Skip to contentSkip to conversation

phy: spear1310-miphy: Return proper error for spear1310_miphy_xlate

PATCH Superseded Axel Lin 2 participants 3 messages Mar 25, 2015 – Mar 31, 2015 Generic PHY framework

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/2 phy: spear1310-miphy: Return proper error for spear1310_miphy_xlate

The of_xlate callback should return ERR_PTR on error.

---
 drivers/phy/phy-spear1310-miphy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/phy/phy-spear1310-miphy.c +2 -2
index 9f47fae..4684b04 100644
@@ -192,14 +192,14 @@ static struct phy *spear1310_miphy_xlate(struct device *dev,
 
 	if (args->args_count < 1) {
 		dev_err(dev, "DT did not pass correct no of args\n");
-		return NULL;
+		return ERR_PTR(-EINVAL);
 	}
 
 	priv->mode = args->args[0];
 
 	if (priv->mode != SATA && priv->mode != PCIE) {
 		dev_err(dev, "DT did not pass correct phy mode\n");
-		return NULL;
+		return ERR_PTR(-EINVAL);
 	}
 
 	return priv->phy;
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 2/2 phy: spear1340-miphy: Return proper error for spear1340_miphy_xlate

The of_xlate callback should return ERR_PTR on error.

---
 drivers/phy/phy-spear1340-miphy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/phy/phy-spear1340-miphy.c +2 -2
index e42bc20..210979b 100644
@@ -229,14 +229,14 @@ static struct phy *spear1340_miphy_xlate(struct device *dev,
 
 	if (args->args_count < 1) {
 		dev_err(dev, "DT did not pass correct no of args\n");
-		return NULL;
+		return ERR_PTR(-EINVAL);
 	}
 
 	priv->mode = args->args[0];
 
 	if (priv->mode != SATA && priv->mode != PCIE) {
 		dev_err(dev, "DT did not pass correct phy mode\n");
-		return NULL;
+		return ERR_PTR(-EINVAL);
 	}
 
 	return priv->phy;
Signature · 1 line
1.9.1
#2 lore raw
In reply to Axel Lin

Hi,

Quoted 12 lines · Axel Lin

The of_xlate callback should return ERR_PTR on error.

---
  drivers/phy/phy-spear1310-miphy.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/phy/phy-spear1310-miphy.c +0 -0
index 9f47fae..4684b04 100644

drivers/phy/phy-spear1310-miphy.c static struct phy *spear1310_miphy_xlate(struct device *dev, · line 195

Quoted 5 lines
drivers/phy/phy-spear1310-miphy.c +1 -1
@@ -192,14 +192,14 @@ static struct phy *spear1310_miphy_xlate(struct device *dev,
 
  	if (args->args_count < 1) {
  		dev_err(dev, "DT did not pass correct no of args\n");
-		return NULL;
+		return ERR_PTR(-EINVAL);

It should actually be -ENODEV so that phy_optional_get() doesn't fail.

drivers/phy/phy-spear1310-miphy.c static struct phy *spear1310_miphy_xlate(struct device *dev, · line 202

Quoted 8 lines
drivers/phy/phy-spear1310-miphy.c +1 -1
  	}
 
  	priv->mode = args->args[0];
 
  	if (priv->mode != SATA && priv->mode != PCIE) {
  		dev_err(dev, "DT did not pass correct phy mode\n");
-		return NULL;
+		return ERR_PTR(-EINVAL);

Same here.

Thanks
Kishon