All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] phy: core: Check requested PHY status in _of_phy_get()
@ 2015-04-07  4:23 Axel Lin
  2015-04-07  6:38 ` Lee Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2015-04-07  4:23 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Gabriel FERNANDEZ, Lee Jones, Sergei Shtylyov, linux-kernel

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>
---
v2: Fixup the error patch. It needs to call module_put if Requested PHY is
    disabled.
 drivers/phy/phy-core.c      | 12 ++++++++++--
 drivers/phy/phy-miphy28lp.c |  5 -----
 drivers/phy/phy-miphy365x.c |  5 -----
 drivers/phy/phy-rcar-gen2.c |  5 -----
 4 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 3791838f..f7403de 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);
 
diff --git a/drivers/phy/phy-miphy28lp.c b/drivers/phy/phy-miphy28lp.c
index 9334352..cc87b3f 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,
 	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);
diff --git a/drivers/phy/phy-miphy365x.c b/drivers/phy/phy-miphy365x.c
index 51b459d..d29b332 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,
 	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);
diff --git a/drivers/phy/phy-rcar-gen2.c b/drivers/phy/phy-rcar-gen2.c
index 778276a..f47bfd8 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,
 	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);
-- 
1.9.1




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] phy: core: Check requested PHY status in _of_phy_get()
  2015-04-07  4:23 [PATCH v2] phy: core: Check requested PHY status in _of_phy_get() Axel Lin
@ 2015-04-07  6:38 ` Lee Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2015-04-07  6:38 UTC (permalink / raw)
  To: Axel Lin
  Cc: Kishon Vijay Abraham I, Gabriel FERNANDEZ, Sergei Shtylyov, linux-kernel

On Tue, 07 Apr 2015, Axel Lin wrote:

> 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>
> ---
> v2: Fixup the error patch. It needs to call module_put if Requested PHY is
>     disabled.
>  drivers/phy/phy-core.c      | 12 ++++++++++--
>  drivers/phy/phy-miphy28lp.c |  5 -----
>  drivers/phy/phy-miphy365x.c |  5 -----

Acked-by: Lee Jones <lee.jones@linaro.org>

>  drivers/phy/phy-rcar-gen2.c |  5 -----
>  4 files changed, 10 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> index 3791838f..f7403de 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);
>  
> diff --git a/drivers/phy/phy-miphy28lp.c b/drivers/phy/phy-miphy28lp.c
> index 9334352..cc87b3f 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,
>  	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);
> diff --git a/drivers/phy/phy-miphy365x.c b/drivers/phy/phy-miphy365x.c
> index 51b459d..d29b332 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,
>  	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);
> diff --git a/drivers/phy/phy-rcar-gen2.c b/drivers/phy/phy-rcar-gen2.c
> index 778276a..f47bfd8 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,
>  	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);

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-04-07  6:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-07  4:23 [PATCH v2] phy: core: Check requested PHY status in _of_phy_get() Axel Lin
2015-04-07  6:38 ` Lee Jones

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.