2021-09-20 09:52:23

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH v2] hwrng: meson - Improve error handling for core clock

-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 <[email protected]>
---
Hello,

compared to (implicit) v1
(https://lore.kernel.org/r/[email protected])
this used dev_err_probe() as suggested by Martin Blumenstingl.

v1 got a "Reviewed-by: Neil Armstrong <[email protected]>", 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


2021-09-20 09:55:19

by Neil Armstrong

[permalink] [raw]
Subject: Re: [PATCH v2] hwrng: meson - Improve error handling for core clock

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 <[email protected]>
> ---
> Hello,
>
> compared to (implicit) v1
> (https://lore.kernel.org/r/[email protected])
> this used dev_err_probe() as suggested by Martin Blumenstingl.
>
> v1 got a "Reviewed-by: Neil Armstrong <[email protected]>", I didn't add
> that because of the above change.
>

Hopefully martin did a better review than me !

Anyway,
Reviewed-by: Neil Armstrong <[email protected]>

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
>

2021-09-21 04:08:50

by Martin Blumenstingl

[permalink] [raw]
Subject: Re: [PATCH v2] hwrng: meson - Improve error handling for core clock

On Mon, Sep 20, 2021 at 9:44 AM Uwe Kleine-König
<[email protected]> 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 <[email protected]>
Reviewed-by: Martin Blumenstingl <[email protected]>
as well as:
Tested-by: Martin Blumenstingl <[email protected]> #
on Odroid-C1

Thank you Uwe!


Best regards,
Martin

2021-10-01 06:45:14

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH v2] hwrng: meson - Improve error handling for core clock

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 <[email protected]>
> ---
> Hello,
>
> compared to (implicit) v1
> (https://lore.kernel.org/r/[email protected])
> this used dev_err_probe() as suggested by Martin Blumenstingl.
>
> v1 got a "Reviewed-by: Neil Armstrong <[email protected]>", 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 <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt