]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
spi: sunplus-sp7021: Simplify clock handling with devm_clk_get_enabled()
authorPei Xiao <xiaopei01@kylinos.cn>
Thu, 19 Mar 2026 02:04:10 +0000 (10:04 +0800)
committerMark Brown <broonie@kernel.org>
Mon, 23 Mar 2026 19:47:43 +0000 (19:47 +0000)
Replace devm_clk_get() followed by clk_prepare_enable() with
devm_clk_get_enabled() for the clock. This removes the need for
explicit clock enable/disable calls and the custom cleanup function,
as the managed API automatically handles clock disabling on device
removal or probe failure.

Remove the now-unnecessary sp7021_spi_disable_unprepare() function
and the devm_add_action_or_reset() call.

Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
Link: https://patch.msgid.link/fb0bc46107975cfff4eefa9ba96fe7545996ae52.1773885292.git.xiaopei01@kylinos.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-sunplus-sp7021.c

index 789b092fe8c071a12ae0061cc753447c358056a0..35601212fb78fe528c844acf0ec939cb06a18b49 100644 (file)
@@ -389,11 +389,6 @@ static int sp7021_spi_target_transfer_one(struct spi_controller *ctlr, struct sp
        return ret;
 }
 
-static void sp7021_spi_disable_unprepare(void *data)
-{
-       clk_disable_unprepare(data);
-}
-
 static void sp7021_spi_reset_control_assert(void *data)
 {
        reset_control_assert(data);
@@ -460,7 +455,7 @@ static int sp7021_spi_controller_probe(struct platform_device *pdev)
        if (pspim->s_irq < 0)
                return pspim->s_irq;
 
-       pspim->spi_clk = devm_clk_get(dev, NULL);
+       pspim->spi_clk = devm_clk_get_enabled(dev, NULL);
        if (IS_ERR(pspim->spi_clk))
                return dev_err_probe(dev, PTR_ERR(pspim->spi_clk), "clk get fail\n");
 
@@ -468,14 +463,6 @@ static int sp7021_spi_controller_probe(struct platform_device *pdev)
        if (IS_ERR(pspim->rstc))
                return dev_err_probe(dev, PTR_ERR(pspim->rstc), "rst get fail\n");
 
-       ret = clk_prepare_enable(pspim->spi_clk);
-       if (ret)
-               return dev_err_probe(dev, ret, "failed to enable clk\n");
-
-       ret = devm_add_action_or_reset(dev, sp7021_spi_disable_unprepare, pspim->spi_clk);
-       if (ret)
-               return ret;
-
        ret = reset_control_deassert(pspim->rstc);
        if (ret)
                return dev_err_probe(dev, ret, "failed to deassert reset\n");