Skip to content

Commit 25bcfaa

Browse files
tititiou36alexandrebelloni
authored andcommitted
rtc: mxc: Use devm_clk_get_enabled() helper
The devm_clk_get_enabled() helper: - calls devm_clk_get() - calls clk_prepare_enable() and registers what is needed in order to call clk_disable_unprepare() when needed, as a managed resource. This simplifies the code, the error handling paths and avoid the need of a dedicated function used with devm_add_action_or_reset(). Based on my test with allyesconfig, this reduces the .o size from: text data bss dec hex filename 6705 1968 0 8673 21e1 drivers/rtc/rtc-mxc.o down to: 6212 1968 0 8180 1ff4 drivers/rtc/rtc-mxc.o Signed-off-by: Christophe JAILLET <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]> Link: https://lore.kernel.org/r/1b5ad1877304b01ddbba73ca615274a52f781aa2.1660582728.git.christophe.jaillet@wanadoo.fr
1 parent 509451a commit 25bcfaa

File tree

1 file changed

+2
-25
lines changed

1 file changed

+2
-25
lines changed

drivers/rtc/rtc-mxc.c

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,6 @@ static const struct rtc_class_ops mxc_rtc_ops = {
291291
.alarm_irq_enable = mxc_rtc_alarm_irq_enable,
292292
};
293293

294-
static void mxc_rtc_action(void *p)
295-
{
296-
struct rtc_plat_data *pdata = p;
297-
298-
clk_disable_unprepare(pdata->clk_ref);
299-
clk_disable_unprepare(pdata->clk_ipg);
300-
}
301-
302294
static int mxc_rtc_probe(struct platform_device *pdev)
303295
{
304296
struct rtc_device *rtc;
@@ -341,33 +333,18 @@ static int mxc_rtc_probe(struct platform_device *pdev)
341333
rtc->range_max = (1 << 16) * 86400ULL - 1;
342334
}
343335

344-
pdata->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
336+
pdata->clk_ipg = devm_clk_get_enabled(&pdev->dev, "ipg");
345337
if (IS_ERR(pdata->clk_ipg)) {
346338
dev_err(&pdev->dev, "unable to get ipg clock!\n");
347339
return PTR_ERR(pdata->clk_ipg);
348340
}
349341

350-
ret = clk_prepare_enable(pdata->clk_ipg);
351-
if (ret)
352-
return ret;
353-
354-
pdata->clk_ref = devm_clk_get(&pdev->dev, "ref");
342+
pdata->clk_ref = devm_clk_get_enabled(&pdev->dev, "ref");
355343
if (IS_ERR(pdata->clk_ref)) {
356-
clk_disable_unprepare(pdata->clk_ipg);
357344
dev_err(&pdev->dev, "unable to get ref clock!\n");
358345
return PTR_ERR(pdata->clk_ref);
359346
}
360347

361-
ret = clk_prepare_enable(pdata->clk_ref);
362-
if (ret) {
363-
clk_disable_unprepare(pdata->clk_ipg);
364-
return ret;
365-
}
366-
367-
ret = devm_add_action_or_reset(&pdev->dev, mxc_rtc_action, pdata);
368-
if (ret)
369-
return ret;
370-
371348
rate = clk_get_rate(pdata->clk_ref);
372349

373350
if (rate == 32768)

0 commit comments

Comments
 (0)