linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] misc: atmel-ssc: Handle error for clk_prepare
@ 2022-03-02  8:49 Jiasheng Jiang
  2022-03-02  9:47 ` Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: Jiasheng Jiang @ 2022-03-02  8:49 UTC (permalink / raw)
  To: codrin.ciubotariu, arnd, gregkh, nicolas.ferre, alexandre.belloni,
	claudiu.beznea
  Cc: linux-arm-kernel, linux-kernel, Jiasheng Jiang

As the potential failure of the clk_prepare(),
it should be better to check it and return error if fails.

Fixes: eb1f2930609b ("Driver for the Atmel on-chip SSC on AT32AP and AT91")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/misc/atmel-ssc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
index d6cd5537126c..e0207e837e35 100644
--- a/drivers/misc/atmel-ssc.c
+++ b/drivers/misc/atmel-ssc.c
@@ -25,7 +25,7 @@ static LIST_HEAD(ssc_list);
 
 struct ssc_device *ssc_request(unsigned int ssc_num)
 {
-	int ssc_valid = 0;
+	int ssc_valid = 0, ret;
 	struct ssc_device *ssc;
 
 	mutex_lock(&user_lock);
@@ -57,7 +57,9 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
 	ssc->user++;
 	mutex_unlock(&user_lock);
 
-	clk_prepare(ssc->clk);
+	ret = clk_prepare(ssc->clk);
+	if (ret)
+		return ret;
 
 	return ssc;
 }
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] misc: atmel-ssc: Handle error for clk_prepare
  2022-03-02  8:49 [PATCH] misc: atmel-ssc: Handle error for clk_prepare Jiasheng Jiang
@ 2022-03-02  9:47 ` Alexandre Belloni
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2022-03-02  9:47 UTC (permalink / raw)
  To: Jiasheng Jiang
  Cc: arnd, gregkh, linux-kernel, codrin.ciubotariu, claudiu.beznea,
	linux-arm-kernel

On 02/03/2022 16:49:02+0800, Jiasheng Jiang wrote:
> As the potential failure of the clk_prepare(),
> it should be better to check it and return error if fails.
> 

This will never ever fail, this doesn't fix anything

> Fixes: eb1f2930609b ("Driver for the Atmel on-chip SSC on AT32AP and AT91")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>  drivers/misc/atmel-ssc.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
> index d6cd5537126c..e0207e837e35 100644
> --- a/drivers/misc/atmel-ssc.c
> +++ b/drivers/misc/atmel-ssc.c
> @@ -25,7 +25,7 @@ static LIST_HEAD(ssc_list);
>  
>  struct ssc_device *ssc_request(unsigned int ssc_num)
>  {
> -	int ssc_valid = 0;
> +	int ssc_valid = 0, ret;
>  	struct ssc_device *ssc;
>  
>  	mutex_lock(&user_lock);
> @@ -57,7 +57,9 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
>  	ssc->user++;
>  	mutex_unlock(&user_lock);
>  
> -	clk_prepare(ssc->clk);
> +	ret = clk_prepare(ssc->clk);
> +	if (ret)
> +		return ret;
>  
>  	return ssc;
>  }
> -- 
> 2.25.1
> 

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-03-02  9:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-02  8:49 [PATCH] misc: atmel-ssc: Handle error for clk_prepare Jiasheng Jiang
2022-03-02  9:47 ` Alexandre Belloni

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