Skip to content

Commit 2a88e47

Browse files
robherringShawn Guo
authored andcommitted
bus: imx-weim: 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> Signed-off-by: Shawn Guo <shawnguo@kernel.org>
1 parent 189cfa8 commit 2a88e47

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

drivers/bus/imx-weim.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/module.h>
1111
#include <linux/clk.h>
1212
#include <linux/io.h>
13+
#include <linux/of_address.h>
1314
#include <linux/of_device.h>
1415
#include <linux/mfd/syscon.h>
1516
#include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
@@ -86,8 +87,8 @@ MODULE_DEVICE_TABLE(of, weim_id_table);
8687
static int imx_weim_gpr_setup(struct platform_device *pdev)
8788
{
8889
struct device_node *np = pdev->dev.of_node;
89-
struct property *prop;
90-
const __be32 *p;
90+
struct of_range_parser parser;
91+
struct of_range range;
9192
struct regmap *gpr;
9293
u32 gprvals[4] = {
9394
05, /* CS0(128M) CS1(0M) CS2(0M) CS3(0M) */
@@ -106,13 +107,13 @@ static int imx_weim_gpr_setup(struct platform_device *pdev)
106107
return 0;
107108
}
108109

109-
of_property_for_each_u32(np, "ranges", prop, p, val) {
110-
if (i % 4 == 0) {
111-
cs = val;
112-
} else if (i % 4 == 3 && val) {
113-
val = (val / SZ_32M) | 1;
114-
gprval |= val << cs * 3;
115-
}
110+
if (of_range_parser_init(&parser, np))
111+
goto err;
112+
113+
for_each_of_range(&parser, &range) {
114+
cs = range.bus_addr >> 32;
115+
val = (range.size / SZ_32M) | 1;
116+
gprval |= val << cs * 3;
116117
i++;
117118
}
118119

0 commit comments

Comments
 (0)