Merge tag 'devicetree-fixes-for-6.13-2' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux

Pull devicetree fixes from Rob Herring:
"Another fix and testcase to avoid the newly added WARN in the case of
non-translatable addresses"

* tag 'devicetree-fixes-for-6.13-2' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux:
of/address: Fix WARN when attempting translating non-translatable addresses
of/unittest: Add test that of_address_to_resource() fails on non-translatable address

Changed files
+42 -3
drivers
+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
··· 34 34 }; 35 35 }; 36 36 }; 37 + 38 + platform-tests-2 { 39 + // No #address-cells or #size-cells 40 + node { 41 + #address-cells = <1>; 42 + #size-cells = <1>; 43 + 44 + test-device@100 { 45 + compatible = "test-sub-device"; 46 + reg = <0x100 1>; 47 + }; 48 + }; 49 + }; 37 50 }; 38 51 };
+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 {