Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

spi: sunplus-sp7021: Simplify clock handling with devm_clk_get_enabled()

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>

authored by

Pei Xiao and committed by
Mark Brown
ea0e916d 7da63780

+1 -14
+1 -14
drivers/spi/spi-sunplus-sp7021.c
··· 389 389 return ret; 390 390 } 391 391 392 - static void sp7021_spi_disable_unprepare(void *data) 393 - { 394 - clk_disable_unprepare(data); 395 - } 396 - 397 392 static void sp7021_spi_reset_control_assert(void *data) 398 393 { 399 394 reset_control_assert(data); ··· 455 460 if (pspim->s_irq < 0) 456 461 return pspim->s_irq; 457 462 458 - pspim->spi_clk = devm_clk_get(dev, NULL); 463 + pspim->spi_clk = devm_clk_get_enabled(dev, NULL); 459 464 if (IS_ERR(pspim->spi_clk)) 460 465 return dev_err_probe(dev, PTR_ERR(pspim->spi_clk), "clk get fail\n"); 461 466 462 467 pspim->rstc = devm_reset_control_get_exclusive(dev, NULL); 463 468 if (IS_ERR(pspim->rstc)) 464 469 return dev_err_probe(dev, PTR_ERR(pspim->rstc), "rst get fail\n"); 465 - 466 - ret = clk_prepare_enable(pspim->spi_clk); 467 - if (ret) 468 - return dev_err_probe(dev, ret, "failed to enable clk\n"); 469 - 470 - ret = devm_add_action_or_reset(dev, sp7021_spi_disable_unprepare, pspim->spi_clk); 471 - if (ret) 472 - return ret; 473 470 474 471 ret = reset_control_deassert(pspim->rstc); 475 472 if (ret)