powerpc: fsl_rio: Use of_range_to_resource() for "ranges" parsing
"ranges" is a standard property with common parsing functions. Users shouldn't be implementing their own parsing of it. Refactor the FSL RapidIO "ranges" parsing to use of_range_to_resource() instead. One change is the original code would look for "#size-cells" and "#address-cells" in the parent node if not found in the port child nodes. That is non-standard behavior and not necessary AFAICT. In 2011 in commit 54986964c13c ("powerpc/85xx: Update SRIO device tree nodes") there was an ABI break. The upstream .dts files have been correct since at least that point. Signed-off-by: Rob Herring <robh@kernel.org> [mpe: Remove now unused "cell" variable] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20230609183244.1767325-1-robh@kernel.org "ranges" is a standard property with common parsing functions. Users shouldn't be implementing their own parsing of it. Refactor the FSL RapidIO "ranges" parsing to use of_range_to_resource() instead. One change is the original code would look for "#size-cells" and "#address-cells" in the parent node if not found in the port child nodes. That is non-standard behavior and not necessary AFAICT. In 2011 in commit 54986964c13c ("powerpc/85xx: Update SRIO device tree nodes") there was an ABI break. The upstream .dts files have been correct since at least that point. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20230609183244.1767325-1-robh@kernel.org
This commit is contained in:
parent
6f3bdbbeaf
commit
c4ae1799a5
@ -448,13 +448,13 @@ int fsl_rio_setup(struct platform_device *dev)
|
|||||||
struct rio_mport *port;
|
struct rio_mport *port;
|
||||||
struct rio_priv *priv;
|
struct rio_priv *priv;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
const u32 *dt_range, *cell, *port_index;
|
const u32 *dt_range, *port_index;
|
||||||
u32 active_ports = 0;
|
u32 active_ports = 0;
|
||||||
struct device_node *np, *rmu_node;
|
struct device_node *np, *rmu_node;
|
||||||
int rlen;
|
int rlen;
|
||||||
u32 ccsr;
|
u32 ccsr;
|
||||||
u64 range_start, range_size;
|
u64 range_start;
|
||||||
int paw, aw, sw;
|
int aw;
|
||||||
u32 i;
|
u32 i;
|
||||||
static int tmp;
|
static int tmp;
|
||||||
struct device_node *rmu_np[MAX_MSG_UNIT_NUM] = {NULL};
|
struct device_node *rmu_np[MAX_MSG_UNIT_NUM] = {NULL};
|
||||||
@ -569,6 +569,8 @@ int fsl_rio_setup(struct platform_device *dev)
|
|||||||
|
|
||||||
/*set up ports node*/
|
/*set up ports node*/
|
||||||
for_each_child_of_node(dev->dev.of_node, np) {
|
for_each_child_of_node(dev->dev.of_node, np) {
|
||||||
|
struct resource res;
|
||||||
|
|
||||||
port_index = of_get_property(np, "cell-index", NULL);
|
port_index = of_get_property(np, "cell-index", NULL);
|
||||||
if (!port_index) {
|
if (!port_index) {
|
||||||
dev_err(&dev->dev, "Can't get %pOF property 'cell-index'\n",
|
dev_err(&dev->dev, "Can't get %pOF property 'cell-index'\n",
|
||||||
@ -576,32 +578,14 @@ int fsl_rio_setup(struct platform_device *dev)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
dt_range = of_get_property(np, "ranges", &rlen);
|
if (of_range_to_resource(np, 0, &res)) {
|
||||||
if (!dt_range) {
|
|
||||||
dev_err(&dev->dev, "Can't get %pOF property 'ranges'\n",
|
dev_err(&dev->dev, "Can't get %pOF property 'ranges'\n",
|
||||||
np);
|
np);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get node address wide */
|
dev_info(&dev->dev, "%pOF: LAW %pR\n",
|
||||||
cell = of_get_property(np, "#address-cells", NULL);
|
np, &res);
|
||||||
if (cell)
|
|
||||||
aw = *cell;
|
|
||||||
else
|
|
||||||
aw = of_n_addr_cells(np);
|
|
||||||
/* Get node size wide */
|
|
||||||
cell = of_get_property(np, "#size-cells", NULL);
|
|
||||||
if (cell)
|
|
||||||
sw = *cell;
|
|
||||||
else
|
|
||||||
sw = of_n_size_cells(np);
|
|
||||||
/* Get parent address wide wide */
|
|
||||||
paw = of_n_addr_cells(np);
|
|
||||||
range_start = of_read_number(dt_range + aw, paw);
|
|
||||||
range_size = of_read_number(dt_range + aw + paw, sw);
|
|
||||||
|
|
||||||
dev_info(&dev->dev, "%pOF: LAW start 0x%016llx, size 0x%016llx.\n",
|
|
||||||
np, range_start, range_size);
|
|
||||||
|
|
||||||
port = kzalloc(sizeof(struct rio_mport), GFP_KERNEL);
|
port = kzalloc(sizeof(struct rio_mport), GFP_KERNEL);
|
||||||
if (!port)
|
if (!port)
|
||||||
@ -624,9 +608,7 @@ int fsl_rio_setup(struct platform_device *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
INIT_LIST_HEAD(&port->dbells);
|
INIT_LIST_HEAD(&port->dbells);
|
||||||
port->iores.start = range_start;
|
port->iores = res; /* struct copy */
|
||||||
port->iores.end = port->iores.start + range_size - 1;
|
|
||||||
port->iores.flags = IORESOURCE_MEM;
|
|
||||||
port->iores.name = "rio_io_win";
|
port->iores.name = "rio_io_win";
|
||||||
|
|
||||||
if (request_resource(&iomem_resource, &port->iores) < 0) {
|
if (request_resource(&iomem_resource, &port->iores) < 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user