[PATCH 03/17] spi: bcmbca-hsspi: Use helper function devm_clk_get_enabled()

Pei Xiao
2026-03-12T23:08:17Z

drivers/spi/spi-bcmbca-hsspi.c | 47 ++++++++++++----------------------
1 file changed, 16 insertions(+), 31 deletions(-)

diff --git a/drivers/spi/spi-bcmbca-hsspi.c b/drivers/spi/spi-bcmbca-hsspi.c
index ece22260f570..08d12606e91d 100644
--- a/drivers/spi/spi-bcmbca-hsspi.c
+++ b/drivers/spi/spi-bcmbca-hsspi.c
@@ -452,39 +452,30 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev)
if (IS_ERR(spim_ctrl))
return PTR_ERR(spim_ctrl);

- clk = devm_clk_get(dev, "hsspi");
+ clk = devm_clk_get_enabled(dev, "hsspi");
if (IS_ERR(clk))
- return PTR_ERR(clk);
-
- ret = clk_prepare_enable(clk);
- if (ret)
- return ret;
+ return dev_err_probe(dev, PTR_ERR(clk),
+ "Failed to get hsspi clock\n");

rate = clk_get_rate(clk);
if (!rate) {
- pll_clk = devm_clk_get(dev, "pll");
+ pll_clk = devm_clk_get_enabled(dev, "pll");

if (IS_ERR(pll_clk)) {
- ret = PTR_ERR(pll_clk);
- goto out_disable_clk;
+ return dev_err_probe(dev, PTR_ERR(pll_clk),
+ "Failed to get pll clock\n");
}

- ret = clk_prepare_enable(pll_clk);
- if (ret)
- goto out_disable_clk;
-
rate = clk_get_rate(pll_clk);
- if (!rate) {
- ret = -EINVAL;
- goto out_disable_pll_clk;
- }
+ if (!rate)
+ return dev_err_probe(dev, -EINVAL,
+ "Failed to get pll clock rate\n");
}

host = devm_spi_alloc_host(&pdev->dev, sizeof(*bs));
- if (!host) {
- ret = -ENOMEM;
- goto out_disable_pll_clk;
- }
+ if (!host)
+ return dev_err_probe(dev, -ENOMEM,
+ "Failed alloc spi host\n");

bs = spi_controller_get_devdata(host);
bs->pdev = pdev;
@@ -535,18 +526,16 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev)
ret = devm_request_irq(dev, irq, bcmbca_hsspi_interrupt, IRQF_SHARED,
pdev->name, bs);
if (ret)
- goto out_disable_pll_clk;
+ return dev_err_probe(dev, ret, "Failed request irq\n");
}

ret = devm_pm_runtime_enable(&pdev->dev);
if (ret)
- goto out_disable_pll_clk;
+ return dev_err_probe(dev, ret, "Failed pm runtime enable\n");

ret = sysfs_create_group(&pdev->dev.kobj, &bcmbca_hsspi_group);
- if (ret) {
- dev_err(&pdev->dev, "couldn't register sysfs group\n");
- goto out_disable_pll_clk;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "couldn't register sysfs group\n");

/* register and we are done */
ret = devm_spi_register_controller(dev, host);
@@ -559,10 +548,6 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev)

out_sysgroup_disable:
sysfs_remove_group(&pdev->dev.kobj, &bcmbca_hsspi_group);
-out_disable_pll_clk:
- clk_disable_unprepare(pll_clk);
-out_disable_clk:
- clk_disable_unprepare(clk);
return ret;
}

--
2.25.1