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

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


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

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

end of thread, other threads:[~2021-09-19 20:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14 14:24 [PATCH] hwrng: meson - Improve error handling for core clock Uwe Kleine-König
2021-09-15  8:13 ` Neil Armstrong
2021-09-19 20:07 ` Martin Blumenstingl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®