aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2015-04-07 00:23:38 -0400
committerKishon Vijay Abraham I <kishon@ti.com>2015-05-11 12:12:27 -0400
commit33f434d283a27116fb358ae5bc3b42967c12f85a (patch)
treed713eba563c8f01adc146e1e02ac872d0efa1ffb
parent5bea496820cdcb0f6711741ba663ccfe78ac4dbf (diff)
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(). Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
-rw-r--r--drivers/phy/phy-core.c12
-rw-r--r--drivers/phy/phy-miphy28lp.c5
-rw-r--r--drivers/phy/phy-miphy365x.c5
-rw-r--r--drivers/phy/phy-rcar-gen2.c5
4 files changed, 10 insertions, 17 deletions
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 5f729bb0788f..7d535dbb63ee 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -367,13 +367,21 @@ static struct phy *_of_phy_get(struct device_node *np, int index)
367 phy_provider = of_phy_provider_lookup(args.np); 367 phy_provider = of_phy_provider_lookup(args.np);
368 if (IS_ERR(phy_provider) || !try_module_get(phy_provider->owner)) { 368 if (IS_ERR(phy_provider) || !try_module_get(phy_provider->owner)) {
369 phy = ERR_PTR(-EPROBE_DEFER); 369 phy = ERR_PTR(-EPROBE_DEFER);
370 goto err0; 370 goto out_unlock;
371 }
372
373 if (!of_device_is_available(args.np)) {
374 dev_warn(phy_provider->dev, "Requested PHY is disabled\n");
375 phy = ERR_PTR(-ENODEV);
376 goto out_put_module;
371 } 377 }
372 378
373 phy = phy_provider->of_xlate(phy_provider->dev, &args); 379 phy = phy_provider->of_xlate(phy_provider->dev, &args);
380
381out_put_module:
374 module_put(phy_provider->owner); 382 module_put(phy_provider->owner);
375 383
376err0: 384out_unlock:
377 mutex_unlock(&phy_provider_mutex); 385 mutex_unlock(&phy_provider_mutex);
378 of_node_put(args.np); 386 of_node_put(args.np);
379 387
diff --git a/drivers/phy/phy-miphy28lp.c b/drivers/phy/phy-miphy28lp.c
index 58d5339ff448..5e257ef7ac05 100644
--- a/drivers/phy/phy-miphy28lp.c
+++ b/drivers/phy/phy-miphy28lp.c
@@ -1107,11 +1107,6 @@ static struct phy *miphy28lp_xlate(struct device *dev,
1107 struct device_node *phynode = args->np; 1107 struct device_node *phynode = args->np;
1108 int ret, index = 0; 1108 int ret, index = 0;
1109 1109
1110 if (!of_device_is_available(phynode)) {
1111 dev_warn(dev, "Requested PHY is disabled\n");
1112 return ERR_PTR(-ENODEV);
1113 }
1114
1115 if (args->args_count != 1) { 1110 if (args->args_count != 1) {
1116 dev_err(dev, "Invalid number of cells in 'phy' property\n"); 1111 dev_err(dev, "Invalid number of cells in 'phy' property\n");
1117 return ERR_PTR(-EINVAL); 1112 return ERR_PTR(-EINVAL);
diff --git a/drivers/phy/phy-miphy365x.c b/drivers/phy/phy-miphy365x.c
index ba6993da91fe..0ff354d6e183 100644
--- a/drivers/phy/phy-miphy365x.c
+++ b/drivers/phy/phy-miphy365x.c
@@ -476,11 +476,6 @@ static struct phy *miphy365x_xlate(struct device *dev,
476 struct device_node *phynode = args->np; 476 struct device_node *phynode = args->np;
477 int ret, index; 477 int ret, index;
478 478
479 if (!of_device_is_available(phynode)) {
480 dev_warn(dev, "Requested PHY is disabled\n");
481 return ERR_PTR(-ENODEV);
482 }
483
484 if (args->args_count != 1) { 479 if (args->args_count != 1) {
485 dev_err(dev, "Invalid number of cells in 'phy' property\n"); 480 dev_err(dev, "Invalid number of cells in 'phy' property\n");
486 return ERR_PTR(-EINVAL); 481 return ERR_PTR(-EINVAL);
diff --git a/drivers/phy/phy-rcar-gen2.c b/drivers/phy/phy-rcar-gen2.c
index 778276aba3aa..f47bfd8a5368 100644
--- a/drivers/phy/phy-rcar-gen2.c
+++ b/drivers/phy/phy-rcar-gen2.c
@@ -206,11 +206,6 @@ static struct phy *rcar_gen2_phy_xlate(struct device *dev,
206 struct device_node *np = args->np; 206 struct device_node *np = args->np;
207 int i; 207 int i;
208 208
209 if (!of_device_is_available(np)) {
210 dev_warn(dev, "Requested PHY is disabled\n");
211 return ERR_PTR(-ENODEV);
212 }
213
214 drv = dev_get_drvdata(dev); 209 drv = dev_get_drvdata(dev);
215 if (!drv) 210 if (!drv)
216 return ERR_PTR(-EINVAL); 211 return ERR_PTR(-EINVAL);