Skip to content

Commit 349112b

Browse files
Li Zetaobroonie
authored andcommitted
spi: dw-mmio: Use helper function devm_clk_get_*()
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. Also, devm_clk_get_optional() and clk_prepare_enable() can now be replaced by devm_clk_get_optional_enabled(). Moreover, the lable "out_clk" no longer makes sense, rename it to "out_reset". Signed-off-by: Li Zetao <lizetao1@huawei.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Acked-by: Serge Semin <fancer.lancer@gmail.com> Link: https://lore.kernel.org/r/20230823133938.1359106-13-lizetao1@huawei.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 10c3937 commit 349112b

1 file changed

Lines changed: 9 additions & 22 deletions

File tree

drivers/spi/spi-dw-mmio.c

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -340,29 +340,20 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
340340
if (dws->irq < 0)
341341
return dws->irq; /* -ENXIO */
342342

343-
dwsmmio->clk = devm_clk_get(&pdev->dev, NULL);
343+
dwsmmio->clk = devm_clk_get_enabled(&pdev->dev, NULL);
344344
if (IS_ERR(dwsmmio->clk))
345345
return PTR_ERR(dwsmmio->clk);
346-
ret = clk_prepare_enable(dwsmmio->clk);
347-
if (ret)
348-
return ret;
349346

350347
/* Optional clock needed to access the registers */
351-
dwsmmio->pclk = devm_clk_get_optional(&pdev->dev, "pclk");
352-
if (IS_ERR(dwsmmio->pclk)) {
353-
ret = PTR_ERR(dwsmmio->pclk);
354-
goto out_clk;
355-
}
356-
ret = clk_prepare_enable(dwsmmio->pclk);
357-
if (ret)
358-
goto out_clk;
348+
dwsmmio->pclk = devm_clk_get_optional_enabled(&pdev->dev, "pclk");
349+
if (IS_ERR(dwsmmio->pclk))
350+
return PTR_ERR(dwsmmio->pclk);
359351

360352
/* find an optional reset controller */
361353
dwsmmio->rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, "spi");
362-
if (IS_ERR(dwsmmio->rstc)) {
363-
ret = PTR_ERR(dwsmmio->rstc);
364-
goto out_clk;
365-
}
354+
if (IS_ERR(dwsmmio->rstc))
355+
return PTR_ERR(dwsmmio->rstc);
356+
366357
reset_control_deassert(dwsmmio->rstc);
367358

368359
dws->bus_num = pdev->id;
@@ -383,7 +374,7 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
383374
if (init_func) {
384375
ret = init_func(pdev, dwsmmio);
385376
if (ret)
386-
goto out;
377+
goto out_reset;
387378
}
388379

389380
pm_runtime_enable(&pdev->dev);
@@ -397,9 +388,7 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
397388

398389
out:
399390
pm_runtime_disable(&pdev->dev);
400-
clk_disable_unprepare(dwsmmio->pclk);
401-
out_clk:
402-
clk_disable_unprepare(dwsmmio->clk);
391+
out_reset:
403392
reset_control_assert(dwsmmio->rstc);
404393

405394
return ret;
@@ -411,8 +400,6 @@ static void dw_spi_mmio_remove(struct platform_device *pdev)
411400

412401
dw_spi_remove_host(&dwsmmio->dws);
413402
pm_runtime_disable(&pdev->dev);
414-
clk_disable_unprepare(dwsmmio->pclk);
415-
clk_disable_unprepare(dwsmmio->clk);
416403
reset_control_assert(dwsmmio->rstc);
417404
}
418405

0 commit comments

Comments
 (0)