mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] fixup! hw_random: add support for STM32 RNG
Date: Wed,  5 Feb 2020 15:06:33 +0100	[thread overview]
Message-ID: <20200205140633.19599-1-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20200205133729.32713-1-a.fatoum@pengutronix.de>

remove is only called when probe succeeds, but we want to undo what init
did if it failed, thus call it explicitly in error case.

---
 drivers/hw_random/stm32-rng.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/hw_random/stm32-rng.c b/drivers/hw_random/stm32-rng.c
index 13d60f1b0bd0..440b53684f71 100644
--- a/drivers/hw_random/stm32-rng.c
+++ b/drivers/hw_random/stm32-rng.c
@@ -106,6 +106,14 @@ static int stm32_rng_init(struct hwrng *hwrng)
 	return 0;
 }
 
+static void stm32_rng_remove(struct device_d *dev)
+{
+	struct stm32_rng *rng = dev->priv;
+
+	writel(0, rng->base + RNG_CR);
+	clk_disable(rng->clk);
+}
+
 static int stm32_rng_probe(struct device_d *dev)
 {
 	struct stm32_rng *rng;
@@ -136,23 +144,12 @@ static int stm32_rng_probe(struct device_d *dev)
 	rng->hwrng.init = stm32_rng_init;
 
 	ret = hwrng_register(dev, &rng->hwrng);
-	if (ret) {
-		dev_err(dev, "failed to register: %s\n", strerror(-ret));
-		clk_disable(rng->clk);
-	}
+	if (ret)
+		stm32_rng_remove(dev);
 
 	return ret;
 }
 
-static void stm32_rng_remove(struct device_d *dev)
-{
-	struct stm32_rng *rng = dev->priv;
-
-	writel(0, rng->base + RNG_CR);
-	clk_disable(rng->clk);
-}
-
-
 static const struct of_device_id stm32_rng_dt_ids[] = {
 	{ .compatible = "st,stm32-rng" },
 	{ /* sentinel */},
-- 
2.25.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2020-02-05 14:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-05 13:37 [PATCH] " Ahmad Fatoum
2020-02-05 14:06 ` Ahmad Fatoum [this message]
2020-02-10  8:13 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200205140633.19599-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox