Skip to contentSkip to conversation

phy: core: Check requested PHY status in _of_phy_get()

PATCH Superseded Axel Lin 1 participant 1 message Apr 7, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 phy: core: Check requested PHY status in _of_phy_get()

This is a common checking in various drivers, so move the checking to _of_phy_get().

---
 drivers/phy/phy-core.c      | 6 ++++++
 drivers/phy/phy-miphy28lp.c | 5 -----
 drivers/phy/phy-miphy365x.c | 5 -----
 drivers/phy/phy-rcar-gen2.c | 5 -----
 4 files changed, 6 insertions(+), 15 deletions(-)
drivers/phy/phy-core.c +6 -0
index 3791838f..6350c26 100644
@@ -370,6 +370,12 @@ static struct phy *_of_phy_get(struct device_node *np, int index)
 		goto err0;
 	}
 
+	if (!of_device_is_available(args.np)) {
+		dev_warn(phy_provider->dev, "Requested PHY is disabled\n");
+		phy = ERR_PTR(-ENODEV);
+		goto err0;
+	}
+
 	phy = phy_provider->of_xlate(phy_provider->dev, &args);
 	module_put(phy_provider->owner);
 
drivers/phy/phy-miphy28lp.c +0 -5
index 9334352..cc87b3f 100644
@@ -1107,11 +1107,6 @@ static struct phy *miphy28lp_xlate(struct device *dev,
 	struct device_node *phynode = args->np;
 	int ret, index = 0;
 
-	if (!of_device_is_available(phynode)) {
-		dev_warn(dev, "Requested PHY is disabled\n");
-		return ERR_PTR(-ENODEV);
-	}
-
 	if (args->args_count != 1) {
 		dev_err(dev, "Invalid number of cells in 'phy' property\n");
 		return ERR_PTR(-EINVAL);
drivers/phy/phy-miphy365x.c +0 -5
index 51b459d..d29b332 100644
@@ -476,11 +476,6 @@ static struct phy *miphy365x_xlate(struct device *dev,
 	struct device_node *phynode = args->np;
 	int ret, index;
 
-	if (!of_device_is_available(phynode)) {
-		dev_warn(dev, "Requested PHY is disabled\n");
-		return ERR_PTR(-ENODEV);
-	}
-
 	if (args->args_count != 1) {
 		dev_err(dev, "Invalid number of cells in 'phy' property\n");
 		return ERR_PTR(-EINVAL);
drivers/phy/phy-rcar-gen2.c +0 -5
index 778276a..f47bfd8 100644
@@ -206,11 +206,6 @@ static struct phy *rcar_gen2_phy_xlate(struct device *dev,
 	struct device_node *np = args->np;
 	int i;
 
-	if (!of_device_is_available(np)) {
-		dev_warn(dev, "Requested PHY is disabled\n");
-		return ERR_PTR(-ENODEV);
-	}
-
 	drv = dev_get_drvdata(dev);
 	if (!drv)
 		return ERR_PTR(-EINVAL);
Signature · 1 line
1.9.1