+15
-3
drivers/of/address.c
+15
-3
drivers/of/address.c
···
340
340
return of_property_present(np, "#address-cells") && (of_bus_n_addr_cells(np) == 3);
341
341
}
342
342
343
+
static int of_bus_default_match(struct device_node *np)
344
+
{
345
+
/*
346
+
* Check for presence first since of_bus_n_addr_cells() will warn when
347
+
* walking parent nodes.
348
+
*/
349
+
return of_property_present(np, "#address-cells");
350
+
}
351
+
343
352
/*
344
353
* Array of bus specific translators
345
354
*/
···
393
384
{
394
385
.name = "default",
395
386
.addresses = "reg",
396
-
.match = NULL,
387
+
.match = of_bus_default_match,
397
388
.count_cells = of_bus_default_count_cells,
398
389
.map = of_bus_default_map,
399
390
.translate = of_bus_default_translate,
···
408
399
for (i = 0; i < ARRAY_SIZE(of_busses); i++)
409
400
if (!of_busses[i].match || of_busses[i].match(np))
410
401
return &of_busses[i];
411
-
BUG();
412
402
return NULL;
413
403
}
414
404
···
529
521
if (parent == NULL)
530
522
return OF_BAD_ADDR;
531
523
bus = of_match_bus(parent);
524
+
if (!bus)
525
+
return OF_BAD_ADDR;
532
526
533
527
/* Count address cells & copy address locally */
534
528
bus->count_cells(dev, &na, &ns);
···
574
564
575
565
/* Get new parent bus and counts */
576
566
pbus = of_match_bus(parent);
567
+
if (!pbus)
568
+
return OF_BAD_ADDR;
577
569
pbus->count_cells(dev, &pna, &pns);
578
570
if (!OF_CHECK_COUNTS(pna, pns)) {
579
571
pr_err("Bad cell count for %pOF\n", dev);
···
715
703
716
704
/* match the parent's bus type */
717
705
bus = of_match_bus(parent);
718
-
if (strcmp(bus->name, "pci") && (bar_no >= 0))
706
+
if (!bus || (strcmp(bus->name, "pci") && (bar_no >= 0)))
719
707
return NULL;
720
708
721
709
/* Get "reg" or "assigned-addresses" property */
+13
drivers/of/unittest-data/tests-platform.dtsi
+13
drivers/of/unittest-data/tests-platform.dtsi
+14
drivers/of/unittest.c
+14
drivers/of/unittest.c
···
1380
1380
static void __init of_unittest_reg(void)
1381
1381
{
1382
1382
struct device_node *np;
1383
+
struct resource res;
1383
1384
int ret;
1384
1385
u64 addr, size;
1385
1386
···
1397
1396
np, addr);
1398
1397
1399
1398
of_node_put(np);
1399
+
1400
+
np = of_find_node_by_path("/testcase-data/platform-tests-2/node/test-device@100");
1401
+
if (!np) {
1402
+
pr_err("missing testcase data\n");
1403
+
return;
1404
+
}
1405
+
1406
+
ret = of_address_to_resource(np, 0, &res);
1407
+
unittest(ret == -EINVAL, "of_address_to_resource(%pOF) expected error on untranslatable address\n",
1408
+
np);
1409
+
1410
+
of_node_put(np);
1411
+
1400
1412
}
1401
1413
1402
1414
struct of_unittest_expected_res {