Skip to content

Commit 4812bc3

Browse files
Li Zetaobroonie
authored andcommitted
spi: spi-fsl-dspi: 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. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Li Zetao <lizetao1@huawei.com> Link: https://lore.kernel.org/r/20230823133938.1359106-14-lizetao1@huawei.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 349112b commit 4812bc3

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

drivers/spi/spi-fsl-dspi.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,19 +1372,16 @@ static int dspi_probe(struct platform_device *pdev)
13721372
}
13731373
}
13741374

1375-
dspi->clk = devm_clk_get(&pdev->dev, "dspi");
1375+
dspi->clk = devm_clk_get_enabled(&pdev->dev, "dspi");
13761376
if (IS_ERR(dspi->clk)) {
13771377
ret = PTR_ERR(dspi->clk);
13781378
dev_err(&pdev->dev, "unable to get clock\n");
13791379
goto out_ctlr_put;
13801380
}
1381-
ret = clk_prepare_enable(dspi->clk);
1382-
if (ret)
1383-
goto out_ctlr_put;
13841381

13851382
ret = dspi_init(dspi);
13861383
if (ret)
1387-
goto out_clk_put;
1384+
goto out_ctlr_put;
13881385

13891386
dspi->irq = platform_get_irq(pdev, 0);
13901387
if (dspi->irq <= 0) {
@@ -1400,7 +1397,7 @@ static int dspi_probe(struct platform_device *pdev)
14001397
IRQF_SHARED, pdev->name, dspi);
14011398
if (ret < 0) {
14021399
dev_err(&pdev->dev, "Unable to attach DSPI interrupt\n");
1403-
goto out_clk_put;
1400+
goto out_ctlr_put;
14041401
}
14051402

14061403
poll_mode:
@@ -1432,8 +1429,6 @@ static int dspi_probe(struct platform_device *pdev)
14321429
out_free_irq:
14331430
if (dspi->irq)
14341431
free_irq(dspi->irq, dspi);
1435-
out_clk_put:
1436-
clk_disable_unprepare(dspi->clk);
14371432
out_ctlr_put:
14381433
spi_controller_put(ctlr);
14391434

@@ -1458,7 +1453,6 @@ static void dspi_remove(struct platform_device *pdev)
14581453
dspi_release_dma(dspi);
14591454
if (dspi->irq)
14601455
free_irq(dspi->irq, dspi);
1461-
clk_disable_unprepare(dspi->clk);
14621456
}
14631457

14641458
static void dspi_shutdown(struct platform_device *pdev)

0 commit comments

Comments
 (0)