ASoC: adi: Use devm_clk_get_enabled()
cover ASoC: adi: Use devm_clk_get_enabled()
From: bui duc phuc <[email protected]>
Hi all,
This series uses devm_clk_get_enabled() to simplify clock management in the ADI AXI I2S and SPDIF drivers, removing the need for manual clock enable/disable handling.
Compile-tested only.
Best regards,
Phuc
bui duc phuc (2):
ASoC: adi: axi-i2s: Use devm_clk_get_enabled()
ASoC: adi: axi-spdif: Use devm_clk_get_enabled()
sound/soc/adi/axi-i2s.c | 22 +++------------------- sound/soc/adi/axi-spdif.c | 22 +++------------------- 2 files changed, 6 insertions(+), 38 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/2 ASoC: adi: axi-i2s: Use devm_clk_get_enabled()
From: bui duc phuc <[email protected]>
The AXI clock is enabled once in probe() and only disabled in remove(). Use devm_clk_get_enabled() to let devres handle this automatically, and drop the now unnecessary remove() callback.
--- sound/soc/adi/axi-i2s.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-)
sound/soc/adi/axi-i2s.c +3 -19
@@ -208,7 +208,7 @@ static int axi_i2s_probe(struct platform_device *pdev)if (IS_ERR (i2s->regmap))return PTR_ERR (i2s->regmap); - i2s->clk =devm_clk_get (&pdev->dev,"axi" ); + i2s->clk =devm_clk_get_enabled (&pdev->dev,"axi" );if (IS_ERR (i2s->clk))return PTR_ERR (i2s->clk);
@@ -216,10 +216,6 @@ static int axi_i2s_probe(struct platform_device *pdev)if (IS_ERR (i2s->clk_ref))return PTR_ERR (i2s->clk_ref); - ret =clk_prepare_enable (i2s->clk); -if (ret) -return ret; -if (i2s->has_playback) { axi_i2s_dai.playback.channels_min =2 ; axi_i2s_dai.playback.channels_max =2 ;
@@ -257,28 +253,17 @@ static int axi_i2s_probe(struct platform_device *pdev) ret =devm_snd_soc_register_component (&pdev->dev, &axi_i2s_component, &axi_i2s_dai,1 );if (ret) - goto err_clk_disable; +return ret; ret =devm_snd_dmaengine_pcm_register (&pdev->dev,NULL ,0 );if (ret) - goto err_clk_disable; +return ret;dev_info (&pdev->dev,"probed, capture %s, playback %s\n" ,str_enabled_disabled (i2s->has_capture),str_enabled_disabled (i2s->has_playback));return 0 ; - -err_clk_disable: -clk_disable_unprepare (i2s->clk); -return ret; -} - -static void axi_i2s_dev_remove (struct platform_device *pdev) -{ -struct axi_i2s *i2s =platform_get_drvdata (pdev); - -clk_disable_unprepare (i2s->clk); }static const struct of_device_id axi_i2s_of_match[] = {
@@ -293,7 +278,6 @@ static struct platform_driver axi_i2s_driver = { .of_match_table = axi_i2s_of_match, }, .probe = axi_i2s_probe, - .remove = axi_i2s_dev_remove, };module_platform_driver (axi_i2s_driver);
Signature · 1 line
2.43.0
PATCH 2/2 ASoC: adi: axi-spdif: Use devm_clk_get_enabled()
In reply to [email protected]From: bui duc phuc <[email protected]>
The AXI clock is enabled once in probe() and only disabled in remove(). Use devm_clk_get_enabled() to let devres handle this automatically, and drop the now unnecessary remove() callback.
--- sound/soc/adi/axi-spdif.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-)
sound/soc/adi/axi-spdif.c +3 -19
@@ -199,7 +199,7 @@ static int axi_spdif_probe(struct platform_device *pdev)if (IS_ERR (spdif->regmap))return PTR_ERR (spdif->regmap); - spdif->clk =devm_clk_get (&pdev->dev,"axi" ); + spdif->clk =devm_clk_get_enabled (&pdev->dev,"axi" );if (IS_ERR (spdif->clk))return PTR_ERR (spdif->clk);
@@ -207,10 +207,6 @@ static int axi_spdif_probe(struct platform_device *pdev)if (IS_ERR (spdif->clk_ref))return PTR_ERR (spdif->clk_ref); - ret =clk_prepare_enable (spdif->clk); -if (ret) -return ret; - spdif->dma_data.addr = res->start +AXI_SPDIF_REG_TX_FIFO ; spdif->dma_data.addr_width =4 ; spdif->dma_data.maxburst =1 ;
@@ -226,24 +222,13 @@ static int axi_spdif_probe(struct platform_device *pdev) ret =devm_snd_soc_register_component (&pdev->dev, &axi_spdif_component, &axi_spdif_dai,1 );if (ret) - goto err_clk_disable; +return ret; ret =devm_snd_dmaengine_pcm_register (&pdev->dev,NULL ,0 );if (ret) - goto err_clk_disable; +return ret;return 0 ; - -err_clk_disable: -clk_disable_unprepare (spdif->clk); -return ret; -} - -static void axi_spdif_dev_remove (struct platform_device *pdev) -{ -struct axi_spdif *spdif =platform_get_drvdata (pdev); - -clk_disable_unprepare (spdif->clk); }static const struct of_device_id axi_spdif_of_match[] = {
@@ -258,7 +243,6 @@ static struct platform_driver axi_spdif_driver = { .of_match_table = axi_spdif_of_match, }, .probe = axi_spdif_probe, - .remove = axi_spdif_dev_remove, };module_platform_driver (axi_spdif_driver);
Signature · 1 line
2.43.0