Commit 7863bd07 authored by Anson Huang's avatar Anson Huang Committed by Alexandre Belloni

rtc: snvs: Use devm_add_action_or_reset() for calls to clk_disable_unprepare()

Use devm_add_action_or_reset() for calls to clk_disable_unprepare(),
which can simplify the error handling.
Signed-off-by: default avatarAnson Huang <Anson.Huang@nxp.com>
Link: https://lore.kernel.org/r/1584109849-21402-1-git-send-email-Anson.Huang@nxp.com
Link: https://lore.kernel.org/r/1584233264-26025-1-git-send-email-Anson.Huang@nxp.comSigned-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
parent 21cbe810
...@@ -263,6 +263,12 @@ static const struct regmap_config snvs_rtc_config = { ...@@ -263,6 +263,12 @@ static const struct regmap_config snvs_rtc_config = {
.reg_stride = 4, .reg_stride = 4,
}; };
static void snvs_rtc_action(void *data)
{
if (data)
clk_disable_unprepare(data);
}
static int snvs_rtc_probe(struct platform_device *pdev) static int snvs_rtc_probe(struct platform_device *pdev)
{ {
struct snvs_rtc_data *data; struct snvs_rtc_data *data;
...@@ -313,6 +319,10 @@ static int snvs_rtc_probe(struct platform_device *pdev) ...@@ -313,6 +319,10 @@ static int snvs_rtc_probe(struct platform_device *pdev)
} }
} }
ret = devm_add_action_or_reset(&pdev->dev, snvs_rtc_action, data->clk);
if (ret)
return ret;
platform_set_drvdata(pdev, data); platform_set_drvdata(pdev, data);
/* Initialize glitch detect */ /* Initialize glitch detect */
...@@ -325,7 +335,7 @@ static int snvs_rtc_probe(struct platform_device *pdev) ...@@ -325,7 +335,7 @@ static int snvs_rtc_probe(struct platform_device *pdev)
ret = snvs_rtc_enable(data, true); ret = snvs_rtc_enable(data, true);
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to enable rtc %d\n", ret); dev_err(&pdev->dev, "failed to enable rtc %d\n", ret);
goto error_rtc_device_register; return ret;
} }
device_init_wakeup(&pdev->dev, true); device_init_wakeup(&pdev->dev, true);
...@@ -338,24 +348,13 @@ static int snvs_rtc_probe(struct platform_device *pdev) ...@@ -338,24 +348,13 @@ static int snvs_rtc_probe(struct platform_device *pdev)
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to request irq %d: %d\n", dev_err(&pdev->dev, "failed to request irq %d: %d\n",
data->irq, ret); data->irq, ret);
goto error_rtc_device_register; return ret;
} }
data->rtc->ops = &snvs_rtc_ops; data->rtc->ops = &snvs_rtc_ops;
data->rtc->range_max = U32_MAX; data->rtc->range_max = U32_MAX;
ret = rtc_register_device(data->rtc);
if (ret) {
dev_err(&pdev->dev, "failed to register rtc: %d\n", ret);
goto error_rtc_device_register;
}
return 0;
error_rtc_device_register: return rtc_register_device(data->rtc);
if (data->clk)
clk_disable_unprepare(data->clk);
return ret;
} }
static int __maybe_unused snvs_rtc_suspend_noirq(struct device *dev) static int __maybe_unused snvs_rtc_suspend_noirq(struct device *dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment