Skip to content

Commit

Permalink
phy: core: Check requested PHY status in _of_phy_get()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Axel Lin authored and Kishon Vijay Abraham I committed May 11, 2015
1 parent 5bea496 commit 33f434d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
12 changes: 10 additions & 2 deletions drivers/phy/phy-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 0 additions & 5 deletions drivers/phy/phy-miphy28lp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 0 additions & 5 deletions drivers/phy/phy-miphy365x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 0 additions & 5 deletions drivers/phy/phy-rcar-gen2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 33f434d

Please sign in to comment.