[PATCH] fixup! hw_random: add support for STM32 RNG

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux