Skip to contentSkip to conversation

watchdog: Use device API to replace devfdt_ helpers

PATCH In review Peng Fan (OSS) 2 participants 13 messages May 25 – Jun 9 Watchdog device drivers

lore
Share & tools
lore
#0 lore raw

cover watchdog: Use device API to replace devfdt_ helpers

The goal is to remove the direct usage of devfdt_ APIs in drivers. The device APIs supports both live device tree and flat DT backends, avoiding direct dependency on devfdt_* helpers.

---
Peng Fan (3):
watchdog: orion_wdt: use dev_read_addr_size_index()
watchdog: rti: Use dev_read_addr_ptr()
watchdog: mpc8xxx_wdt: Use dev_remap_addr()

 drivers/watchdog/mpc8xxx_wdt.c | 2 +-
 drivers/watchdog/orion_wdt.c   | 2 +-
 drivers/watchdog/rti_wdt.c     | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

---
base-commit: bb354d04459f5425318aeb8a70bae995ee573f1d
change-id: 20260525-devfdt-wdog-83d0b9d89fb0

Best regards,

Signature · 1 line
Peng Fan <[email protected]>
#1 lore raw

PATCH 1/3 watchdog: orion_wdt: use dev_read_addr_size_index()

From: Peng Fan <[email protected]>

Replace devfdt_read_addr_size_index() with dev_read_addr_size_index() when retrieving the register base address.

dev_read_addr_size_index() supports both live device tree and flat DT backends, avoiding direct dependency on devfdt_* helpers.

No functional changes.

---
 drivers/watchdog/orion_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/orion_wdt.c +1 -1
index a2000b968c9..c9bd40c8d8f 100644
@@ -119,7 +119,7 @@ static inline bool save_reg_from_ofdata(struct udevice *dev, int index,
 	fdt_addr_t addr;
 	fdt_size_t off;
 
-	addr = devfdt_get_addr_size_index(dev, index, &off);
+	addr = dev_read_addr_size_index(dev, index, &off);
 	if (addr == FDT_ADDR_T_NONE)
 		return false;
 
Signature · 1 line
2.51.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] watchdog: orion_wdt: use dev_read_addr_size_index()

Quoted 11 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

Replace devfdt_read_addr_size_index() with dev_read_addr_size_index() when retrieving the register base address.

dev_read_addr_size_index() supports both live device tree and flat DT backends, avoiding direct dependency on devfdt_* helpers.

No functional changes.

Thanks,
Stefan

Quoted 18 lines
---
  drivers/watchdog/orion_wdt.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/orion_wdt.c +1 -1
index a2000b968c9..c9bd40c8d8f 100644
@@ -119,7 +119,7 @@ static inline bool save_reg_from_ofdata(struct udevice *dev, int index,
  	fdt_addr_t addr;
  	fdt_size_t off;
 
-	addr = devfdt_get_addr_size_index(dev, index, &off);
+	addr = dev_read_addr_size_index(dev, index, &off);
  	if (addr == FDT_ADDR_T_NONE)
  		return false;
 
#3 lore raw

Re: [PATCH 1/3] watchdog: orion_wdt: use dev_read_addr_size_index()

In reply to Peng Fan (OSS)
Quoted 11 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

Replace devfdt_read_addr_size_index() with dev_read_addr_size_index() when retrieving the register base address.

dev_read_addr_size_index() supports both live device tree and flat DT backends, avoiding direct dependency on devfdt_* helpers.

No functional changes.

Applied to u-boot-watchdog/next

Thanks,
Stefan

#4 lore raw

Re: [PATCH 1/3] watchdog: orion_wdt: use dev_read_addr_size_index()

In reply to Peng Fan (OSS)
Quoted 11 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

Replace devfdt_read_addr_size_index() with dev_read_addr_size_index() when retrieving the register base address.

dev_read_addr_size_index() supports both live device tree and flat DT backends, avoiding direct dependency on devfdt_* helpers.

No functional changes.

Applied to u-boot-watchdog/next

Thanks,
Stefan

#5 lore raw

PATCH 2/3 watchdog: rti: Use dev_read_addr_ptr()

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

devfdt_get_addr() returns FDT_ADDR_T_NONE(-1UL) when fail, using "!priv->regs" to check return value is wrong.

Replace devfdt_read_addr() with dev_read_addr_ptr() when retrieving the register base address.

dev_read_addr_ptr() supports both live device tree and flat DT backends, avoiding direct dependency on devfdt_* helpers.

Also use "void __iomem *" to replace "phys_addr_t" to avoid type casting.

No functional changes.

---
 drivers/watchdog/rti_wdt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/watchdog/rti_wdt.c +2 -2
index 7b387266b99..866f555789c 100644
@@ -39,7 +39,7 @@
 #define WDT_PRELOAD_MAX		0xfff
 
 struct rti_wdt_priv {
-	phys_addr_t regs;
+	void __iomem *regs;
 	unsigned int clk_hz;
 };
 
@@ -177,7 +177,7 @@ static int rti_wdt_probe(struct udevice *dev)
 	struct clk clk;
 	int ret;
 
-	priv->regs = devfdt_get_addr(dev);
+	priv->regs = dev_read_addr_ptr(dev);
 	if (!priv->regs)
 		return -EINVAL;
 
Signature · 1 line
2.51.0
Reviewed-by on v1 2/3
#6 lore raw

Re: [PATCH 2/3] watchdog: rti: Use dev_read_addr_ptr()

Quoted 11 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

devfdt_get_addr() returns FDT_ADDR_T_NONE(-1UL) when fail, using "!priv->regs" to check return value is wrong.

Replace devfdt_read_addr() with dev_read_addr_ptr() when retrieving the register base address.

dev_read_addr_ptr() supports both live device tree and flat DT backends, avoiding direct dependency on devfdt_* helpers.

Quoted 6 lines

Also use "void __iomem *" to replace "phys_addr_t" to avoid type casting.

No functional changes.

Thanks,
Stefan

Quoted 27 lines
---
  drivers/watchdog/rti_wdt.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/watchdog/rti_wdt.c +2 -2
index 7b387266b99..866f555789c 100644
@@ -39,7 +39,7 @@
  #define WDT_PRELOAD_MAX		0xfff
 
  struct rti_wdt_priv {
-	phys_addr_t regs;
+	void __iomem *regs;
  	unsigned int clk_hz;
  };
 
@@ -177,7 +177,7 @@ static int rti_wdt_probe(struct udevice *dev)
  	struct clk clk;
  	int ret;
 
-	priv->regs = devfdt_get_addr(dev);
+	priv->regs = dev_read_addr_ptr(dev);
  	if (!priv->regs)
  		return -EINVAL;
 
#7 lore raw

Re: [PATCH 2/3] watchdog: rti: Use dev_read_addr_ptr()

In reply to Peng Fan (OSS)
Quoted 11 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

devfdt_get_addr() returns FDT_ADDR_T_NONE(-1UL) when fail, using "!priv->regs" to check return value is wrong.

Replace devfdt_read_addr() with dev_read_addr_ptr() when retrieving the register base address.

dev_read_addr_ptr() supports both live device tree and flat DT backends, avoiding direct dependency on devfdt_* helpers.

Quoted 6 lines

Also use "void __iomem *" to replace "phys_addr_t" to avoid type casting.

No functional changes.

Applied to u-boot-watchdog/next

Thanks,
Stefan

#8 lore raw

Re: [PATCH 2/3] watchdog: rti: Use dev_read_addr_ptr()

In reply to Peng Fan (OSS)
Quoted 11 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

devfdt_get_addr() returns FDT_ADDR_T_NONE(-1UL) when fail, using "!priv->regs" to check return value is wrong.

Replace devfdt_read_addr() with dev_read_addr_ptr() when retrieving the register base address.

dev_read_addr_ptr() supports both live device tree and flat DT backends, avoiding direct dependency on devfdt_* helpers.

Quoted 6 lines

Also use "void __iomem *" to replace "phys_addr_t" to avoid type casting.

No functional changes.

Applied to u-boot-watchdog/next

Thanks,
Stefan

#9 lore raw

PATCH 3/3 watchdog: mpc8xxx_wdt: Use dev_remap_addr()

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Use dev_remap_addr() to replace devfdt_remap_addr which supports both live device tree and flat DT backends, avoiding direct dependency on devfdt_* helpers.

No functional changes.

---
 drivers/watchdog/mpc8xxx_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/mpc8xxx_wdt.c +1 -1
index 7fcb866f574..068f99c5fc6 100644
@@ -81,7 +81,7 @@ static int mpc8xxx_wdt_of_to_plat(struct udevice *dev)
 {
 	struct mpc8xxx_wdt_priv *priv = dev_get_priv(dev);
 
-	priv->base = (void __iomem *)devfdt_remap_addr(dev);
+	priv->base = (void __iomem *)dev_remap_addr(dev);
 
 	if (!priv->base)
 		return -EINVAL;
Signature · 1 line
2.51.0
Reviewed-by on v1 3/3
#10 lore raw

Re: [PATCH 3/3] watchdog: mpc8xxx_wdt: Use dev_remap_addr()

Quoted 9 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

Use dev_remap_addr() to replace devfdt_remap_addr which supports both live device tree and flat DT backends, avoiding direct dependency on devfdt_* helpers.

No functional changes.

Thanks,
Stefan

Quoted 18 lines
---
  drivers/watchdog/mpc8xxx_wdt.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/mpc8xxx_wdt.c +1 -1
index 7fcb866f574..068f99c5fc6 100644
@@ -81,7 +81,7 @@ static int mpc8xxx_wdt_of_to_plat(struct udevice *dev)
  {
  	struct mpc8xxx_wdt_priv *priv = dev_get_priv(dev);
 
-	priv->base = (void __iomem *)devfdt_remap_addr(dev);
+	priv->base = (void __iomem *)dev_remap_addr(dev);
 
  	if (!priv->base)
  		return -EINVAL;