[PATCH -next] mfd: mxs-lradc: Use the devm_clk_get_enabled() helper function
Ruan Jinjie
ruanjinjie at huawei.com
Fri Aug 18 02:33:08 PDT 2023
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: Ruan Jinjie <ruanjinjie at huawei.com>
---
drivers/mfd/mxs-lradc.c | 35 ++++++++---------------------------
1 file changed, 8 insertions(+), 27 deletions(-)
diff --git a/drivers/mfd/mxs-lradc.c b/drivers/mfd/mxs-lradc.c
index 111d11fd25aa..6d6d417bad5a 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 = (enum mxs_lradc_id)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;
}
--
2.34.1
More information about the linux-arm-kernel
mailing list