mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-04 04:02:26 +00:00
bus: ti-sysc: Remove open coded "ranges" parsing
"ranges" is a standard property and we have common helper functions for parsing it, so let's use them. Signed-off-by: Rob Herring <robh@kernel.org> Message-Id: <20230201220002.246907-1-robh@kernel.org> Signed-off-by: Tony Lindgren <tony@atomide.com>
This commit is contained in:
parent
fe15c26ee2
commit
41e4f807f8
@ -648,43 +648,20 @@ static int sysc_init_resets(struct sysc *ddata)
|
|||||||
static int sysc_parse_and_check_child_range(struct sysc *ddata)
|
static int sysc_parse_and_check_child_range(struct sysc *ddata)
|
||||||
{
|
{
|
||||||
struct device_node *np = ddata->dev->of_node;
|
struct device_node *np = ddata->dev->of_node;
|
||||||
const __be32 *ranges;
|
struct of_range_parser parser;
|
||||||
u32 nr_addr, nr_size;
|
struct of_range range;
|
||||||
int len, error;
|
int error;
|
||||||
|
|
||||||
ranges = of_get_property(np, "ranges", &len);
|
error = of_range_parser_init(&parser, np);
|
||||||
if (!ranges) {
|
|
||||||
dev_err(ddata->dev, "missing ranges for %pOF\n", np);
|
|
||||||
|
|
||||||
return -ENOENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
len /= sizeof(*ranges);
|
|
||||||
|
|
||||||
if (len < 3) {
|
|
||||||
dev_err(ddata->dev, "incomplete ranges for %pOF\n", np);
|
|
||||||
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
error = of_property_read_u32(np, "#address-cells", &nr_addr);
|
|
||||||
if (error)
|
if (error)
|
||||||
return -ENOENT;
|
return error;
|
||||||
|
|
||||||
error = of_property_read_u32(np, "#size-cells", &nr_size);
|
for_each_of_range(&parser, &range) {
|
||||||
if (error)
|
ddata->module_pa = range.cpu_addr;
|
||||||
return -ENOENT;
|
ddata->module_size = range.size;
|
||||||
|
break;
|
||||||
if (nr_addr != 1 || nr_size != 1) {
|
|
||||||
dev_err(ddata->dev, "invalid ranges for %pOF\n", np);
|
|
||||||
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ranges++;
|
|
||||||
ddata->module_pa = of_translate_address(np, ranges++);
|
|
||||||
ddata->module_size = be32_to_cpup(ranges);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user