Skip to contentSkip to conversation

mailbox: imx: Disable the clock on devm_mbox_controller_register() failure

PATCH In review Fabio Estevam 3 participants 3 messages May 20, 2020

Subsystems (2)
lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH 1/1 mailbox: imx: Disable the clock on devm_mbox_controller_register() failure

devm_mbox_controller_register() may fail, and in the case of failure the priv->clk clock that was previously enabled, should be disabled.

Fixes 2bb7005696e2 ("mailbox: Add support for i.MX messaging unit")
---
 drivers/mailbox/imx-mailbox.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/mailbox/imx-mailbox.c +7 -1
index 7906624a731c..3f7c4548c18f 100644
@@ -508,7 +508,13 @@ static int imx_mu_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, priv);
 
-	return devm_mbox_controller_register(dev, &priv->mbox);
+	ret = devm_mbox_controller_register(dev, &priv->mbox);
+	if (ret) {
+		clk_disable_unprepare(priv->clk);
+		return ret;
+	}
+
+	return 0;
 }
 
 static int imx_mu_remove(struct platform_device *pdev)
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines

Subject: [PATCH] mailbox: imx: Disable the clock on devm_mbox_controller_register() failure

devm_mbox_controller_register() may fail, and in the case of failure the priv->clk clock that was previously enabled, should be disabled.

Fixes 2bb7005696e2 ("mailbox: Add support for i.MX messaging unit")
Quoted 26 lines
---
 drivers/mailbox/imx-mailbox.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/mailbox/imx-mailbox.c +7 -1
index 7906624a731c..3f7c4548c18f 100644
@@ -508,7 +508,13 @@ static int imx_mu_probe(struct platform_device
 *pdev)
 
 	platform_set_drvdata(pdev, priv);
 
-	return devm_mbox_controller_register(dev, &priv->mbox);
+	ret = devm_mbox_controller_register(dev, &priv->mbox);
+	if (ret) {
+		clk_disable_unprepare(priv->clk);
+		return ret;
+	}
+
+	return 0;
 }
 

static int imx_mu_remove(struct platform_device *pdev)
--
2.17.1

Acked-by on v1 1/1
#2 lore raw
In reply to Fabio Estevam
Quoted 5 lines · Fabio Estevam

devm_mbox_controller_register() may fail, and in the case of failure the priv->clk clock that was previously enabled, should be disabled.

Fixes 2bb7005696e2 ("mailbox: Add support for i.MX messaging unit")
Quoted 27 lines
---
 drivers/mailbox/imx-mailbox.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/mailbox/imx-mailbox.c +7 -1
index 7906624a731c..3f7c4548c18f 100644
@@ -508,7 +508,13 @@ static int imx_mu_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, priv);
 
-	return devm_mbox_controller_register(dev, &priv->mbox);
+	ret = devm_mbox_controller_register(dev, &priv->mbox);
+	if (ret) {
+		clk_disable_unprepare(priv->clk);
+		return ret;
+	}
+
+	return 0;
 }
 
 static int imx_mu_remove(struct platform_device *pdev)
Signature · 1 line
2.17.1
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |