[PATCH] mtd: rpc: renesas: Switch to dev_read_addr_name()

Marek Vasut via U-Boot <[email protected]>
Newsgroups org.u-boot-project.lists.u-boot
Message-ID <[email protected]>
Simplify the DT register address parsing using dev_read_addr_name(),
switch away from raw fdt_*() functions. No functional change.

Signed-off-by: Marek Vasut <[email protected]>
---
Cc: Johan Jonker <[email protected]>
Cc: Nobuhiro Iwamatsu <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
---
 drivers/mtd/renesas_rpc_hf.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/mtd/renesas_rpc_hf.c b/drivers/mtd/renesas_rpc_hf.c
index 9390c9e9ab3..0b4459df4d6 100644
--- a/drivers/mtd/renesas_rpc_hf.c
+++ b/drivers/mtd/renesas_rpc_hf.c
@@ -344,21 +344,21 @@ static int rpc_hf_bind(struct udevice *parent)
 
 static int rpc_hf_probe(struct udevice *dev)
 {
-	void *blob = (void *)gd->fdt_blob;
-	const fdt32_t *cell;
-	int node = dev_of_offset(dev);
-	int parent, addrc, sizec, len, ret;
-	struct clk clk;
 	phys_addr_t flash_base;
+	struct clk clk;
+	int ret;
 
-	parent = fdt_parent_offset(blob, node);
-	fdt_support_default_count_cells(blob, parent, &addrc, &sizec);
-	cell = fdt_getprop(blob, node, "reg", &len);
-	if (!cell)
-		return -ENOENT;
+	rpc_base = dev_read_addr_name(dev, "regs");
+	if (rpc_base == FDT_ADDR_T_NONE) {
+		dev_err(dev, "Failed to get RPC control registers\n");
+		return -EINVAL;
+	}
 
-	if (addrc != 2 || sizec != 2)
+	flash_base = dev_read_addr_name(dev, "dirmap");
+	if (flash_base == FDT_ADDR_T_NONE) {
+		dev_err(dev, "Failed to get RPC direct map registers\n");
 		return -EINVAL;
+	}
 
 	ret = clk_get_by_index(dev, 0, &clk);
 	if (ret < 0) {
@@ -372,9 +372,6 @@ static int rpc_hf_probe(struct udevice *dev)
 		return ret;
 	}
 
-	rpc_base = fdt_translate_address(blob, node, cell);
-	flash_base = fdt_translate_address(blob, node, cell + addrc + sizec);
-
 	flash_info[0].dev = dev;
 	flash_info[0].base = flash_base;
 	cfi_flash_num_flash_banks = 1;
-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.