[PATCH] hwrng: meson - Improve error handling for core clock
Uwe Kleine-König
u.kleine-koenig at pengutronix.de
Tue Sep 14 07:24:28 PDT 2021
-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);
--
2.30.2
More information about the linux-amlogic
mailing list