From: Lionel Debieve Subject: [PATCH Resend 1/5] hwrng: stm32 - add reset during probe Date: Thu, 15 Feb 2018 14:03:08 +0100 Message-ID: <20180215130312.23612-2-lionel.debieve@st.com> References: <20180215130312.23612-1-lionel.debieve@st.com> Mime-Version: 1.0 Content-Type: text/plain Cc: Benjamin Gaignard , Ludovic Barre To: Matt Mackall , Herbert Xu , Arnd Bergmann , Greg Kroah-Hartman , Maxime Coquelin , Alexandre Torgue , Rob Herring , , , Return-path: In-Reply-To: <20180215130312.23612-1-lionel.debieve@st.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-crypto.vger.kernel.org Avoid issue when probing the RNG without reset if bad status has been detected previously Signed-off-by: Lionel Debieve --- drivers/char/hw_random/stm32-rng.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/char/hw_random/stm32-rng.c b/drivers/char/hw_random/stm32-rng.c index 63d84e6f1891..83c695938a2d 100644 --- a/drivers/char/hw_random/stm32-rng.c +++ b/drivers/char/hw_random/stm32-rng.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #define RNG_CR 0x00 @@ -46,6 +47,7 @@ struct stm32_rng_private { struct hwrng rng; void __iomem *base; struct clk *clk; + struct reset_control *rst; }; static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool wait) @@ -140,6 +142,13 @@ static int stm32_rng_probe(struct platform_device *ofdev) if (IS_ERR(priv->clk)) return PTR_ERR(priv->clk); + priv->rst = devm_reset_control_get(&ofdev->dev, NULL); + if (!IS_ERR(priv->rst)) { + reset_control_assert(priv->rst); + udelay(2); + reset_control_deassert(priv->rst); + } + dev_set_drvdata(dev, priv); priv->rng.name = dev_driver_string(dev), -- 2.15.1