diff mbox series

[-next,RESEND] mfd: mxs-lradc: Use the devm_clk_get_enabled() helper function

Message ID 20230821114719.3002483-1-ruanjinjie@huawei.com (mailing list archive)
State New, archived
Headers show
Series [-next,RESEND] mfd: mxs-lradc: Use the devm_clk_get_enabled() helper function | expand

Commit Message

Jinjie Ruan Aug. 21, 2023, 11:47 a.m. UTC
With devm_clk_get_enabled() the call to clk_disable_unprepare() can be
dropped from the error path and the remove callback.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 drivers/mfd/mxs-lradc.c | 35 ++++++++---------------------------
 1 file changed, 8 insertions(+), 27 deletions(-)
diff mbox series

Patch

diff --git a/drivers/mfd/mxs-lradc.c b/drivers/mfd/mxs-lradc.c
index 21f3033d6eb5..62d669ce1f7f 100644
--- a/drivers/mfd/mxs-lradc.c
+++ b/drivers/mfd/mxs-lradc.c
@@ -144,16 +144,10 @@  static int mxs_lradc_probe(struct platform_device *pdev)
 
 	lradc->soc = (uintptr_t)of_id->data;
 
-	lradc->clk = devm_clk_get(&pdev->dev, NULL);
+	lradc->clk = devm_clk_get_enabled(&pdev->dev, NULL);
 	if (IS_ERR(lradc->clk)) {
-		dev_err(dev, "Failed to get the delay unit clock\n");
-		return PTR_ERR(lradc->clk);
-	}
-
-	ret = clk_prepare_enable(lradc->clk);
-	if (ret) {
 		dev_err(dev, "Failed to enable the delay unit clock\n");
-		return ret;
+		return PTR_ERR(lradc->clk);
 	}
 
 	ret = of_property_read_u32(node, "fsl,lradc-touchscreen-wires",
@@ -177,8 +171,7 @@  static int mxs_lradc_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev,
 				"Unsupported number of touchscreen wires (%d)\n"
 				, ts_wires);
-			ret = -EINVAL;
-			goto err_clk;
+			return -EINVAL;
 		}
 	} else {
 		lradc->buffer_vchans = BUFFER_VCHANS_ALL;
@@ -187,10 +180,8 @@  static int mxs_lradc_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, lradc);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		ret = -ENOMEM;
-		goto err_clk;
-	}
+	if (!res)
+		return -ENOMEM;
 
 	switch (lradc->soc) {
 	case IMX23_LRADC:
@@ -205,15 +196,14 @@  static int mxs_lradc_probe(struct platform_device *pdev)
 		break;
 	default:
 		dev_err(dev, "Unsupported SoC\n");
-		ret = -ENODEV;
-		goto err_clk;
+		return -ENODEV;
 	}
 
 	ret = devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE,
 				   &cells[ADC_CELL], 1, NULL, 0, NULL);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to add the ADC subdevice\n");
-		goto err_clk;
+		return ret;
 	}
 
 	if (!lradc->touchscreen_wire)
@@ -224,23 +214,14 @@  static int mxs_lradc_probe(struct platform_device *pdev)
 	if (ret) {
 		dev_err(&pdev->dev,
 			"Failed to add the touchscreen subdevice\n");
-		goto err_clk;
+		return ret;
 	}
 
 	return 0;
-
-err_clk:
-	clk_disable_unprepare(lradc->clk);
-
-	return ret;
 }
 
 static int mxs_lradc_remove(struct platform_device *pdev)
 {
-	struct mxs_lradc *lradc = platform_get_drvdata(pdev);
-
-	clk_disable_unprepare(lradc->clk);
-
 	return 0;
 }