linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] hwrng: meson - Improve error handling for core clock
@ 2021-09-20  7:44 Uwe Kleine-König
  2021-09-20  8:16 ` Neil Armstrong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2021-09-20  7:44 UTC (permalink / raw)
  To: Matt Mackall, Herbert Xu, Neil Armstrong, Kevin Hilman
  Cc: Martin Blumenstingl, linux-crypto, kernel, linux-amlogic,
	linux-arm-kernel, Jerome Brunet

-ENOENT (ie. "there is no clock") is fine to ignore for an optional
clock, other values are not supposed to be ignored and should be
escalated to the caller (e.g. -EPROBE_DEFER). Ignore -ENOENT by using
devm_clk_get_optional().

While touching this code also add an error message for the fatal errors.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Hello,

compared to (implicit) v1
(https://lore.kernel.org/r/20210914142428.57099-1-u.kleine-koenig@pengutronix.de)
this used dev_err_probe() as suggested by Martin Blumenstingl.

v1 got a "Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>", I didn't add
that because of the above change.

(Hmm, my setup is broken, the b4 patch signature was done before I added this
message. I wonder if this will break the signature ...)

Best regards
Uwe

 drivers/char/hw_random/meson-rng.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/char/hw_random/meson-rng.c b/drivers/char/hw_random/meson-rng.c
index e446236e81f2..8bb30282ca46 100644
--- a/drivers/char/hw_random/meson-rng.c
+++ b/drivers/char/hw_random/meson-rng.c
@@ -54,9 +54,10 @@ static int meson_rng_probe(struct platform_device *pdev)
 	if (IS_ERR(data->base))
 		return PTR_ERR(data->base);
 
-	data->core_clk = devm_clk_get(dev, "core");
+	data->core_clk = devm_clk_get_optional(dev, "core");
 	if (IS_ERR(data->core_clk))
-		data->core_clk = NULL;
+		return dev_err_probe(dev, PTR_ERR(data->core_clk),
+				     "Failed to get core clock\n");
 
 	if (data->core_clk) {
 		ret = clk_prepare_enable(data->core_clk);

base-commit: 7d2a07b769330c34b4deabeed939325c77a7ec2f
-- 
2.30.2


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

* Re: [PATCH v2] hwrng: meson - Improve error handling for core clock
  2021-09-20  7:44 [PATCH v2] hwrng: meson - Improve error handling for core clock Uwe Kleine-König
@ 2021-09-20  8:16 ` Neil Armstrong
  2021-09-20 20:24 ` Martin Blumenstingl
  2021-10-01  6:43 ` Herbert Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Neil Armstrong @ 2021-09-20  8:16 UTC (permalink / raw)
  To: Uwe Kleine-König, Matt Mackall, Herbert Xu, Kevin Hilman
  Cc: Martin Blumenstingl, linux-crypto, kernel, linux-amlogic,
	linux-arm-kernel, Jerome Brunet

On 20/09/2021 09:44, Uwe Kleine-König wrote:
> -ENOENT (ie. "there is no clock") is fine to ignore for an optional
> clock, other values are not supposed to be ignored and should be
> escalated to the caller (e.g. -EPROBE_DEFER). Ignore -ENOENT by using
> devm_clk_get_optional().
> 
> While touching this code also add an error message for the fatal errors.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> Hello,
> 
> compared to (implicit) v1
> (https://lore.kernel.org/r/20210914142428.57099-1-u.kleine-koenig@pengutronix.de)
> this used dev_err_probe() as suggested by Martin Blumenstingl.
> 
> v1 got a "Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>", I didn't add
> that because of the above change.
> 

Hopefully martin did a better review than me !

Anyway,
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>

Neil

> (Hmm, my setup is broken, the b4 patch signature was done before I added this
> message. I wonder if this will break the signature ...)
> 
> Best regards
> Uwe
> 
>  drivers/char/hw_random/meson-rng.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/char/hw_random/meson-rng.c b/drivers/char/hw_random/meson-rng.c
> index e446236e81f2..8bb30282ca46 100644
> --- a/drivers/char/hw_random/meson-rng.c
> +++ b/drivers/char/hw_random/meson-rng.c
> @@ -54,9 +54,10 @@ static int meson_rng_probe(struct platform_device *pdev)
>  	if (IS_ERR(data->base))
>  		return PTR_ERR(data->base);
>  
> -	data->core_clk = devm_clk_get(dev, "core");
> +	data->core_clk = devm_clk_get_optional(dev, "core");
>  	if (IS_ERR(data->core_clk))
> -		data->core_clk = NULL;
> +		return dev_err_probe(dev, PTR_ERR(data->core_clk),
> +				     "Failed to get core clock\n");
>  
>  	if (data->core_clk) {
>  		ret = clk_prepare_enable(data->core_clk);
> 
> base-commit: 7d2a07b769330c34b4deabeed939325c77a7ec2f
> 


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

* Re: [PATCH v2] hwrng: meson - Improve error handling for core clock
  2021-09-20  7:44 [PATCH v2] hwrng: meson - Improve error handling for core clock Uwe Kleine-König
  2021-09-20  8:16 ` Neil Armstrong
@ 2021-09-20 20:24 ` Martin Blumenstingl
  2021-10-01  6:43 ` Herbert Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Martin Blumenstingl @ 2021-09-20 20:24 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Matt Mackall, Herbert Xu, Neil Armstrong, Kevin Hilman,
	linux-crypto, kernel, linux-amlogic, linux-arm-kernel,
	Jerome Brunet

On Mon, Sep 20, 2021 at 9:44 AM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
>
> -ENOENT (ie. "there is no clock") is fine to ignore for an optional
> clock, other values are not supposed to be ignored and should be
> escalated to the caller (e.g. -EPROBE_DEFER). Ignore -ENOENT by using
> devm_clk_get_optional().
>
> While touching this code also add an error message for the fatal errors.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
as well as:
Tested-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> #
on Odroid-C1

Thank you Uwe!


Best regards,
Martin

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

* Re: [PATCH v2] hwrng: meson - Improve error handling for core clock
  2021-09-20  7:44 [PATCH v2] hwrng: meson - Improve error handling for core clock Uwe Kleine-König
  2021-09-20  8:16 ` Neil Armstrong
  2021-09-20 20:24 ` Martin Blumenstingl
@ 2021-10-01  6:43 ` Herbert Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2021-10-01  6:43 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Matt Mackall, Neil Armstrong, Kevin Hilman, Martin Blumenstingl,
	linux-crypto, kernel, linux-amlogic, linux-arm-kernel,
	Jerome Brunet

On Mon, Sep 20, 2021 at 09:44:05AM +0200, Uwe Kleine-König wrote:
> -ENOENT (ie. "there is no clock") is fine to ignore for an optional
> clock, other values are not supposed to be ignored and should be
> escalated to the caller (e.g. -EPROBE_DEFER). Ignore -ENOENT by using
> devm_clk_get_optional().
> 
> While touching this code also add an error message for the fatal errors.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> Hello,
> 
> compared to (implicit) v1
> (https://lore.kernel.org/r/20210914142428.57099-1-u.kleine-koenig@pengutronix.de)
> this used dev_err_probe() as suggested by Martin Blumenstingl.
> 
> v1 got a "Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>", I didn't add
> that because of the above change.
> 
> (Hmm, my setup is broken, the b4 patch signature was done before I added this
> message. I wonder if this will break the signature ...)
> 
> Best regards
> Uwe
> 
>  drivers/char/hw_random/meson-rng.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

end of thread, other threads:[~2021-10-01  6:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-20  7:44 [PATCH v2] hwrng: meson - Improve error handling for core clock Uwe Kleine-König
2021-09-20  8:16 ` Neil Armstrong
2021-09-20 20:24 ` Martin Blumenstingl
2021-10-01  6:43 ` Herbert Xu

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