summaryrefslogtreecommitdiffstats
path: root/drivers/phy/phy-core.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2015-04-07 12:23:38 +0800
committerKishon Vijay Abraham I <kishon@ti.com>2015-05-11 21:42:27 +0530
commit33f434d283a27116fb358ae5bc3b42967c12f85a (patch)
treed713eba563c8f01adc146e1e02ac872d0efa1ffb /drivers/phy/phy-core.c
parent5bea496820cdcb0f6711741ba663ccfe78ac4dbf (diff)
downloadlinux-stable-33f434d283a27116fb358ae5bc3b42967c12f85a.tar.gz
linux-stable-33f434d283a27116fb358ae5bc3b42967c12f85a.tar.bz2
linux-stable-33f434d283a27116fb358ae5bc3b42967c12f85a.zip
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>
Diffstat (limited to 'drivers/phy/phy-core.c')
-rw-r--r--drivers/phy/phy-core.c12
1 files changed, 10 insertions, 2 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)
phy_provider = of_phy_provider_lookup(args.np);
if (IS_ERR(phy_provider) || !try_module_get(phy_provider->owner)) {
phy = ERR_PTR(-EPROBE_DEFER);
- goto err0;
+ goto out_unlock;
+ }
+
+ if (!of_device_is_available(args.np)) {
+ dev_warn(phy_provider->dev, "Requested PHY is disabled\n");
+ phy = ERR_PTR(-ENODEV);
+ goto out_put_module;
}
phy = phy_provider->of_xlate(phy_provider->dev, &args);
+
+out_put_module:
module_put(phy_provider->owner);
-err0:
+out_unlock:
mutex_unlock(&phy_provider_mutex);
of_node_put(args.np);