Skip to content

Commit c45fd12

Browse files
Li Zetaobroonie
authored andcommitted
spi: spi-meson-spifc: Use helper function devm_clk_get_enabled()
Since commit 7ef9651 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), devm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables (and possibly prepares) the clocks for the whole lifetime of the device. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly. Moreover, the lable "out_clk" no longer makes sense, rename it to "out_pm". Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Li Zetao <lizetao1@huawei.com> Link: https://lore.kernel.org/r/20230823133938.1359106-17-lizetao1@huawei.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 7ef5110 commit c45fd12

1 file changed

Lines changed: 3 additions & 14 deletions

File tree

drivers/spi/spi-meson-spifc.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -312,19 +312,13 @@ static int meson_spifc_probe(struct platform_device *pdev)
312312
goto out_err;
313313
}
314314

315-
spifc->clk = devm_clk_get(spifc->dev, NULL);
315+
spifc->clk = devm_clk_get_enabled(spifc->dev, NULL);
316316
if (IS_ERR(spifc->clk)) {
317317
dev_err(spifc->dev, "missing clock\n");
318318
ret = PTR_ERR(spifc->clk);
319319
goto out_err;
320320
}
321321

322-
ret = clk_prepare_enable(spifc->clk);
323-
if (ret) {
324-
dev_err(spifc->dev, "can't prepare clock\n");
325-
goto out_err;
326-
}
327-
328322
rate = clk_get_rate(spifc->clk);
329323

330324
master->num_chipselect = 1;
@@ -343,12 +337,11 @@ static int meson_spifc_probe(struct platform_device *pdev)
343337
ret = devm_spi_register_master(spifc->dev, master);
344338
if (ret) {
345339
dev_err(spifc->dev, "failed to register spi master\n");
346-
goto out_clk;
340+
goto out_pm;
347341
}
348342

349343
return 0;
350-
out_clk:
351-
clk_disable_unprepare(spifc->clk);
344+
out_pm:
352345
pm_runtime_disable(spifc->dev);
353346
out_err:
354347
spi_master_put(master);
@@ -357,11 +350,7 @@ static int meson_spifc_probe(struct platform_device *pdev)
357350

358351
static void meson_spifc_remove(struct platform_device *pdev)
359352
{
360-
struct spi_master *master = platform_get_drvdata(pdev);
361-
struct meson_spifc *spifc = spi_master_get_devdata(master);
362-
363353
pm_runtime_get_sync(&pdev->dev);
364-
clk_disable_unprepare(spifc->clk);
365354
pm_runtime_disable(&pdev->dev);
366355
}
367356

0 commit comments

Comments
 (0)