Skip to contentSkip to conversation

of_mdio: use IS_ERR_OR_NULL() and PTR_ERR_OR_ZERO()

PATCH Superseded Sergei Shtylyov 4 participants 8 messages Mar 11, 2016 1 message not in the archive

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover of_mdio: use IS_ERR_OR_NULL() and PTR_ERR_OR_ZERO()

Hello.

Here's the set of 2 patches against DaveM's 'net-next.git' repo. They
replace the patch posted earlier today which was clearly insufficient...

[1/2] of_mdio: use IS_ERR_OR_NULL()
[2/2] of_mdio: use PTR_ERR_OR_ZERO()

MBR, Sergei

#1 lore raw

PATCH 1/2 of_mdio: use IS_ERR_OR_NULL()

IS_ERR_OR_NULL() is open coded in of_mdiobus_register_{phy|device}(), so just call it directly...

---
 drivers/of/of_mdio.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/of/of_mdio.c +2 -2
Index: net-next/drivers/of/of_mdio.c
===================================================================
@@ -56,7 +56,7 @@ static int of_mdiobus_register_phy(struc
 		phy = phy_device_create(mdio, addr, phy_id, 0, NULL);
 	else
 		phy = get_phy_device(mdio, addr, is_c45);
-	if (!phy || IS_ERR(phy))
+	if (IS_ERR_OR_NULL(phy))
 		return 1;
 
 	rc = irq_of_parse_and_map(child, 0);
@@ -98,7 +98,7 @@ static int of_mdiobus_register_device(st
 	int rc;
 
 	mdiodev = mdio_device_create(mdio, addr);
-	if (!mdiodev || IS_ERR(mdiodev))
+	if (IS_ERR_OR_NULL(mdiodev))
 		return 1;
 
 	/* Associate the OF node with the device structure so it

A message that is not in the archive (sent off-list or not yet received): 3305414.rAFdOb57tB-gHKXc3Y1Z8zGSmamagVegGFoWSdPRAKMAL8bYrjMMd8@public.gmane.org

#4 lore raw

Re: [PATCH 1/2] of_mdio: use IS_ERR_OR_NULL()

Hello Sergei,

Quoted 23 lines · Sergei Shtylyov

IS_ERR_OR_NULL() is open coded in of_mdiobus_register_{phy|device}(), so just call it directly...

---
 drivers/of/of_mdio.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: net-next/drivers/of/of_mdio.c
===================================================================

drivers/of/of_mdio.c +1 -1
@@ -56,7 +56,7 @@ static int of_mdiobus_register_phy(struc
 		phy = phy_device_create(mdio, addr, phy_id, 0, NULL);
 	else
 		phy = get_phy_device(mdio, addr, is_c45);
-	if (!phy || IS_ERR(phy))
+	if (IS_ERR_OR_NULL(phy))
 		return 1;
 
 	rc = irq_of_parse_and_map(child, 0);

drivers/of/of_mdio.c static int of_mdiobus_register_device(st · line 103

Quoted 7 lines
drivers/of/of_mdio.c +1 -1
@@ -98,7 +98,7 @@ static int of_mdiobus_register_device(st
 	int rc;
 
 	mdiodev = mdio_device_create(mdio, addr);
-	if (!mdiodev || IS_ERR(mdiodev))
+	if (IS_ERR_OR_NULL(mdiodev))
 		return 1;
 

I don't see how it is possible for mdio_device_create() to return NULL, instead of this change consider to remove if (!mdiodev) check.

drivers/of/of_mdio.c static int of_mdiobus_register_device(st · line 104

Quoted 2 lines
drivers/of/of_mdio.c +0 -0
 	/* Associate the OF node with the device structure so it

--
With best wishes,
Vladimir
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

Re: [PATCH 1/2] of_mdio: use IS_ERR_OR_NULL()

Quoted 28 lines · Vladimir Zapolskiy

Hello Sergei,

Quoted 25 lines · Sergei Shtylyov

IS_ERR_OR_NULL() is open coded in of_mdiobus_register_{phy|device}(), so just call it directly...

---
 drivers/of/of_mdio.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: net-next/drivers/of/of_mdio.c
===================================================================

drivers/of/of_mdio.c +1 -1
@@ -56,7 +56,7 @@ static int of_mdiobus_register_phy(struc
 		phy = phy_device_create(mdio, addr, phy_id, 0, NULL);
 	else
 		phy = get_phy_device(mdio, addr, is_c45);
-	if (!phy || IS_ERR(phy))
+	if (IS_ERR_OR_NULL(phy))
 		return 1;
 
 	rc = irq_of_parse_and_map(child, 0);
@@ -98,7 +98,7 @@ static int of_mdiobus_register_device(st
 	int rc;
 
Quoted 8 lines

drivers/of/of_mdio.c static int of_mdiobus_register_device(st · line 103

Quoted 5 lines
drivers/of/of_mdio.c +1 -1
 	mdiodev = mdio_device_create(mdio, addr);
-	if (!mdiodev || IS_ERR(mdiodev))
+	if (IS_ERR_OR_NULL(mdiodev))
 		return 1;
 

I don't see how it is possible for mdio_device_create() to return NULL, instead of this change consider to remove if (!mdiodev) check.

Good point, worst case we return PTR_ERR(-ENOMEM).

Signature · 1 line
Florian
#6 lore raw

PATCH 2/2 of_mdio: use PTR_ERR_OR_ZERO()

In reply to Sergei Shtylyov

PTR_ERR_OR_ZERO() is open coded in of_phy_register_fixed_link(), so just call it directly...

---
 drivers/of/of_mdio.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/of/of_mdio.c +3 -3
Index: net-next/drivers/of/of_mdio.c
===================================================================
@@ -412,7 +412,7 @@ int of_phy_register_fixed_link(struct de
 		if (strcmp(managed, "in-band-status") == 0) {
 			/* status is zeroed, namely its .link member */
 			phy = fixed_phy_register(PHY_POLL, &status, -1, np);
-			return IS_ERR(phy) ? PTR_ERR(phy) : 0;
+			return PTR_ERR_OR_ZERO(phy);
 		}
 	}
 
@@ -434,7 +434,7 @@ int of_phy_register_fixed_link(struct de
 			return -EPROBE_DEFER;
 
 		phy = fixed_phy_register(PHY_POLL, &status, link_gpio, np);
-		return IS_ERR(phy) ? PTR_ERR(phy) : 0;
+		return PTR_ERR_OR_ZERO(phy);
 	}
 
 	/* Old binding */
@@ -446,7 +446,7 @@ int of_phy_register_fixed_link(struct de
 		status.pause = be32_to_cpu(fixed_link_prop[3]);
 		status.asym_pause = be32_to_cpu(fixed_link_prop[4]);
 		phy = fixed_phy_register(PHY_POLL, &status, -1, np);
-		return IS_ERR(phy) ? PTR_ERR(phy) : 0;
+		return PTR_ERR_OR_ZERO(phy);
 	}
 
 	return -ENODEV;
Reviewed-by on v1 2/2
#8 lore raw

Re: [PATCH 2/2] of_mdio: use PTR_ERR_OR_ZERO()

In reply to Sergei Shtylyov

Hello Sergei,

Quoted 33 lines · Sergei Shtylyov

PTR_ERR_OR_ZERO() is open coded in of_phy_register_fixed_link(), so just call it directly...

---
 drivers/of/of_mdio.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: net-next/drivers/of/of_mdio.c
===================================================================

drivers/of/of_mdio.c +2 -2
@@ -412,7 +412,7 @@ int of_phy_register_fixed_link(struct de
 		if (strcmp(managed, "in-band-status") == 0) {
 			/* status is zeroed, namely its .link member */
 			phy = fixed_phy_register(PHY_POLL, &status, -1, np);
-			return IS_ERR(phy) ? PTR_ERR(phy) : 0;
+			return PTR_ERR_OR_ZERO(phy);
 		}
 	}
 
@@ -434,7 +434,7 @@ int of_phy_register_fixed_link(struct de
 			return -EPROBE_DEFER;
 
 		phy = fixed_phy_register(PHY_POLL, &status, link_gpio, np);
-		return IS_ERR(phy) ? PTR_ERR(phy) : 0;
+		return PTR_ERR_OR_ZERO(phy);
 	}
 
 	/* Old binding */

drivers/of/of_mdio.c int of_phy_register_fixed_link(struct de · line 452

Quoted 8 lines
drivers/of/of_mdio.c +1 -1
@@ -446,7 +446,7 @@ int of_phy_register_fixed_link(struct de
 		status.pause = be32_to_cpu(fixed_link_prop[3]);
 		status.asym_pause = be32_to_cpu(fixed_link_prop[4]);
 		phy = fixed_phy_register(PHY_POLL, &status, -1, np);
-		return IS_ERR(phy) ? PTR_ERR(phy) : 0;
+		return PTR_ERR_OR_ZERO(phy);
 	}
 
 	return -ENODEV;