of/unittest: Add test that of_address_to_resource() fails on non-translatable address

of_address_to_resource() on a non-translatable address should return an
error. Additionally, this case also triggers a spurious WARN for
missing #address-cells/#size-cells.

Link: https://lore.kernel.org/r/20250110215030.3637845-1-robh@kernel.org
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>

Changed files
+27
drivers
of
+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 {