Commit c63f5b45 authored by Rob Herring's avatar Rob Herring Committed by Tony Lindgren

ARM: omap2: 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. Use the recently
added of_range_to_resource() function instead for OMAP hwmod.
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Message-ID: <20230609183252.1767487-1-robh@kernel.org>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 937e8722
...@@ -2194,23 +2194,8 @@ int omap_hwmod_parse_module_range(struct omap_hwmod *oh, ...@@ -2194,23 +2194,8 @@ int omap_hwmod_parse_module_range(struct omap_hwmod *oh,
struct resource *res) struct resource *res)
{ {
struct property *prop; struct property *prop;
const __be32 *ranges;
const char *name; const char *name;
u32 nr_addr, nr_size; int err;
u64 base, size;
int len, error;
if (!res)
return -EINVAL;
ranges = of_get_property(np, "ranges", &len);
if (!ranges)
return -ENOENT;
len /= sizeof(*ranges);
if (len < 3)
return -EINVAL;
of_property_for_each_string(np, "compatible", prop, name) of_property_for_each_string(np, "compatible", prop, name)
if (!strncmp("ti,sysc-", name, 8)) if (!strncmp("ti,sysc-", name, 8))
...@@ -2219,26 +2204,12 @@ int omap_hwmod_parse_module_range(struct omap_hwmod *oh, ...@@ -2219,26 +2204,12 @@ int omap_hwmod_parse_module_range(struct omap_hwmod *oh,
if (!name) if (!name)
return -ENOENT; return -ENOENT;
error = of_property_read_u32(np, "#address-cells", &nr_addr); err = of_range_to_resource(np, 0, res);
if (error) if (err)
return -ENOENT; return err;
error = of_property_read_u32(np, "#size-cells", &nr_size); pr_debug("omap_hwmod: %s %pOFn at %pR\n",
if (error) oh->name, np, &res);
return -ENOENT;
if (nr_addr != 1 || nr_size != 1) {
pr_err("%s: invalid range for %s->%pOFn\n", __func__,
oh->name, np);
return -EINVAL;
}
ranges++;
base = of_translate_address(np, ranges++);
size = be32_to_cpup(ranges);
pr_debug("omap_hwmod: %s %pOFn at 0x%llx size 0x%llx\n",
oh->name, np, base, size);
if (oh && oh->mpu_rt_idx) { if (oh && oh->mpu_rt_idx) {
omap_hwmod_fix_mpu_rt_idx(oh, np, res); omap_hwmod_fix_mpu_rt_idx(oh, np, res);
...@@ -2246,10 +2217,6 @@ int omap_hwmod_parse_module_range(struct omap_hwmod *oh, ...@@ -2246,10 +2217,6 @@ int omap_hwmod_parse_module_range(struct omap_hwmod *oh,
return 0; return 0;
} }
res->start = base;
res->end = base + size - 1;
res->flags = IORESOURCE_MEM;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment