linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: pxa2xx: Handle return value of clk_prepare_enable
@ 2017-06-06  9:44 Arvind Yadav
       [not found] ` <4e16c0aba047b068aaa41c1d180d98ccb441afd0.1496668108.git.arvind.yadav.cs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Arvind Yadav @ 2017-06-06  9:44 UTC (permalink / raw)
  To: daniel-cYrQPVfZoowdnm+yROfE0A,
	haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w,
	robert.jarzmik-GANU6spQydw, broonie-DgEjT+Ai2ygdnm+yROfE0A,
	geert-Td1EMuHUCqxL1ZNQvxDV9g
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

clk_prepare_enable() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <arvind.yadav.cs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/spi/spi-pxa2xx.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index 47b65d7..e9c0fe5 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -1676,7 +1676,11 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
 	}
 
 	/* Enable SOC clock */
-	clk_prepare_enable(ssp->clk);
+	status = clk_prepare_enable(ssp->clk);
+	if (status) {
+		dev_err(&pdev->dev, "Failed to prepare clock\n");
+		goto out_error_master_alloc;
+	}
 
 	master->max_speed_hz = clk_get_rate(ssp->clk);
 
@@ -1855,8 +1859,13 @@ static int pxa2xx_spi_resume(struct device *dev)
 	int status;
 
 	/* Enable the SSP clock */
-	if (!pm_runtime_suspended(dev))
-		clk_prepare_enable(ssp->clk);
+	if (!pm_runtime_suspended(dev)) {
+		status = clk_prepare_enable(ssp->clk);
+		if (status) {
+			dev_err(dev, "Failed to prepare clock\n");
+			return status;
+		}
+	}
 
 	/* Restore LPSS private register bits */
 	if (is_lpss_ssp(drv_data))
@@ -1886,8 +1895,7 @@ static int pxa2xx_spi_runtime_resume(struct device *dev)
 {
 	struct driver_data *drv_data = dev_get_drvdata(dev);
 
-	clk_prepare_enable(drv_data->ssp->clk);
-	return 0;
+	return clk_prepare_enable(drv_data->ssp->clk);
 }
 #endif
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] spi: pxa2xx: Handle return value of clk_prepare_enable
       [not found] ` <4e16c0aba047b068aaa41c1d180d98ccb441afd0.1496668108.git.arvind.yadav.cs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2017-06-06 10:54   ` Andy Shevchenko
  2017-06-06 11:33     ` Arvind Yadav
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2017-06-06 10:54 UTC (permalink / raw)
  To: Arvind Yadav
  Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Mark Brown,
	Geert Uytterhoeven, linux-arm Mailing List, linux-spi,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Tue, Jun 6, 2017 at 12:44 PM, Arvind Yadav <arvind.yadav.cs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> clk_prepare_enable() can fail here and we must check its return value.

> @@ -1676,7 +1676,11 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)

> -       clk_prepare_enable(ssp->clk);
> +       status = clk_prepare_enable(ssp->clk);

This one looks fine.

> @@ -1855,8 +1859,13 @@ static int pxa2xx_spi_resume(struct device *dev)

>         /* Enable the SSP clock */
> -       if (!pm_runtime_suspended(dev))
> -               clk_prepare_enable(ssp->clk);
> +       if (!pm_runtime_suspended(dev)) {
> +               status = clk_prepare_enable(ssp->clk);
> +               if (status) {
> +                       dev_err(dev, "Failed to prepare clock\n");
> +                       return status;
> +               }

This...

> @@ -1886,8 +1895,7 @@ static int pxa2xx_spi_runtime_resume(struct device *dev)
>  {
>         struct driver_data *drv_data = dev_get_drvdata(dev);
>
> -       clk_prepare_enable(drv_data->ssp->clk);
> -       return 0;
> +       return clk_prepare_enable(drv_data->ssp->clk);

...and especially this should be carefully checked since there are
differences in behaviour how system or driver will be resumed.

So, the question is how did you test it?

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] spi: pxa2xx: Handle return value of clk_prepare_enable
  2017-06-06 10:54   ` Andy Shevchenko
@ 2017-06-06 11:33     ` Arvind Yadav
  0 siblings, 0 replies; 3+ messages in thread
From: Arvind Yadav @ 2017-06-06 11:33 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Mark Brown,
	Geert Uytterhoeven, linux-arm Mailing List, linux-spi,
	linux-kernel



On Tuesday 06 June 2017 04:24 PM, Andy Shevchenko wrote:
> On Tue, Jun 6, 2017 at 12:44 PM, Arvind Yadav <arvind.yadav.cs@gmail.com> wrote:
>> clk_prepare_enable() can fail here and we must check its return value.
>> @@ -1676,7 +1676,11 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
>> -       clk_prepare_enable(ssp->clk);
>> +       status = clk_prepare_enable(ssp->clk);
> This one looks fine.
>
>> @@ -1855,8 +1859,13 @@ static int pxa2xx_spi_resume(struct device *dev)
>>          /* Enable the SSP clock */
>> -       if (!pm_runtime_suspended(dev))
>> -               clk_prepare_enable(ssp->clk);
>> +       if (!pm_runtime_suspended(dev)) {
>> +               status = clk_prepare_enable(ssp->clk);
>> +               if (status) {
>> +                       dev_err(dev, "Failed to prepare clock\n");
>> +                       return status;
>> +               }
> This...
>
>> @@ -1886,8 +1895,7 @@ static int pxa2xx_spi_runtime_resume(struct device *dev)
>>   {
>>          struct driver_data *drv_data = dev_get_drvdata(dev);
>>
>> -       clk_prepare_enable(drv_data->ssp->clk);
>> -       return 0;
>> +       return clk_prepare_enable(drv_data->ssp->clk);
> ...and especially this should be carefully checked since there are
> differences in behaviour how system or driver will be resumed.
yes true, here clk_prepare_enable will return 0 on successful attempt.
what do you suggest here, we should not return like this.?
>
> So, the question is how did you test it?
It can fail, I am not able to produce clock failure issue. If you have 
any suggestion.
please let me know.
>
-arvind

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

end of thread, other threads:[~2017-06-06 11:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-06  9:44 [PATCH] spi: pxa2xx: Handle return value of clk_prepare_enable Arvind Yadav
     [not found] ` <4e16c0aba047b068aaa41c1d180d98ccb441afd0.1496668108.git.arvind.yadav.cs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-06 10:54   ` Andy Shevchenko
2017-06-06 11:33     ` Arvind Yadav

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).