mirror of
https://github.com/torvalds/linux.git
synced 2024-11-25 05:32:00 +00:00
rtc: st-lpc: Simplify clk handling in st_rtc_probe()
Use devm_clk_get_enabled() instead of hand writing it. This simplifies error handling and removes some lines of code. Also use dev_err_probe() which filters -EPROBE_DEFER. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Link: https://lore.kernel.org/r/992dd8c31be0bb5b8a9d8b5e8e94807ab0848a66.1686251455.git.christophe.jaillet@wanadoo.fr Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
This commit is contained in:
parent
06c6e1b01d
commit
0e6f36cca1
@ -228,17 +228,13 @@ static int st_rtc_probe(struct platform_device *pdev)
|
|||||||
enable_irq_wake(rtc->irq);
|
enable_irq_wake(rtc->irq);
|
||||||
disable_irq(rtc->irq);
|
disable_irq(rtc->irq);
|
||||||
|
|
||||||
rtc->clk = devm_clk_get(&pdev->dev, NULL);
|
rtc->clk = devm_clk_get_enabled(&pdev->dev, NULL);
|
||||||
if (IS_ERR(rtc->clk)) {
|
if (IS_ERR(rtc->clk))
|
||||||
dev_err(&pdev->dev, "Unable to request clock\n");
|
return dev_err_probe(&pdev->dev, PTR_ERR(rtc->clk),
|
||||||
return PTR_ERR(rtc->clk);
|
"Unable to request clock\n");
|
||||||
}
|
|
||||||
|
|
||||||
clk_prepare_enable(rtc->clk);
|
|
||||||
|
|
||||||
rtc->clkrate = clk_get_rate(rtc->clk);
|
rtc->clkrate = clk_get_rate(rtc->clk);
|
||||||
if (!rtc->clkrate) {
|
if (!rtc->clkrate) {
|
||||||
clk_disable_unprepare(rtc->clk);
|
|
||||||
dev_err(&pdev->dev, "Unable to fetch clock rate\n");
|
dev_err(&pdev->dev, "Unable to fetch clock rate\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
@ -252,10 +248,8 @@ static int st_rtc_probe(struct platform_device *pdev)
|
|||||||
do_div(rtc->rtc_dev->range_max, rtc->clkrate);
|
do_div(rtc->rtc_dev->range_max, rtc->clkrate);
|
||||||
|
|
||||||
ret = devm_rtc_register_device(rtc->rtc_dev);
|
ret = devm_rtc_register_device(rtc->rtc_dev);
|
||||||
if (ret) {
|
if (ret)
|
||||||
clk_disable_unprepare(rtc->clk);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user