spi: dw-bt1: Use helper function devm_clk_get_enabled()

Since commit 7ef9651e97 ("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>
Acked-by: Serge Semin <fancer.lancer@gmail.com>
Signed-off-by: Li Zetao <lizetao1@huawei.com>
Link: https://lore.kernel.org/r/20230823133938.1359106-12-lizetao1@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Li Zetao 2023-08-23 21:39:24 +08:00 committed by Mark Brown
parent 9dc2aa96a3
commit 10c3937890
No known key found for this signature in database
GPG key ID: 24D68B725D5487D0

View file

@ -269,43 +269,32 @@ static int dw_spi_bt1_probe(struct platform_device *pdev)
dws->paddr = mem->start;
dwsbt1->clk = devm_clk_get(&pdev->dev, NULL);
dwsbt1->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(dwsbt1->clk))
return PTR_ERR(dwsbt1->clk);
ret = clk_prepare_enable(dwsbt1->clk);
if (ret)
return ret;
dws->bus_num = pdev->id;
dws->reg_io_width = 4;
dws->max_freq = clk_get_rate(dwsbt1->clk);
if (!dws->max_freq) {
ret = -EINVAL;
goto err_disable_clk;
}
if (!dws->max_freq)
return -EINVAL;
init_func = device_get_match_data(&pdev->dev);
ret = init_func(pdev, dwsbt1);
if (ret)
goto err_disable_clk;
return ret;
pm_runtime_enable(&pdev->dev);
ret = dw_spi_add_host(&pdev->dev, dws);
if (ret) {
pm_runtime_disable(&pdev->dev);
goto err_disable_clk;
return ret;
}
platform_set_drvdata(pdev, dwsbt1);
return 0;
err_disable_clk:
clk_disable_unprepare(dwsbt1->clk);
return ret;
}
static void dw_spi_bt1_remove(struct platform_device *pdev)
@ -315,8 +304,6 @@ static void dw_spi_bt1_remove(struct platform_device *pdev)
dw_spi_remove_host(&dwsbt1->dws);
pm_runtime_disable(&pdev->dev);
clk_disable_unprepare(dwsbt1->clk);
}
static const struct of_device_id dw_spi_bt1_of_match[] = {