diff mbox series

[1/5] PCI: exynos: Properly handle optional PHYs

Message ID 20190828163636.12967-1-thierry.reding@gmail.com (mailing list archive)
State Mainlined, archived
Commit ddd6960087d4b45759434146d681a94bbb1c54ad
Headers show
Series [1/5] PCI: exynos: Properly handle optional PHYs | expand

Commit Message

Thierry Reding Aug. 28, 2019, 4:36 p.m. UTC
From: Thierry Reding <treding@nvidia.com>

devm_of_phy_get() can fail for a number of resides besides probe
deferral. It can for example return -ENOMEM if it runs out of memory as
it tries to allocate devres structures. Propagating only -EPROBE_DEFER
is problematic because it results in these legitimately fatal errors
being treated as "PHY not specified in DT".

What we really want is to ignore the optional PHYs only if they have not
been specified in DT. devm_of_phy_get() returns -ENODEV in this case, so
that's the special case that we need to handle. So we propagate all
errors, except -ENODEV, so that real failures will still cause the
driver to fail probe.

Cc: Jingoo Han <jingoohan1@gmail.com>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/pci/controller/dwc/pci-exynos.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bjorn Helgaas Aug. 28, 2019, 5:54 p.m. UTC | #1
This could use a [0/n] cover letter to hold this together as a series.

In my mind, "Properly" adds nothing (why would we merge something done
"improperly"?) and takes space that could be better used for more
specific details.

On Wed, Aug 28, 2019 at 06:36:32PM +0200, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> devm_of_phy_get() can fail for a number of resides besides probe
> deferral. It can for example return -ENOMEM if it runs out of memory as
> it tries to allocate devres structures. Propagating only -EPROBE_DEFER
> is problematic because it results in these legitimately fatal errors
> being treated as "PHY not specified in DT".

s/resides/reasons/?  (Also in other patches, I think)

> What we really want is to ignore the optional PHYs only if they have not
> been specified in DT. devm_of_phy_get() returns -ENODEV in this case, so
> that's the special case that we need to handle. So we propagate all
> errors, except -ENODEV, so that real failures will still cause the
> driver to fail probe.
> 
> Cc: Jingoo Han <jingoohan1@gmail.com>
> Cc: Kukjin Kim <kgene@kernel.org>
> Cc: Krzysztof Kozlowski <krzk@kernel.org>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  drivers/pci/controller/dwc/pci-exynos.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/dwc/pci-exynos.c b/drivers/pci/controller/dwc/pci-exynos.c
> index cee5f2f590e2..14a6ba4067fb 100644
> --- a/drivers/pci/controller/dwc/pci-exynos.c
> +++ b/drivers/pci/controller/dwc/pci-exynos.c
> @@ -465,7 +465,7 @@ static int __init exynos_pcie_probe(struct platform_device *pdev)
>  
>  	ep->phy = devm_of_phy_get(dev, np, NULL);
>  	if (IS_ERR(ep->phy)) {
> -		if (PTR_ERR(ep->phy) == -EPROBE_DEFER)
> +		if (PTR_ERR(ep->phy) != -ENODEV)
>  			return PTR_ERR(ep->phy);
>  
>  		ep->phy = NULL;
> -- 
> 2.22.0
>
Andrew Murray Aug. 28, 2019, 9:08 p.m. UTC | #2
On Wed, Aug 28, 2019 at 06:36:32PM +0200, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> devm_of_phy_get() can fail for a number of resides besides probe
> deferral. It can for example return -ENOMEM if it runs out of memory as
> it tries to allocate devres structures. Propagating only -EPROBE_DEFER
> is problematic because it results in these legitimately fatal errors
> being treated as "PHY not specified in DT".
> 
> What we really want is to ignore the optional PHYs only if they have not
> been specified in DT. devm_of_phy_get() returns -ENODEV in this case, so
> that's the special case that we need to handle. So we propagate all
> errors, except -ENODEV, so that real failures will still cause the
> driver to fail probe.
> 
> Cc: Jingoo Han <jingoohan1@gmail.com>
> Cc: Kukjin Kim <kgene@kernel.org>
> Cc: Krzysztof Kozlowski <krzk@kernel.org>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  drivers/pci/controller/dwc/pci-exynos.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/dwc/pci-exynos.c b/drivers/pci/controller/dwc/pci-exynos.c
> index cee5f2f590e2..14a6ba4067fb 100644
> --- a/drivers/pci/controller/dwc/pci-exynos.c
> +++ b/drivers/pci/controller/dwc/pci-exynos.c
> @@ -465,7 +465,7 @@ static int __init exynos_pcie_probe(struct platform_device *pdev)
>  
>  	ep->phy = devm_of_phy_get(dev, np, NULL);
>  	if (IS_ERR(ep->phy)) {
> -		if (PTR_ERR(ep->phy) == -EPROBE_DEFER)
> +		if (PTR_ERR(ep->phy) != -ENODEV)
>  			return PTR_ERR(ep->phy);
>  
>  		ep->phy = NULL;

Once you've applied Bjorn's feedback you can add:

Reviewed-by: Andrew Murray <andrew.murray@arm.com>

> -- 
> 2.22.0
>
diff mbox series

Patch

diff --git a/drivers/pci/controller/dwc/pci-exynos.c b/drivers/pci/controller/dwc/pci-exynos.c
index cee5f2f590e2..14a6ba4067fb 100644
--- a/drivers/pci/controller/dwc/pci-exynos.c
+++ b/drivers/pci/controller/dwc/pci-exynos.c
@@ -465,7 +465,7 @@  static int __init exynos_pcie_probe(struct platform_device *pdev)
 
 	ep->phy = devm_of_phy_get(dev, np, NULL);
 	if (IS_ERR(ep->phy)) {
-		if (PTR_ERR(ep->phy) == -EPROBE_DEFER)
+		if (PTR_ERR(ep->phy) != -ENODEV)
 			return PTR_ERR(ep->phy);
 
 		ep->phy = NULL;