Skip to content

Commit 070b730

Browse files
Eric Biggersgregkh
authored andcommitted
crypto: qcom-rng - Enable clock in hwrng case
commit 0fd97bb upstream. Fix qcom-rng.c to enable the clock before accessing the hardware. Fixes: f29cd5b ("crypto: qcom-rng - Add hw_random interface support") Cc: stable@vger.kernel.org Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5545de5 commit 070b730

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

drivers/crypto/qcom-rng.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,27 @@ static int qcom_rng_seed(struct crypto_rng *tfm, const u8 *seed,
113113
return 0;
114114
}
115115

116+
static int qcom_hwrng_init(struct hwrng *hwrng)
117+
{
118+
struct qcom_rng *qrng = container_of(hwrng, struct qcom_rng, hwrng);
119+
120+
return clk_prepare_enable(qrng->clk);
121+
}
122+
116123
static int qcom_hwrng_read(struct hwrng *hwrng, void *data, size_t max, bool wait)
117124
{
118125
struct qcom_rng *qrng = container_of(hwrng, struct qcom_rng, hwrng);
119126

120127
return qcom_rng_read(qrng, data, max);
121128
}
122129

130+
static void qcom_hwrng_cleanup(struct hwrng *hwrng)
131+
{
132+
struct qcom_rng *qrng = container_of(hwrng, struct qcom_rng, hwrng);
133+
134+
clk_disable_unprepare(qrng->clk);
135+
}
136+
123137
static int qcom_rng_enable(struct qcom_rng *rng)
124138
{
125139
u32 val;
@@ -208,7 +222,9 @@ static int qcom_rng_probe(struct platform_device *pdev)
208222

209223
if (rng->match_data->hwrng_support) {
210224
rng->hwrng.name = "qcom_hwrng";
225+
rng->hwrng.init = qcom_hwrng_init;
211226
rng->hwrng.read = qcom_hwrng_read;
227+
rng->hwrng.cleanup = qcom_hwrng_cleanup;
212228
rng->hwrng.quality = QCOM_TRNG_QUALITY;
213229
ret = devm_hwrng_register(&pdev->dev, &rng->hwrng);
214230
if (ret) {

0 commit comments

Comments
 (0)