public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND] libahci_platform: Fail when PHY required but PHY support disabled
@ 2014-06-17 12:07 Mikko Perttunen
  2014-06-17 12:33 ` Bartlomiej Zolnierkiewicz
  2014-06-17 14:27 ` Tejun Heo
  0 siblings, 2 replies; 3+ messages in thread
From: Mikko Perttunen @ 2014-06-17 12:07 UTC (permalink / raw)
  To: tj; +Cc: linux-ide, linux-kernel, Mikko Perttunen

ahci_platform_get_resources handles resource management for
platform AHCI drivers, including getting a possible PHY
from the device tree. Since not all drivers need a PHY, it
ignores -ENODEV and -ENOSYS from devm_get_phy. However, when
the PHY subsystem is mistakenly disabled, -ENOSYS can be
returned even when a PHY is needed.

This patch modifies the -ENOSYS case to check if a "phys"
device tree node exists. If it exists, then clearly the PHY
subsystem is mistakenly disabled and the driver cannot work,
ahci_platform_get_resources will fail and propagate the error.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
---
 drivers/ata/libahci_platform.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c
index 3a5b4ed..b007758 100644
--- a/drivers/ata/libahci_platform.c
+++ b/drivers/ata/libahci_platform.c
@@ -250,8 +250,13 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev)
 	if (IS_ERR(hpriv->phy)) {
 		rc = PTR_ERR(hpriv->phy);
 		switch (rc) {
-		case -ENODEV:
 		case -ENOSYS:
+			/* No PHY support. Check if PHY is required. */
+			if (of_find_property(dev->of_node, "phys", NULL)) {
+				dev_err(dev, "couldn't get sata-phy: ENOSYS\n");
+				goto err_out;
+			}
+		case -ENODEV:
 			/* continue normally */
 			hpriv->phy = NULL;
 			break;
-- 
1.8.1.5


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

* Re: [PATCH RESEND] libahci_platform: Fail when PHY required but PHY support disabled
  2014-06-17 12:07 [PATCH RESEND] libahci_platform: Fail when PHY required but PHY support disabled Mikko Perttunen
@ 2014-06-17 12:33 ` Bartlomiej Zolnierkiewicz
  2014-06-17 14:27 ` Tejun Heo
  1 sibling, 0 replies; 3+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2014-06-17 12:33 UTC (permalink / raw)
  To: Mikko Perttunen; +Cc: tj, linux-ide, linux-kernel

On Tuesday, June 17, 2014 03:07:55 PM Mikko Perttunen wrote:
> ahci_platform_get_resources handles resource management for
> platform AHCI drivers, including getting a possible PHY
> from the device tree. Since not all drivers need a PHY, it
> ignores -ENODEV and -ENOSYS from devm_get_phy. However, when
> the PHY subsystem is mistakenly disabled, -ENOSYS can be
> returned even when a PHY is needed.
> 
> This patch modifies the -ENOSYS case to check if a "phys"
> device tree node exists. If it exists, then clearly the PHY
> subsystem is mistakenly disabled and the driver cannot work,
> ahci_platform_get_resources will fail and propagate the error.
> 
> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>

Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>

> ---
>  drivers/ata/libahci_platform.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c
> index 3a5b4ed..b007758 100644
> --- a/drivers/ata/libahci_platform.c
> +++ b/drivers/ata/libahci_platform.c
> @@ -250,8 +250,13 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev)
>  	if (IS_ERR(hpriv->phy)) {
>  		rc = PTR_ERR(hpriv->phy);
>  		switch (rc) {
> -		case -ENODEV:
>  		case -ENOSYS:
> +			/* No PHY support. Check if PHY is required. */
> +			if (of_find_property(dev->of_node, "phys", NULL)) {
> +				dev_err(dev, "couldn't get sata-phy: ENOSYS\n");
> +				goto err_out;
> +			}
> +		case -ENODEV:
>  			/* continue normally */
>  			hpriv->phy = NULL;
>  			break;

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics


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

* Re: [PATCH RESEND] libahci_platform: Fail when PHY required but PHY support disabled
  2014-06-17 12:07 [PATCH RESEND] libahci_platform: Fail when PHY required but PHY support disabled Mikko Perttunen
  2014-06-17 12:33 ` Bartlomiej Zolnierkiewicz
@ 2014-06-17 14:27 ` Tejun Heo
  1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2014-06-17 14:27 UTC (permalink / raw)
  To: Mikko Perttunen; +Cc: linux-ide, linux-kernel

On Tue, Jun 17, 2014 at 03:07:55PM +0300, Mikko Perttunen wrote:
> ahci_platform_get_resources handles resource management for
> platform AHCI drivers, including getting a possible PHY
> from the device tree. Since not all drivers need a PHY, it
> ignores -ENODEV and -ENOSYS from devm_get_phy. However, when
> the PHY subsystem is mistakenly disabled, -ENOSYS can be
> returned even when a PHY is needed.
> 
> This patch modifies the -ENOSYS case to check if a "phys"
> device tree node exists. If it exists, then clearly the PHY
> subsystem is mistakenly disabled and the driver cannot work,
> ahci_platform_get_resources will fail and propagate the error.
> 
> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>

Applied to libata/for-3.17.

Thanks.

-- 
tejun

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

end of thread, other threads:[~2014-06-17 14:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-17 12:07 [PATCH RESEND] libahci_platform: Fail when PHY required but PHY support disabled Mikko Perttunen
2014-06-17 12:33 ` Bartlomiej Zolnierkiewicz
2014-06-17 14:27 ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox