Skip to content

Commit 24fb316

Browse files
tititiou36alexandrebelloni
authored andcommitted
rtc: mpfs: 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(). That said, mpfs_rtc_init_clk() is the same as devm_clk_get_enabled(), so use this function directly instead. This also fixes an (unlikely) unchecked devm_add_action_or_reset() error. Based on my test with allyesconfig, this reduces the .o size from: text data bss dec hex filename 5330 2208 0 7538 1d72 drivers/rtc/rtc-mpfs.o down to: 5074 2208 0 7282 1c72 drivers/rtc/rtc-mpfs.o Signed-off-by: Christophe JAILLET <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/e55c959f2821a2c367a4c5de529a638b1cc6b8cd.1661329086.git.christophe.jaillet@wanadoo.fr Signed-off-by: Alexandre Belloni <[email protected]>
1 parent d73d66c commit 24fb316

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

drivers/rtc/rtc-mpfs.c

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -193,23 +193,6 @@ static int mpfs_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
193193
return 0;
194194
}
195195

196-
static inline struct clk *mpfs_rtc_init_clk(struct device *dev)
197-
{
198-
struct clk *clk;
199-
int ret;
200-
201-
clk = devm_clk_get(dev, "rtc");
202-
if (IS_ERR(clk))
203-
return clk;
204-
205-
ret = clk_prepare_enable(clk);
206-
if (ret)
207-
return ERR_PTR(ret);
208-
209-
devm_add_action_or_reset(dev, (void (*) (void *))clk_disable_unprepare, clk);
210-
return clk;
211-
}
212-
213196
static irqreturn_t mpfs_rtc_wakeup_irq_handler(int irq, void *dev)
214197
{
215198
struct mpfs_rtc_dev *rtcdev = dev;
@@ -251,7 +234,7 @@ static int mpfs_rtc_probe(struct platform_device *pdev)
251234
/* range is capped by alarm max, lower reg is 31:0 & upper is 10:0 */
252235
rtcdev->rtc->range_max = GENMASK_ULL(42, 0);
253236

254-
clk = mpfs_rtc_init_clk(&pdev->dev);
237+
clk = devm_clk_get_enabled(&pdev->dev, "rtc");
255238
if (IS_ERR(clk))
256239
return PTR_ERR(clk);
257240

0 commit comments

Comments
 (0)