Skip to contentSkip to conversation

ASoC: codecs: Use devm_clk_get_enabled() helpers

PATCH In review ying zuxin 3 participants 3 messages Sep 6, 2024

Subsystems (3)
lore
Share & tools
lore

ying zuxin

author
#0 lore raw

PATCH 1/1 ASoC: codecs: Use devm_clk_get_enabled() helpers

From: ying zuxin <[email protected]>

The devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to call clk_disable_unprepare() when needed, as a managed resource.

This simplifies the code and avoids the calls to clk_disable_unprepare().

---
 sound/soc/codecs/peb2466.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
sound/soc/codecs/peb2466.c +1 -13
index 76ee7e3f4d9b..b67cfad4fc32 100644
@@ -1975,12 +1975,9 @@ static int peb2466_spi_probe(struct spi_device *spi)
 	if (IS_ERR(peb2466->reset_gpio))
 		return PTR_ERR(peb2466->reset_gpio);
 
-	peb2466->mclk = devm_clk_get(&peb2466->spi->dev, "mclk");
+	peb2466->mclk = devm_clk_get_enabled(&peb2466->spi->dev, "mclk");
 	if (IS_ERR(peb2466->mclk))
 		return PTR_ERR(peb2466->mclk);
-	ret = clk_prepare_enable(peb2466->mclk);
-	if (ret)
-		return ret;
 
 	if (peb2466->reset_gpio) {
 		gpiod_set_value_cansleep(peb2466->reset_gpio, 1);
@@ -2031,17 +2028,9 @@ static int peb2466_spi_probe(struct spi_device *spi)
 	return 0;
 
 failed:
-	clk_disable_unprepare(peb2466->mclk);
 	return ret;
 }
 
-static void peb2466_spi_remove(struct spi_device *spi)
-{
-	struct peb2466 *peb2466 = spi_get_drvdata(spi);
-
-	clk_disable_unprepare(peb2466->mclk);
-}
-
 static const struct of_device_id peb2466_of_match[] = {
 	{ .compatible = "infineon,peb2466", },
 	{ }
@@ -2061,7 +2050,6 @@ static struct spi_driver peb2466_spi_driver = {
 	},
 	.id_table = peb2466_id_table,
 	.probe  = peb2466_spi_probe,
-	.remove = peb2466_spi_remove,
 };
 
 module_spi_driver(peb2466_spi_driver);
Signature · 1 line
2.39.0
#1 lore raw

Le 06/09/2024 à 10:48, ying zuxin a écrit :

Quoted 33 lines

From: ying zuxin <[email protected]>

The devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to call clk_disable_unprepare() when needed, as a managed resource.

This simplifies the code and avoids the calls to clk_disable_unprepare().

---
  sound/soc/codecs/peb2466.c | 14 +-------------
  1 file changed, 1 insertion(+), 13 deletions(-)
sound/soc/codecs/peb2466.c +1 -4
index 76ee7e3f4d9b..b67cfad4fc32 100644
@@ -1975,12 +1975,9 @@ static int peb2466_spi_probe(struct spi_device *spi)
  	if (IS_ERR(peb2466->reset_gpio))
  		return PTR_ERR(peb2466->reset_gpio);
 
-	peb2466->mclk = devm_clk_get(&peb2466->spi->dev, "mclk");
+	peb2466->mclk = devm_clk_get_enabled(&peb2466->spi->dev, "mclk");
  	if (IS_ERR(peb2466->mclk))
  		return PTR_ERR(peb2466->mclk);
-	ret = clk_prepare_enable(peb2466->mclk);
-	if (ret)
-		return ret;
 
  	if (peb2466->reset_gpio) {
  		gpiod_set_value_cansleep(peb2466->reset_gpio, 1);

sound/soc/codecs/peb2466.c static int peb2466_spi_probe(struct spi_device *spi) · line 2031

Quoted 5 lines
sound/soc/codecs/peb2466.c +0 -1
@@ -2031,17 +2028,9 @@ static int peb2466_spi_probe(struct spi_device *spi)
  	return 0;
 
  failed:
-	clk_disable_unprepare(peb2466->mclk);
  	return ret;

Hi,

so the 'failed' label is now mostly useless and direct returns could be used instead.

CJ

Quoted 20 lines
sound/soc/codecs/peb2466.c +0 -8
  }
 
-static void peb2466_spi_remove(struct spi_device *spi)
-{
-	struct peb2466 *peb2466 = spi_get_drvdata(spi);
-
-	clk_disable_unprepare(peb2466->mclk);
-}
-
  static const struct of_device_id peb2466_of_match[] = {
  	{ .compatible = "infineon,peb2466", },
  	{ }
@@ -2061,7 +2050,6 @@ static struct spi_driver peb2466_spi_driver = {
  	},
  	.id_table = peb2466_id_table,
  	.probe  = peb2466_spi_probe,
-	.remove = peb2466_spi_remove,
  };
 
  module_spi_driver(peb2466_spi_driver);
maintainer
#2 lore raw
In reply to ying zuxin
Quoted 8 lines · ying zuxin

The devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to call clk_disable_unprepare() when needed, as a managed resource.

This simplifies the code and avoids the calls to clk_disable_unprepare().

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: codecs: Use devm_clk_get_enabled() helpers

      commit: 241c044e743f9c55886828763c99b51b0392c21d

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark