Commit 2a88e479 authored by Rob Herring's avatar Rob Herring Committed by Shawn Guo
Browse files

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: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
parent 189cfa84
Loading
Loading
Loading
Loading
+10 −9
Original line number Original line Diff line number Diff line
@@ -10,6 +10,7 @@
#include <linux/module.h>
#include <linux/module.h>
#include <linux/clk.h>
#include <linux/clk.h>
#include <linux/io.h>
#include <linux/io.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/of_device.h>
#include <linux/mfd/syscon.h>
#include <linux/mfd/syscon.h>
#include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
#include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
@@ -86,8 +87,8 @@ MODULE_DEVICE_TABLE(of, weim_id_table);
static int imx_weim_gpr_setup(struct platform_device *pdev)
static int imx_weim_gpr_setup(struct platform_device *pdev)
{
{
	struct device_node *np = pdev->dev.of_node;
	struct device_node *np = pdev->dev.of_node;
	struct property *prop;
	struct of_range_parser parser;
	const __be32 *p;
	struct of_range range;
	struct regmap *gpr;
	struct regmap *gpr;
	u32 gprvals[4] = {
	u32 gprvals[4] = {
		05,	/* CS0(128M) CS1(0M)  CS2(0M)  CS3(0M)  */
		05,	/* CS0(128M) CS1(0M)  CS2(0M)  CS3(0M)  */
@@ -106,13 +107,13 @@ static int imx_weim_gpr_setup(struct platform_device *pdev)
		return 0;
		return 0;
	}
	}


	of_property_for_each_u32(np, "ranges", prop, p, val) {
	if (of_range_parser_init(&parser, np))
		if (i % 4 == 0) {
		goto err;
			cs = val;

		} else if (i % 4 == 3 && val) {
	for_each_of_range(&parser, &range) {
			val = (val / SZ_32M) | 1;
		cs = range.bus_addr >> 32;
		val = (range.size / SZ_32M) | 1;
		gprval |= val << cs * 3;
		gprval |= val << cs * 3;
		}
		i++;
		i++;
	}
	}