[PATCH] crypto: jh7110-cryp: handle clock enable failures

Jiawen Liu posted 1 patch 1 month, 1 week ago
[PATCH] crypto: jh7110-cryp: handle clock enable failures
Posted by Jiawen Liu 1 month, 1 week ago
Return error from failed clock enable.

starfive_cryp_probe ignores clk_prepare_enable return for hclk/ahb, then
remove/error paths unconditionally clk_disable_unprepare both clocks.

Check consecutive clk_prepare_enable(cryp->hclk)/cryp->ahb returns in
starfive_cryp_probe.

Signed-off-by: jiawen <1298662399@qq.com>
---
diff --git a/drivers/crypto/starfive/jh7110-cryp.c b/drivers/crypto/starfive/jh7110-cryp.c
--- a/drivers/crypto/starfive/jh7110-cryp.c
+++ b/drivers/crypto/starfive/jh7110-cryp.c
@@ -120,8 +120,15 @@
 		return dev_err_probe(&pdev->dev, PTR_ERR(cryp->rst),
 				     "Error getting hardware reset line\n");
 
-	clk_prepare_enable(cryp->hclk);
-	clk_prepare_enable(cryp->ahb);
+	ret = clk_prepare_enable(cryp->hclk);
+	if (ret)
+		return ret;
+
+	ret = clk_prepare_enable(cryp->ahb);
+	if (ret) {
+		clk_disable_unprepare(cryp->hclk);
+		return ret;
+	}
 	reset_control_deassert(cryp->rst);
 
 	spin_lock(&dev_list.lock);
Re: [PATCH] crypto: jh7110-cryp: handle clock enable failures
Posted by Herbert Xu 3 weeks, 3 days ago
Jiawen Liu <1298662399@qq.com> wrote:
> Return error from failed clock enable.
> 
> starfive_cryp_probe ignores clk_prepare_enable return for hclk/ahb, then
> remove/error paths unconditionally clk_disable_unprepare both clocks.
> 
> Check consecutive clk_prepare_enable(cryp->hclk)/cryp->ahb returns in
> starfive_cryp_probe.
> 
> Signed-off-by: jiawen <1298662399@qq.com>

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Re: [PATCH] crypto: jh7110-cryp: handle clock enable failures
Posted by Markus Elfring 1 month, 1 week ago
…
> Check consecutive clk_prepare_enable(cryp->hclk)/cryp->ahb returns in
> starfive_cryp_probe.

I find such a wording approach improvable.
How do you think about to add any tags (like “Fixes” and “Cc”) accordingly?

See also once more:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/stable-kernel-rules.rst?h=v7.2#n34
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.2#n145
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.2#n792

Regards,
Markus