Commit b79221a7d9132fd7bfd81cad9ebdc37acb39f69e
Committed by
Simon Glass
1 parent
2e38662dc6
Exists in
smarc_8mq_lf_v2020.04
and in
17 other branches
lib: fdtdec: Fix some style violations
Fix some style violations in fdtdec.c, and reduce the scope of some variables. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Mario Six <mario.six@gdsys.cc>
Showing 1 changed file with 15 additions and 14 deletions Side-by-side Diff
lib/fdtdec.c
... | ... | @@ -233,10 +233,10 @@ |
233 | 233 | addr->phys_mid = fdt32_to_cpu(cell[1]); |
234 | 234 | addr->phys_lo = fdt32_to_cpu(cell[1]); |
235 | 235 | break; |
236 | - } else { | |
237 | - cell += (FDT_PCI_ADDR_CELLS + | |
238 | - FDT_PCI_SIZE_CELLS); | |
239 | 236 | } |
237 | + | |
238 | + cell += (FDT_PCI_ADDR_CELLS + | |
239 | + FDT_PCI_SIZE_CELLS); | |
240 | 240 | } |
241 | 241 | |
242 | 242 | if (i == num) { |
243 | 243 | |
... | ... | @@ -245,10 +245,10 @@ |
245 | 245 | } |
246 | 246 | |
247 | 247 | return 0; |
248 | - } else { | |
249 | - ret = -EINVAL; | |
250 | 248 | } |
251 | 249 | |
250 | + ret = -EINVAL; | |
251 | + | |
252 | 252 | fail: |
253 | 253 | debug("(not found)\n"); |
254 | 254 | return ret; |
255 | 255 | |
... | ... | @@ -265,11 +265,9 @@ |
265 | 265 | |
266 | 266 | end = list + len; |
267 | 267 | while (list < end) { |
268 | - char *s; | |
269 | - | |
270 | 268 | len = strlen(list); |
271 | 269 | if (len >= strlen("pciVVVV,DDDD")) { |
272 | - s = strstr(list, "pci"); | |
270 | + char *s = strstr(list, "pci"); | |
273 | 271 | |
274 | 272 | /* |
275 | 273 | * check if the string is something like pciVVVV,DDDD.RR |
... | ... | @@ -299,7 +297,7 @@ |
299 | 297 | |
300 | 298 | /* extract the bar number from fdt_pci_addr */ |
301 | 299 | barnum = addr->phys_hi & 0xff; |
302 | - if ((barnum < PCI_BASE_ADDRESS_0) || (barnum > PCI_CARDBUS_CIS)) | |
300 | + if (barnum < PCI_BASE_ADDRESS_0 || barnum > PCI_CARDBUS_CIS) | |
303 | 301 | return -EINVAL; |
304 | 302 | |
305 | 303 | barnum = (barnum - PCI_BASE_ADDRESS_0) / 4; |
... | ... | @@ -335,7 +333,7 @@ |
335 | 333 | */ |
336 | 334 | cell = fdt_getprop(blob, node, "status", NULL); |
337 | 335 | if (cell) |
338 | - return 0 == strcmp(cell, "okay"); | |
336 | + return strcmp(cell, "okay") == 0; | |
339 | 337 | return 1; |
340 | 338 | } |
341 | 339 | |
... | ... | @@ -345,8 +343,8 @@ |
345 | 343 | |
346 | 344 | /* Search our drivers */ |
347 | 345 | for (id = COMPAT_UNKNOWN; id < COMPAT_COUNT; id++) |
348 | - if (0 == fdt_node_check_compatible(blob, node, | |
349 | - compat_names[id])) | |
346 | + if (fdt_node_check_compatible(blob, node, | |
347 | + compat_names[id]) == 0) | |
350 | 348 | return id; |
351 | 349 | return COMPAT_UNKNOWN; |
352 | 350 | } |
353 | 351 | |
... | ... | @@ -665,12 +663,14 @@ |
665 | 663 | u32 *array, int count) |
666 | 664 | { |
667 | 665 | const u32 *cell; |
668 | - int i, err = 0; | |
666 | + int err = 0; | |
669 | 667 | |
670 | 668 | debug("%s: %s\n", __func__, prop_name); |
671 | 669 | cell = get_prop_check_min_len(blob, node, prop_name, |
672 | 670 | sizeof(u32) * count, &err); |
673 | 671 | if (!err) { |
672 | + int i; | |
673 | + | |
674 | 674 | for (i = 0; i < count; i++) |
675 | 675 | array[i] = fdt32_to_cpu(cell[i]); |
676 | 676 | } |
... | ... | @@ -975,7 +975,8 @@ |
975 | 975 | |
976 | 976 | while (ptr + na + ns <= end) { |
977 | 977 | if (i == index) { |
978 | - res->start = res->end = fdtdec_get_number(ptr, na); | |
978 | + res->start = fdtdec_get_number(ptr, na); | |
979 | + res->end = res->start; | |
979 | 980 | res->end += fdtdec_get_number(&ptr[na], ns) - 1; |
980 | 981 | return 0; |
981 | 982 | } |