Skip to contentSkip to conversation

net: Use dev APIs

PATCH Superseded Peng Fan (OSS) 3 participants 15 messages May 26 – May 27 Network drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover net: Use dev APIs

This series converts several Ethernet drivers to use the generic device model APIs for device tree access, replacing devfdt_* and fdtdec/fdt_* interfaces.

The goal is to improve compatibility with both live device tree and flat device tree backends, and to reduce direct dependencies on low-level FDT helpers.

Patches 1–5 perform straightforward replacements:
- devfdt_get_addr() → dev_read_addr()
- devfdt_get_addr_index() → dev_read_addr_index()
- devfdt_get_addr_index_ptr() → dev_read_addr_index_ptr()
- map_physmem(devfdt_get_addr()) → dev_remap_addr()

These changes are mechanical and introduce no functional change.

Patch 6 converts the mvpp2 driver from legacy fdtdec/fdt_* APIs to ofnode-based interfaces. This removes dependencies on gd->fdt_blob and updates phandle parsing, subnode iteration, property access, and device lookup.

No intended functional changes.

I not have the platforms to test, just best practice for this work.

---
Peng Fan (6):
net: ethoc: Use dev_read_addr_index()
net: qe: dm_qe_uec: Use dev_read_addr()
net: calxedaxgmac: Use dev_read_addr()
net: dc2114x: Use dev_remap_addr()
net: mvpp2: Use dev_read_addr_index_ptr()
net: mvpp2: convert FDT access to ofnode API

 drivers/net/calxedaxgmac.c |  2 +-
 drivers/net/dc2114x.c      |  2 +-
 drivers/net/ethoc.c        |  2 +-
 drivers/net/mvpp2.c        | 63 +++++++++++++++++++++++-----------------------
 drivers/net/qe/dm_qe_uec.c |  2 +-
 5 files changed, 35 insertions(+), 36 deletions(-)

---
base-commit: bb354d04459f5425318aeb8a70bae995ee573f1d
change-id: 20260526-devfdt-net-a0fe75cd7f49

Best regards,

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

PATCH 1/6 net: ethoc: Use dev_read_addr_index()

From: Peng Fan <[email protected]>

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

No functional changes.

---
 drivers/net/ethoc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethoc.c +1 -1
index dc7e6f1929f..87b2b3426c8 100644
@@ -686,7 +686,7 @@ static int ethoc_of_to_plat(struct udevice *dev)
 	fdt_addr_t addr;
 
 	pdata->eth_pdata.iobase = dev_read_addr(dev);
-	addr = devfdt_get_addr_index(dev, 1);
+	addr = dev_read_addr_index(dev, 1);
 	if (addr != FDT_ADDR_T_NONE)
 		pdata->packet_base = addr;
 	return 0;
Signature · 1 line
2.51.0
Reviewed-by on v1 1/6
#2 lore raw

Re: [PATCH 1/6] net: ethoc: Use dev_read_addr_index()

Quoted 11 lines · Peng Fan (OSS)

net: ethoc: Use dev_read_addr_index()

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

No functional changes.

drivers/net/ethoc.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
#3 lore raw

PATCH 2/6 net: qe: dm_qe_uec: Use dev_read_addr()

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

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

No functional changes.

---
 drivers/net/qe/dm_qe_uec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/qe/dm_qe_uec.c +1 -1
