linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ata: brcm: mark PM functions as __maybe_unused
@ 2020-01-07 22:14 Arnd Bergmann
  2020-01-07 22:15 ` [PATCH 2/2] ata: brcm: fix reset controller API usage Arnd Bergmann
  2020-01-07 22:51 ` [PATCH 1/2] ata: brcm: mark PM functions as __maybe_unused Florian Fainelli
  0 siblings, 2 replies; 4+ messages in thread
From: Arnd Bergmann @ 2020-01-07 22:14 UTC (permalink / raw)
  To: Jens Axboe, Florian Fainelli, Hans de Goede
  Cc: Arnd Bergmann, Greg Kroah-Hartman, Thomas Gleixner, linux-ide,
	linux-kernel

The new shutdown callback causes a link failure:

drivers/ata/ahci_brcm.c: In function 'brcm_ahci_shutdown':
drivers/ata/ahci_brcm.c:552:8: error: implicit declaration of function 'brcm_ahci_suspend'; did you mean 'brcm_ahci_shutdown'? [-Werror=implicit-function-declaration]
  ret = brcm_ahci_suspend(&pdev->dev);
        ^~~~~~~~~~~~~~~~~

Remove the incorrect #ifdef and use __maybe_unused annotations
instead to make this more robust.

Fixes: 7de9b1688c1d ("ata: ahci_brcm: Add a shutdown callback")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/ata/ahci_brcm.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/ata/ahci_brcm.c b/drivers/ata/ahci_brcm.c
index 13ceca687104..239333d11b88 100644
--- a/drivers/ata/ahci_brcm.c
+++ b/drivers/ata/ahci_brcm.c
@@ -338,7 +338,6 @@ static const struct ata_port_info ahci_brcm_port_info = {
 	.port_ops	= &ahci_brcm_platform_ops,
 };
 
-#ifdef CONFIG_PM_SLEEP
 static int brcm_ahci_suspend(struct device *dev)
 {
 	struct ata_host *host = dev_get_drvdata(dev);
@@ -348,7 +347,10 @@ static int brcm_ahci_suspend(struct device *dev)
 
 	brcm_sata_phys_disable(priv);
 
-	ret = ahci_platform_suspend(dev);
+	if (IS_ENABLED(CONFIG_PM_SLEEP))
+		ret = ahci_platform_suspend(dev);
+	else
+		ret = 0;
 
 	if (!IS_ERR_OR_NULL(priv->rcdev))
 		reset_control_assert(priv->rcdev);
@@ -356,7 +358,7 @@ static int brcm_ahci_suspend(struct device *dev)
 	return ret;
 }
 
-static int brcm_ahci_resume(struct device *dev)
+static int __maybe_unused brcm_ahci_resume(struct device *dev)
 {
 	struct ata_host *host = dev_get_drvdata(dev);
 	struct ahci_host_priv *hpriv = host->private_data;
@@ -405,7 +407,6 @@ static int brcm_ahci_resume(struct device *dev)
 	ahci_platform_disable_clks(hpriv);
 	return ret;
 }
-#endif
 
 static struct scsi_host_template ahci_platform_sht = {
 	AHCI_SHT(DRV_NAME),
-- 
2.20.0


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

* [PATCH 2/2] ata: brcm: fix reset controller API usage
  2020-01-07 22:14 [PATCH 1/2] ata: brcm: mark PM functions as __maybe_unused Arnd Bergmann
@ 2020-01-07 22:15 ` Arnd Bergmann
  2020-01-07 22:52   ` Florian Fainelli
  2020-01-07 22:51 ` [PATCH 1/2] ata: brcm: mark PM functions as __maybe_unused Florian Fainelli
  1 sibling, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2020-01-07 22:15 UTC (permalink / raw)
  To: Jens Axboe, Philipp Zabel, Florian Fainelli
  Cc: Arnd Bergmann, Hans de Goede, Allison Randal, Thomas Gleixner,
	linux-ide, linux-kernel

While fixing another issue in this driver I noticed it uses
IS_ERR_OR_NULL(), which is almost always a mistake.

Change the driver to use the proper devm_reset_control_get_optional()
interface instead and remove the checks except for the one that
checks for a failure in that function.

Fixes: 2b2c47d9e1fe ("ata: ahci_brcm: Allow optional reset controller to be used")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/ata/ahci_brcm.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/ata/ahci_brcm.c b/drivers/ata/ahci_brcm.c
index 239333d11b88..7ac1141c6ad0 100644
--- a/drivers/ata/ahci_brcm.c
+++ b/drivers/ata/ahci_brcm.c
@@ -352,8 +352,7 @@ static int brcm_ahci_suspend(struct device *dev)
 	else
 		ret = 0;
 
-	if (!IS_ERR_OR_NULL(priv->rcdev))
-		reset_control_assert(priv->rcdev);
+	reset_control_assert(priv->rcdev);
 
 	return ret;
 }
@@ -365,8 +364,7 @@ static int __maybe_unused brcm_ahci_resume(struct device *dev)
 	struct brcm_ahci_priv *priv = hpriv->plat_data;
 	int ret = 0;
 
-	if (!IS_ERR_OR_NULL(priv->rcdev))
-		ret = reset_control_deassert(priv->rcdev);
+	ret = reset_control_deassert(priv->rcdev);
 	if (ret)
 		return ret;
 
@@ -454,9 +452,11 @@ static int brcm_ahci_probe(struct platform_device *pdev)
 	else
 		reset_name = "ahci";
 
-	priv->rcdev = devm_reset_control_get(&pdev->dev, reset_name);
-	if (!IS_ERR_OR_NULL(priv->rcdev))
-		reset_control_deassert(priv->rcdev);
+	priv->rcdev = devm_reset_control_get_optional(&pdev->dev, reset_name);
+	if (IS_ERR(priv->rcdev))
+		return PTR_ERR(priv->rcdev);
+
+	reset_control_deassert(priv->rcdev);
 
 	hpriv = ahci_platform_get_resources(pdev, 0);
 	if (IS_ERR(hpriv)) {
@@ -520,8 +520,7 @@ static int brcm_ahci_probe(struct platform_device *pdev)
 out_disable_clks:
 	ahci_platform_disable_clks(hpriv);
 out_reset:
-	if (!IS_ERR_OR_NULL(priv->rcdev))
-		reset_control_assert(priv->rcdev);
+	reset_control_assert(priv->rcdev);
 	return ret;
 }
 
-- 
2.20.0


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

* Re: [PATCH 1/2] ata: brcm: mark PM functions as __maybe_unused
  2020-01-07 22:14 [PATCH 1/2] ata: brcm: mark PM functions as __maybe_unused Arnd Bergmann
  2020-01-07 22:15 ` [PATCH 2/2] ata: brcm: fix reset controller API usage Arnd Bergmann
@ 2020-01-07 22:51 ` Florian Fainelli
  1 sibling, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2020-01-07 22:51 UTC (permalink / raw)
  To: Arnd Bergmann, Jens Axboe, Hans de Goede
  Cc: Greg Kroah-Hartman, Thomas Gleixner, linux-ide, linux-kernel

On 1/7/20 2:14 PM, Arnd Bergmann wrote:
> The new shutdown callback causes a link failure:
> 
> drivers/ata/ahci_brcm.c: In function 'brcm_ahci_shutdown':
> drivers/ata/ahci_brcm.c:552:8: error: implicit declaration of function 'brcm_ahci_suspend'; did you mean 'brcm_ahci_shutdown'? [-Werror=implicit-function-declaration]
>   ret = brcm_ahci_suspend(&pdev->dev);
>         ^~~~~~~~~~~~~~~~~
> 
> Remove the incorrect #ifdef and use __maybe_unused annotations
> instead to make this more robust.
> 
> Fixes: 7de9b1688c1d ("ata: ahci_brcm: Add a shutdown callback")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>

good catch, thanks!
-- 
Florian

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

* Re: [PATCH 2/2] ata: brcm: fix reset controller API usage
  2020-01-07 22:15 ` [PATCH 2/2] ata: brcm: fix reset controller API usage Arnd Bergmann
@ 2020-01-07 22:52   ` Florian Fainelli
  0 siblings, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2020-01-07 22:52 UTC (permalink / raw)
  To: Arnd Bergmann, Jens Axboe, Philipp Zabel
  Cc: Hans de Goede, Allison Randal, Thomas Gleixner, linux-ide, linux-kernel

On 1/7/20 2:15 PM, Arnd Bergmann wrote:
> While fixing another issue in this driver I noticed it uses
> IS_ERR_OR_NULL(), which is almost always a mistake.
> 
> Change the driver to use the proper devm_reset_control_get_optional()
> interface instead and remove the checks except for the one that
> checks for a failure in that function.
> 
> Fixes: 2b2c47d9e1fe ("ata: ahci_brcm: Allow optional reset controller to be used")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

This is nearly equivalent to:

https://lore.kernel.org/lkml/20200107183022.26224-2-f.fainelli@gmail.com/

which was just submitted this morning. Thanks!

> ---
>  drivers/ata/ahci_brcm.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/ata/ahci_brcm.c b/drivers/ata/ahci_brcm.c
> index 239333d11b88..7ac1141c6ad0 100644
> --- a/drivers/ata/ahci_brcm.c
> +++ b/drivers/ata/ahci_brcm.c
> @@ -352,8 +352,7 @@ static int brcm_ahci_suspend(struct device *dev)
>  	else
>  		ret = 0;
>  
> -	if (!IS_ERR_OR_NULL(priv->rcdev))
> -		reset_control_assert(priv->rcdev);
> +	reset_control_assert(priv->rcdev);
>  
>  	return ret;
>  }
> @@ -365,8 +364,7 @@ static int __maybe_unused brcm_ahci_resume(struct device *dev)
>  	struct brcm_ahci_priv *priv = hpriv->plat_data;
>  	int ret = 0;
>  
> -	if (!IS_ERR_OR_NULL(priv->rcdev))
> -		ret = reset_control_deassert(priv->rcdev);
> +	ret = reset_control_deassert(priv->rcdev);
>  	if (ret)
>  		return ret;
>  
> @@ -454,9 +452,11 @@ static int brcm_ahci_probe(struct platform_device *pdev)
>  	else
>  		reset_name = "ahci";
>  
> -	priv->rcdev = devm_reset_control_get(&pdev->dev, reset_name);
> -	if (!IS_ERR_OR_NULL(priv->rcdev))
> -		reset_control_deassert(priv->rcdev);
> +	priv->rcdev = devm_reset_control_get_optional(&pdev->dev, reset_name);
> +	if (IS_ERR(priv->rcdev))
> +		return PTR_ERR(priv->rcdev);
> +
> +	reset_control_deassert(priv->rcdev);
>  
>  	hpriv = ahci_platform_get_resources(pdev, 0);
>  	if (IS_ERR(hpriv)) {
> @@ -520,8 +520,7 @@ static int brcm_ahci_probe(struct platform_device *pdev)
>  out_disable_clks:
>  	ahci_platform_disable_clks(hpriv);
>  out_reset:
> -	if (!IS_ERR_OR_NULL(priv->rcdev))
> -		reset_control_assert(priv->rcdev);
> +	reset_control_assert(priv->rcdev);
>  	return ret;
>  }
>  
> 


-- 
Florian

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

end of thread, other threads:[~2020-01-07 22:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-07 22:14 [PATCH 1/2] ata: brcm: mark PM functions as __maybe_unused Arnd Bergmann
2020-01-07 22:15 ` [PATCH 2/2] ata: brcm: fix reset controller API usage Arnd Bergmann
2020-01-07 22:52   ` Florian Fainelli
2020-01-07 22:51 ` [PATCH 1/2] ata: brcm: mark PM functions as __maybe_unused Florian Fainelli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).