[PATCH] hwrng: meson - Improve error handling for core clock
Neil Armstrong
narmstrong at baylibre.com
Wed Sep 15 01:13:54 PDT 2021
On 14/09/2021 16:24, 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 at pengutronix.de>
> ---
> drivers/char/hw_random/meson-rng.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/char/hw_random/meson-rng.c b/drivers/char/hw_random/meson-rng.c
> index e446236e81f2..9f3e2eb8011d 100644
> --- a/drivers/char/hw_random/meson-rng.c
> +++ b/drivers/char/hw_random/meson-rng.c
> @@ -54,9 +54,15 @@ 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");
> - if (IS_ERR(data->core_clk))
> - data->core_clk = NULL;
> + data->core_clk = devm_clk_get_optional(dev, "core");
> + if (IS_ERR(data->core_clk)) {
> + ret = PTR_ERR(data->core_clk);
> + if (ret != -EPROBE_DEFER)
> + dev_err(dev, "Failed to get core clock: %pe\n",
> + data->core_clk);
> +
> + return ret;
> + }
>
> if (data->core_clk) {
> ret = clk_prepare_enable(data->core_clk);
>
Reviewed-by: Neil Armstrong <narmstrong at baylibre.com>
Thanks,
Neil
More information about the linux-arm-kernel
mailing list