index ac3aedd8b49..f9bc5d49c8f 100644
@@ -1133,7 +1133,7 @@ static int qe_uec_of_to_plat(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_plat(dev);
 
-	pdata->iobase = (phys_addr_t)devfdt_get_addr(dev);
+	pdata->iobase = (phys_addr_t)dev_read_addr(dev);
 
 	pdata->phy_interface = dev_read_phy_mode(dev);
 	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
Signature · 1 line
2.51.0
Reviewed-by on v1 2/6
#4 lore raw

Re: [PATCH 2/6] net: qe: dm_qe_uec: Use dev_read_addr()

Quoted 11 lines · Peng Fan (OSS)

net: qe: dm_qe_uec: Use dev_read_addr()

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

No functional changes.

drivers/net/qe/dm_qe_uec.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
#5 lore raw

PATCH 3/6 net: calxedaxgmac: Use dev_read_addr()

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

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

No functional changes.

---
 drivers/net/calxedaxgmac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/calxedaxgmac.c +1 -1
index 92990fa6d47..df0ed820e06 100644
@@ -555,7 +555,7 @@ static int xgmac_ofdata_to_platdata(struct udevice *dev)
 		return -ENOMEM;
 	dev_set_priv(dev, priv);
 
-	pdata->iobase = devfdt_get_addr(dev);
+	pdata->iobase = dev_read_addr(dev);
 	if (pdata->iobase == FDT_ADDR_T_NONE) {
 		printf("%s: Cannot find XGMAC base address\n", __func__);
 		return -EINVAL;
Signature · 1 line
2.51.0
Reviewed-by on v1 3/6
#6 lore raw

Re: [PATCH 3/6] net: calxedaxgmac: Use dev_read_addr()

Quoted 11 lines · Peng Fan (OSS)

net: calxedaxgmac: Use dev_read_addr()

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

No functional changes.

drivers/net/calxedaxgmac.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
#7 lore raw

PATCH 4/6 net: dc2114x: Use dev_remap_addr()

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Use dev_remap_addr() to simplify code.

dev_remap_addr() does same thing as dev_read_addr() + map_physmem(). And it supports both live device tree and flat DT backends, avoiding direct dependency on devfdt_* helpers.

No functional changes.

---
 drivers/net/dc2114x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dc2114x.c +1 -1
index 8fa549280aa..2a21eceac57 100644
@@ -653,7 +653,7 @@ static int dc2114x_of_to_plat(struct udevice *dev)
 	struct eth_pdata *plat = dev_get_plat(dev);
 	struct dc2114x_priv *priv = dev_get_priv(dev);
 
-	plat->iobase = (phys_addr_t)map_physmem((phys_addr_t)devfdt_get_addr(dev), 0, MAP_NOCACHE);
+	plat->iobase = (phys_addr_t)dev_remap_addr(dev);
 	priv->iobase = (void *)plat->iobase;
 
 	return 0;
Signature · 1 line
2.51.0
Reviewed-by on v1 4/6
#8 lore raw

Re: [PATCH 4/6] net: dc2114x: Use dev_remap_addr()

Quoted 8 lines · Peng Fan (OSS)

net: dc2114x: Use dev_remap_addr()

Use dev_remap_addr() to simplify code.

dev_remap_addr() does same thing as dev_read_addr() + map_physmem(). And it supports both live device tree and flat DT backends, avoiding direct dependency on devfdt_* helpers.

Quoted 6 lines

No functional changes.

drivers/net/dc2114x.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
#9 lore raw

PATCH 5/6 net: mvpp2: Use dev_read_addr_index_ptr()

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

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

No functional changes.

---
 drivers/net/mvpp2.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/mvpp2.c +4 -5
index f9e979c4d58..193f82ea07d 100644
@@ -5296,16 +5296,16 @@ static int mvpp2_base_probe(struct udevice *dev)
 	}
 
 	/* Save base addresses for later use */
-	priv->base = devfdt_get_addr_index_ptr(dev, 0);
+	priv->base = dev_read_addr_index_ptr(dev, 0);
 	if (!priv->base)
 		return -EINVAL;
 
 	if (priv->hw_version == MVPP21) {
-		priv->lms_base = devfdt_get_addr_index_ptr(dev, 1);
+		priv->lms_base = dev_read_addr_index_ptr(dev, 1);
 		if (!priv->lms_base)
 			return -EINVAL;
 	} else {
-		priv->iface_base = devfdt_get_addr_index_ptr(dev, 1);
+		priv->iface_base = dev_read_addr_index_ptr(dev, 1);
 		if (!priv->iface_base)
 			return -EINVAL;
 
@@ -5346,8 +5346,7 @@ static int mvpp2_probe(struct udevice *dev)
 	if (priv->hw_version == MVPP21) {
 		int priv_common_regs_num = 2;
 
-		port->base = devfdt_get_addr_index_ptr(
-			dev->parent, priv_common_regs_num + port->id);
+		port->base = dev_read_addr_index_ptr(dev->parent, priv_common_regs_num + port->id);
 		if (!port->base)
 			return -EINVAL;
 	} else {
Signature · 1 line
2.51.0
Reviewed-by on v1 5/6
#10 lore raw

Re: [PATCH 5/6] net: mvpp2: Use dev_read_addr_index_ptr()

Hi Peng,

Quoted 11 lines · Peng Fan (OSS)

net: mvpp2: Use dev_read_addr_index_ptr()

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

No functional changes.

drivers/net/mvpp2.c | 9 ++++-----

 1 file changed, 4 insertions(+), 5 deletions(-)

drivers/net/mvpp2.c static int mvpp2_probe(struct udevice *dev) · line 5349

Quoted 8 lines
drivers/net/mvpp2.c +1 -2
@@ -5346,8 +5346,7 @@ static int mvpp2_probe(struct udevice *dev)
      if (priv->hw_version == MVPP21) {
              int priv_common_regs_num = 2;
 
-             port->base = devfdt_get_addr_index_ptr(
-                     dev->parent, priv_common_regs_num + port->id);
+             port->base = dev_read_addr_index_ptr(dev->parent, priv_common_regs_num + port->id);

Please keep the wrap to stay within 80 columns:

port->base = dev_read_addr_index_ptr(dev->parent,

                                        priv_common_regs_num + port->id);

Regards,
Simon

#11 lore raw

PATCH 6/6 net: mvpp2: convert FDT access to ofnode API

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Convert mvpp2 driver from legacy fdtdec/fdt_* APIs to the ofnode-based interfaces.

Replace usage of dev_of_offset(), fdtdec_lookup_phandle(), fdtdec_get_int(), fdt_parent_offset(), and related helpers with their ofnode equivalents, including dev_ofnode(), ofnode_parse_phandle(), ofnode_read_s32_default(), ofnode_get_parent(), and ofnode_for_each_subnode().

Remove direct dependencies on gd->fdt_blob.

Main changes:
- Use ofnode_valid() instead of integer checks for node presence
- Switch fixed-link detection to ofnode_find_subnode()
- Replace uclass_get_device_by_of_offset() with uclass_get_device_by_ofnode()
- Update subnode iteration and device binding to use ofnode

No functional changes.

---
 drivers/net/mvpp2.c | 54 ++++++++++++++++++++++++++---------------------------
 1 file changed, 27 insertions(+), 27 deletions(-)
drivers/net/mvpp2.c +27 -27
index 193f82ea07d..27f785163ba 100644
@@ -4731,33 +4731,34 @@ static int mvpp2_port_init(struct udevice *dev, struct mvpp2_port *port)
 
 static int phy_info_parse(struct udevice *dev, struct mvpp2_port *port)
 {
-	int port_node = dev_of_offset(dev);
-	int phy_node;
+	ofnode port_node = dev_ofnode(dev);
+	ofnode phy_node;
 	u32 id;
 	int phyaddr = 0;
-	int fixed_link = 0;
+	ofnode fixed_link;
 	int ret;
 
-	phy_node = fdtdec_lookup_phandle(gd->fdt_blob, port_node, "phy");
-	fixed_link = fdt_subnode_offset(gd->fdt_blob, port_node, "fixed-link");
+	phy_node = ofnode_parse_phandle(port_node, "phy", 0);
+	fixed_link = ofnode_find_subnode(port_node, "fixed-link");
 
-	if (phy_node > 0) {
-		int parent;
+	if (ofnode_valid(phy_node)) {
+		ofnode parent;
 
-		if (fixed_link != -FDT_ERR_NOTFOUND) {
+		if (ofnode_valid(fixed_link)) {
 			/* phy_addr is set to invalid value for fixed links */
 			phyaddr = PHY_MAX_ADDR;
 		} else {
-			phyaddr = fdtdec_get_int(gd->fdt_blob, phy_node,
-						 "reg", 0);
+			phyaddr = ofnode_read_s32_default(phy_node, "reg", 0);
 			if (phyaddr < 0) {
 				dev_err(dev, "could not find phy address\n");
 				return -1;
 			}
 		}
-		parent = fdt_parent_offset(gd->fdt_blob, phy_node);
-		ret = uclass_get_device_by_of_offset(UCLASS_MDIO, parent,
-						     &port->mdio_dev);
+		parent = ofnode_get_parent(phy_node);
+		if (!ofnode_valid(parent))
+			return -ENODEV;
+		ret = uclass_get_device_by_ofnode(UCLASS_MDIO, parent,
+						  &port->mdio_dev);
 		if (ret)
 			return ret;
 	} else {
@@ -4771,7 +4772,7 @@ static int phy_info_parse(struct udevice *dev, struct mvpp2_port *port)
 		return -EINVAL;
 	}
 
-	id = fdtdec_get_int(gd->fdt_blob, port_node, "port-id", -1);
+	id = dev_read_s32_default(dev, "port-id", -1);
 	if (id == -1) {
 		dev_err(dev, "missing port-id value\n");
 		return -EINVAL;
@@ -4812,7 +4813,7 @@ static void mvpp2_gpio_init(struct mvpp2_port *port)
 /* Ports initialization */
 static int mvpp2_port_probe(struct udevice *dev,
 			    struct mvpp2_port *port,
-			    int port_node,
+			    ofnode port_node,
 			    struct mvpp2 *priv)
 {
 	int err;
@@ -5350,8 +5351,7 @@ static int mvpp2_probe(struct udevice *dev)
 		if (!port->base)
 			return -EINVAL;
 	} else {
-		port->gop_id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
-					      "gop-port-id", -1);
+		port->gop_id = ofnode_read_s32_default(dev_ofnode(dev), "gop-port-id", -1);
 		if (port->gop_id == -1) {
 			dev_err(dev, "missing gop-port-id value\n");
 			return -EINVAL;
@@ -5375,7 +5375,7 @@ static int mvpp2_probe(struct udevice *dev)
 		priv->probe_done = 1;
 	}
 
-	err = mvpp2_port_probe(dev, port, dev_of_offset(dev), priv);
+	err = mvpp2_port_probe(dev, port, dev_ofnode(dev), priv);
 	if (err)
 		return err;
 
@@ -5436,15 +5436,14 @@ static struct driver mvpp2_driver = {
  */
 static int mvpp2_base_bind(struct udevice *parent)
 {
-	const void *blob = gd->fdt_blob;
-	int node = dev_of_offset(parent);
+	ofnode node = dev_ofnode(parent);
 	struct uclass_driver *drv;
 	struct udevice *dev;
 	struct eth_pdata *plat;
 	char *name;
-	int subnode;
+	ofnode subnode;
 	u32 id;
-	int base_id_add;
+	int base_id_add, ret;
 
 	/* Lookup eth driver */
 	drv = lists_uclass_lookup(UCLASS_ETH);
@@ -5455,19 +5454,19 @@ static int mvpp2_base_bind(struct udevice *parent)
 
 	base_id_add = base_id;
 
-	fdt_for_each_subnode(subnode, blob, node) {
+	dev_for_each_subnode(subnode, parent) {
 		/* Increment base_id for all subnodes, also the disabled ones */
 		base_id++;
 
 		/* Skip disabled ports */
-		if (!fdtdec_get_is_enabled(blob, subnode))
+		if (!ofnode_is_enabled(subnode))
 			continue;
 
 		plat = calloc(1, sizeof(*plat));
 		if (!plat)
 			return -ENOMEM;
 
-		id = fdtdec_get_int(blob, subnode, "port-id", -1);
+		id = ofnode_read_s32_default(subnode, "port-id", -1);
 		id += base_id_add;
 
 		name = calloc(1, 16);
@@ -5478,8 +5477,9 @@ static int mvpp2_base_bind(struct udevice *parent)
 		sprintf(name, "mvpp2-%d", id);
 
 		/* Create child device UCLASS_ETH and bind it */
-		device_bind(parent, &mvpp2_driver, name, plat,
-			    offset_to_ofnode(subnode), &dev);
+		ret = device_bind(parent, &mvpp2_driver, name, plat, subnode, &dev);
+		if (ret)
+			return ret;
 	}
 
 	return 0;
Signature · 1 line
2.51.0
Reviewed-by on v1 6/6
#12 lore raw

Re: [PATCH 6/6] net: mvpp2: convert FDT access to ofnode API

Hi Peng,

Quoted 20 lines · Peng Fan (OSS)

net: mvpp2: convert FDT access to ofnode API

Convert mvpp2 driver from legacy fdtdec/fdt_* APIs to the ofnode-based interfaces.

Replace usage of dev_of_offset(), fdtdec_lookup_phandle(), fdtdec_get_int(), fdt_parent_offset(), and related helpers with their ofnode equivalents, including dev_ofnode(), ofnode_parse_phandle(), ofnode_read_s32_default(), ofnode_get_parent(), and ofnode_for_each_subnode().

Remove direct dependencies on gd->fdt_blob.

Main changes:
- Use ofnode_valid() instead of integer checks for node presence
- Switch fixed-link detection to ofnode_find_subnode()
- Replace uclass_get_device_by_of_offset() with uclass_get_device_by_ofnode()
- Update subnode iteration and device binding to use ofnode

Quoted 4 lines

[...]

drivers/net/mvpp2.c | 54 ++++++++++++++++++++++++++---------------------------

 1 file changed, 27 insertions(+), 27 deletions(-)

drivers/net/mvpp2.c static struct driver mvpp2_driver = { · line 5439

Quoted 8 lines
drivers/net/mvpp2.c +1 -2
@@ -5436,15 +5436,14 @@ static struct driver mvpp2_driver = {
  */
 static int mvpp2_base_bind(struct udevice *parent)
 {
-     const void *blob = gd->fdt_blob;
-     int node = dev_of_offset(parent);
+     ofnode node = dev_ofnode(parent);

'node' is now no longer used by the look of it. Do you see a warning?

drivers/net/mvpp2.c static int mvpp2_base_bind(struct udevice *parent) · line 5482

Quoted 10 lines
drivers/net/mvpp2.c +3 -2
@@ -5478,8 +5477,9 @@ static int mvpp2_base_bind(struct udevice *parent)
              sprintf(name, 'mvpp2-%d', id);
 
              /* Create child device UCLASS_ETH and bind it */
-             device_bind(parent, &mvpp2_driver, name, plat,
-                         offset_to_ofnode(subnode), &dev);
+             ret = device_bind(parent, &mvpp2_driver, name, plat, subnode, &dev);
+             if (ret)
+                     return ret;

This is a behavioural change - the old code ignored bind failures and continued, the new code aborts and leaks the already-allocated plat and name. Probably the right thing, but please mention it in the commit message (the "No functional changes" claim is not quite accurate) and free plat/name on the error path.

drivers/net/mvpp2.c static int mvpp2_port_init(struct udevice *dev, struct mvpp2_port *port) · line 4733

Quoted 8 lines
drivers/net/mvpp2.c +3 -3
@@ -4731,33 +4731,34 @@ static int mvpp2_port_init(struct udevice *dev, struct mvpp2_port *port)
-             parent = fdt_parent_offset(gd->fdt_blob, phy_node);
-             ret = uclass_get_device_by_of_offset(UCLASS_MDIO, parent,
-                                                  &port->mdio_dev);
+             parent = ofnode_get_parent(phy_node);
+             if (!ofnode_valid(parent))
+                     return -ENODEV;

We should be careful returning -ENODEV as it has a special meaning with DM. This is a small behavioural change versus the old code, which passed a negative offset straight through. Worth noting in the commit message, or drop the check since the call below will return an error anyway.

Regards,
Simon

#13 lore raw

RE: [PATCH 6/6] net: mvpp2: convert FDT access to ofnode API

Hi Simon,

Thanks for giving a look.

Quoted 35 lines

Subject: Re: [PATCH 6/6] net: mvpp2: convert FDT access to ofnode API

Hi Peng,

Quoted 3 lines · Peng Fan (OSS)

net: mvpp2: convert FDT access to ofnode API

Convert mvpp2 driver from legacy fdtdec/fdt_* APIs to the ofnode-

based

Quoted 17 lines

interfaces.

Replace usage of dev_of_offset(), fdtdec_lookup_phandle(), fdtdec_get_int(), fdt_parent_offset(), and related helpers with their ofnode equivalents, including dev_ofnode(), ofnode_parse_phandle(), ofnode_read_s32_default(), ofnode_get_parent(), and ofnode_for_each_subnode().

Remove direct dependencies on gd->fdt_blob.

Main changes:
- Use ofnode_valid() instead of integer checks for node presence
- Switch fixed-link detection to ofnode_find_subnode()
- Replace uclass_get_device_by_of_offset() with uclass_get_device_by_ofnode()
- Update subnode iteration and device binding to use ofnode

Quoted 5 lines

[...]

drivers/net/mvpp2.c | 54
++++++++++++++++++++++++++---------------------------

 1 file changed, 27 insertions(+), 27 deletions(-)
Quoted 9 lines

drivers/net/mvpp2.c @@ -5436,15

Quoted 7 lines
drivers/net/mvpp2.c @@ -5436,15 renamed from drivers/net/mvpp2.c +2 -2
+5436,14 @@ static struct driver mvpp2_driver = {
  */
 static int mvpp2_base_bind(struct udevice *parent)  {
-     const void *blob = gd->fdt_blob;
-     int node = dev_of_offset(parent);
+     ofnode node = dev_ofnode(parent);

'node' is now no longer used by the look of it. Do you see a warning?

I use "./tools/buildman/buildman x250 ", I may miss something. indeed no user, I will remove it.

Quoted 11 lines

drivers/net/mvpp2.c static int mvpp2_base_bind(struct udevice

Quoted 3 lines
drivers/net/mvpp2.c +0 -0
@@ -5478,8 +5477,9 @@ static int mvpp2_base_bind(struct udevice

*parent)

drivers/net/mvpp2.c static int mvpp2_base_bind(struct udevice *parent)

Quoted 6 lines
drivers/net/mvpp2.c +1 -2
              sprintf(name, 'mvpp2-%d', id);
 
              /* Create child device UCLASS_ETH and bind it */
-             device_bind(parent, &mvpp2_driver, name, plat,
-                         offset_to_ofnode(subnode), &dev);
+             ret = device_bind(parent, &mvpp2_driver, name, plat,

subnode, &dev);

Quoted 8 lines

drivers/net/mvpp2.c static int mvpp2_base_bind(struct udevice *parent) · line 5482

Quoted 2 lines
drivers/net/mvpp2.c +2 -0
+             if (ret)
+                     return ret;

This is a behavioural change - the old code ignored bind failures and continued, the new code aborts and leaks the already-allocated plat and name. Probably the right thing, but please mention it in the commit message (the "No functional changes" claim is not quite accurate) and free plat/name on the error path.

Will update commit message in v2.

Quoted 11 lines

drivers/net/mvpp2.c static int mvpp2_port_init(struct

Quoted 3 lines
drivers/net/mvpp2.c +0 -0
@@ -4731,33 +4731,34 @@ static int mvpp2_port_init(struct

udevice *dev, struct mvpp2_port *port)

drivers/net/mvpp2.c static int mvpp2_port_init(struct udevice *dev, struct mvpp2_port *port) · line 4759

Quoted 6 lines
drivers/net/mvpp2.c +3 -3
-             parent = fdt_parent_offset(gd->fdt_blob, phy_node);
-             ret = uclass_get_device_by_of_offset(UCLASS_MDIO, parent,
-                                                  &port->mdio_dev);
+             parent = ofnode_get_parent(phy_node);
+             if (!ofnode_valid(parent))
+                     return -ENODEV;
Quoted 4 lines

We should be careful returning -ENODEV as it has a special meaning with DM. This is a small behavioural change versus the old code, which passed a negative offset straight through. Worth noting in the commit message, or drop the check since the call below will return an error

I will drop the check in v2.

Thanks,
Peng.

Quoted 4 lines

anyway.

Regards,
Simon

#14 lore raw

Re: [PATCH 6/6] net: mvpp2: convert FDT access to ofnode API

Quoted 49 lines · Peng Fan (OSS)

Hi Simon,

Thanks for giving a look.

Quoted 35 lines

Subject: Re: [PATCH 6/6] net: mvpp2: convert FDT access to ofnode API

Hi Peng,

Quoted 3 lines · Peng Fan (OSS)

net: mvpp2: convert FDT access to ofnode API

Convert mvpp2 driver from legacy fdtdec/fdt_* APIs to the ofnode-

based

Quoted 17 lines

interfaces.

Replace usage of dev_of_offset(), fdtdec_lookup_phandle(), fdtdec_get_int(), fdt_parent_offset(), and related helpers with their ofnode equivalents, including dev_ofnode(), ofnode_parse_phandle(), ofnode_read_s32_default(), ofnode_get_parent(), and ofnode_for_each_subnode().

Remove direct dependencies on gd->fdt_blob.

Main changes:
- Use ofnode_valid() instead of integer checks for node presence
- Switch fixed-link detection to ofnode_find_subnode()
- Replace uclass_get_device_by_of_offset() with uclass_get_device_by_ofnode()
- Update subnode iteration and device binding to use ofnode

Quoted 5 lines

[...]

drivers/net/mvpp2.c | 54
++++++++++++++++++++++++++---------------------------

 1 file changed, 27 insertions(+), 27 deletions(-)
Quoted 9 lines

drivers/net/mvpp2.c @@ -5436,15

Quoted 7 lines
drivers/net/mvpp2.c @@ -5436,15 renamed from drivers/net/mvpp2.c +2 -2
+5436,14 @@ static struct driver mvpp2_driver = {
  */
 static int mvpp2_base_bind(struct udevice *parent)  {
-     const void *blob = gd->fdt_blob;
-     int node = dev_of_offset(parent);
+     ofnode node = dev_ofnode(parent);

'node' is now no longer used by the look of it. Do you see a warning?

Quoted 2 lines

I use "./tools/buildman/buildman x250 ", I may miss something. indeed no user, I will remove it.

You have to use buildman -E to make warnings be errors. Or, *cough*, we enable WERROR by default, as has been suggested.

Signature · 1 line
Tom