mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-22 07:53:11 -05:00
Devicetree fixes for 6.13, part 2:
Another fix and testcase to avoid the newly added WARN in the case of non-translatable addresses. -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEktVUI4SxYhzZyEuo+vtdtY28YcMFAmeK0gAACgkQ+vtdtY28 YcNanRAAjtXeeRK8NZJ9JfjTDaNMxQJ89WVSKmbJBNH8M/hWFK9eq2fJvNwnPJJT 4xHfWvNr7znyC2kLm6k/LKGmyV/mQqiJ8vCaBKQ1KssjQ1hXR7JiXbniw78Rc0LD zfY9nDxMRm8jJhz5T0TNfhWn1bBAUA9dibew8etdo2KqCXGrFnGIZoeFU/ro8Tzy /bW90QhlUxze9V4bH/4UBvTmfK8WmSTobG9r7Z2/YXcbTxB1uDGKZhV4jhJ4Issa qrue201VlReHdRmiYWeDz57m/aXBudOvLaDJVymzoYJU5FypNH/757cvmysiQxzq tRRLgZLhAye5qB3HCX5xa6v3CvAvuf01EzTMMLKuKA4IkkaoO6CjjG7D/ip4lvdc Ekt4OFGYdxGQaJNeXmaLioJzhrsS0NQe4ZFUQF1YnMdOfI3vneVsRcG6CHgKyfft pnoBiakIiapNj4S/UTn+A2bI+/rG0P9rbMwhpb3ojJBlp5IpC/8vqKzeA8Hzy19I 3Yi3lfX4sscSvQJk6izkTxwDMfx/FsrQfkf6PS8eYfhAlyMcc1JKuxN15sIoEth7 TapRH0hR5aCe64jYWpIEIwaVb+d2izdEPf+9Dd7v/LBRe44mvHnLAMs2936UxvUg U/dKP9iR/pWaibPpIGuK6RCRY4uO6qJfzwvSRPrJNohZUk8RNhM= =Uw0f -----END PGP SIGNATURE----- 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
This commit is contained in:
commit
595523945b
3 changed files with 42 additions and 3 deletions
|
@ -340,6 +340,15 @@ static int of_bus_default_flags_match(struct device_node *np)
|
||||||
return of_property_present(np, "#address-cells") && (of_bus_n_addr_cells(np) == 3);
|
return of_property_present(np, "#address-cells") && (of_bus_n_addr_cells(np) == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int of_bus_default_match(struct device_node *np)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Check for presence first since of_bus_n_addr_cells() will warn when
|
||||||
|
* walking parent nodes.
|
||||||
|
*/
|
||||||
|
return of_property_present(np, "#address-cells");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Array of bus specific translators
|
* Array of bus specific translators
|
||||||
*/
|
*/
|
||||||
|
@ -384,7 +393,7 @@ static const struct of_bus of_busses[] = {
|
||||||
{
|
{
|
||||||
.name = "default",
|
.name = "default",
|
||||||
.addresses = "reg",
|
.addresses = "reg",
|
||||||
.match = NULL,
|
.match = of_bus_default_match,
|
||||||
.count_cells = of_bus_default_count_cells,
|
.count_cells = of_bus_default_count_cells,
|
||||||
.map = of_bus_default_map,
|
.map = of_bus_default_map,
|
||||||
.translate = of_bus_default_translate,
|
.translate = of_bus_default_translate,
|
||||||
|
@ -399,7 +408,6 @@ static const struct of_bus *of_match_bus(struct device_node *np)
|
||||||
for (i = 0; i < ARRAY_SIZE(of_busses); i++)
|
for (i = 0; i < ARRAY_SIZE(of_busses); i++)
|
||||||
if (!of_busses[i].match || of_busses[i].match(np))
|
if (!of_busses[i].match || of_busses[i].match(np))
|
||||||
return &of_busses[i];
|
return &of_busses[i];
|
||||||
BUG();
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,6 +529,8 @@ static u64 __of_translate_address(struct device_node *node,
|
||||||
if (parent == NULL)
|
if (parent == NULL)
|
||||||
return OF_BAD_ADDR;
|
return OF_BAD_ADDR;
|
||||||
bus = of_match_bus(parent);
|
bus = of_match_bus(parent);
|
||||||
|
if (!bus)
|
||||||
|
return OF_BAD_ADDR;
|
||||||
|
|
||||||
/* Count address cells & copy address locally */
|
/* Count address cells & copy address locally */
|
||||||
bus->count_cells(dev, &na, &ns);
|
bus->count_cells(dev, &na, &ns);
|
||||||
|
@ -564,6 +574,8 @@ static u64 __of_translate_address(struct device_node *node,
|
||||||
|
|
||||||
/* Get new parent bus and counts */
|
/* Get new parent bus and counts */
|
||||||
pbus = of_match_bus(parent);
|
pbus = of_match_bus(parent);
|
||||||
|
if (!pbus)
|
||||||
|
return OF_BAD_ADDR;
|
||||||
pbus->count_cells(dev, &pna, &pns);
|
pbus->count_cells(dev, &pna, &pns);
|
||||||
if (!OF_CHECK_COUNTS(pna, pns)) {
|
if (!OF_CHECK_COUNTS(pna, pns)) {
|
||||||
pr_err("Bad cell count for %pOF\n", dev);
|
pr_err("Bad cell count for %pOF\n", dev);
|
||||||
|
@ -703,7 +715,7 @@ const __be32 *__of_get_address(struct device_node *dev, int index, int bar_no,
|
||||||
|
|
||||||
/* match the parent's bus type */
|
/* match the parent's bus type */
|
||||||
bus = of_match_bus(parent);
|
bus = of_match_bus(parent);
|
||||||
if (strcmp(bus->name, "pci") && (bar_no >= 0))
|
if (!bus || (strcmp(bus->name, "pci") && (bar_no >= 0)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Get "reg" or "assigned-addresses" property */
|
/* Get "reg" or "assigned-addresses" property */
|
||||||
|
|
|
@ -34,5 +34,18 @@ dev@100 {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
platform-tests-2 {
|
||||||
|
// No #address-cells or #size-cells
|
||||||
|
node {
|
||||||
|
#address-cells = <1>;
|
||||||
|
#size-cells = <1>;
|
||||||
|
|
||||||
|
test-device@100 {
|
||||||
|
compatible = "test-sub-device";
|
||||||
|
reg = <0x100 1>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1380,6 +1380,7 @@ static void __init of_unittest_bus_3cell_ranges(void)
|
||||||
static void __init of_unittest_reg(void)
|
static void __init of_unittest_reg(void)
|
||||||
{
|
{
|
||||||
struct device_node *np;
|
struct device_node *np;
|
||||||
|
struct resource res;
|
||||||
int ret;
|
int ret;
|
||||||
u64 addr, size;
|
u64 addr, size;
|
||||||
|
|
||||||
|
@ -1396,6 +1397,19 @@ static void __init of_unittest_reg(void)
|
||||||
np, addr);
|
np, addr);
|
||||||
|
|
||||||
of_node_put(np);
|
of_node_put(np);
|
||||||
|
|
||||||
|
np = of_find_node_by_path("/testcase-data/platform-tests-2/node/test-device@100");
|
||||||
|
if (!np) {
|
||||||
|
pr_err("missing testcase data\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = of_address_to_resource(np, 0, &res);
|
||||||
|
unittest(ret == -EINVAL, "of_address_to_resource(%pOF) expected error on untranslatable address\n",
|
||||||
|
np);
|
||||||
|
|
||||||
|
of_node_put(np);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct of_unittest_expected_res {
|
struct of_unittest_expected_res {
|
||||||
|
|
Loading…
Reference in a new issue