alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] ASoC: fsl: imx-audmux: Use devm_clk_get()
@ 2013-03-12 23:51 Fabio Estevam
  2013-03-12 23:51 ` [PATCH 1/2] ASoC: fsl: imx-sgtl5000: " Fabio Estevam
  2013-03-13 10:39 ` [PATCH 2/2] ASoC: fsl: imx-audmux: " Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Fabio Estevam @ 2013-03-12 23:51 UTC (permalink / raw)
  To: broonie; +Cc: Fabio Estevam, alsa-devel

From: Fabio Estevam <fabio.estevam@freescale.com>

By using devm_clk_get() we can save a call to clk_put().

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 sound/soc/fsl/imx-audmux.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/soc/fsl/imx-audmux.c b/sound/soc/fsl/imx-audmux.c
index 3f333e5..47f046a 100644
--- a/sound/soc/fsl/imx-audmux.c
+++ b/sound/soc/fsl/imx-audmux.c
@@ -262,7 +262,7 @@ static int imx_audmux_probe(struct platform_device *pdev)
 		return PTR_ERR(pinctrl);
 	}
 
-	audmux_clk = clk_get(&pdev->dev, "audmux");
+	audmux_clk = devm_clk_get(&pdev->dev, "audmux");
 	if (IS_ERR(audmux_clk)) {
 		dev_dbg(&pdev->dev, "cannot get clock: %ld\n",
 				PTR_ERR(audmux_clk));
@@ -282,7 +282,6 @@ static int imx_audmux_remove(struct platform_device *pdev)
 {
 	if (audmux_type == IMX31_AUDMUX)
 		audmux_debugfs_remove();
-	clk_put(audmux_clk);
 
 	return 0;
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 1/2] ASoC: fsl: imx-sgtl5000: Use devm_clk_get()
  2013-03-12 23:51 [PATCH 2/2] ASoC: fsl: imx-audmux: Use devm_clk_get() Fabio Estevam
@ 2013-03-12 23:51 ` Fabio Estevam
  2013-03-13 10:39   ` Mark Brown
  2013-03-13 10:39 ` [PATCH 2/2] ASoC: fsl: imx-audmux: " Mark Brown
  1 sibling, 1 reply; 4+ messages in thread
From: Fabio Estevam @ 2013-03-12 23:51 UTC (permalink / raw)
  To: broonie; +Cc: Fabio Estevam, alsa-devel

From: Fabio Estevam <fabio.estevam@freescale.com>

Using devm_clk_get() can make the code smaller and simpler.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 sound/soc/fsl/imx-sgtl5000.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c
index 424347e..74a4628 100644
--- a/sound/soc/fsl/imx-sgtl5000.c
+++ b/sound/soc/fsl/imx-sgtl5000.c
@@ -128,7 +128,7 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
 		goto fail;
 	}
 
-	data->codec_clk = clk_get(&codec_dev->dev, NULL);
+	data->codec_clk = devm_clk_get(&codec_dev->dev, NULL);
 	if (IS_ERR(data->codec_clk)) {
 		/* assuming clock enabled by default */
 		data->codec_clk = NULL;
@@ -175,7 +175,6 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, data);
 clk_fail:
-	clk_put(data->codec_clk);
 fail:
 	if (ssi_np)
 		of_node_put(ssi_np);
@@ -189,10 +188,9 @@ static int imx_sgtl5000_remove(struct platform_device *pdev)
 {
 	struct imx_sgtl5000_data *data = platform_get_drvdata(pdev);
 
-	if (data->codec_clk) {
+	if (data->codec_clk)
 		clk_disable_unprepare(data->codec_clk);
-		clk_put(data->codec_clk);
-	}
+
 	snd_soc_unregister_card(&data->card);
 
 	return 0;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] ASoC: fsl: imx-sgtl5000: Use devm_clk_get()
  2013-03-12 23:51 ` [PATCH 1/2] ASoC: fsl: imx-sgtl5000: " Fabio Estevam
@ 2013-03-13 10:39   ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2013-03-13 10:39 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: Fabio Estevam, alsa-devel


[-- Attachment #1.1: Type: text/plain, Size: 615 bytes --]

On Tue, Mar 12, 2013 at 08:51:29PM -0300, Fabio Estevam wrote:

> -	data->codec_clk = clk_get(&codec_dev->dev, NULL);
> +	data->codec_clk = devm_clk_get(&codec_dev->dev, NULL);
>  	if (IS_ERR(data->codec_clk)) {

This doesn't look right, we're using the CODEC device here but this is
the card driver.  That means that if we unload and reload the card the
clock will get acquired twice.  Should be mostly harmless but still it's
not good practice and would eventually run us out of memory.

Really the CODEC should be doing this but then we get into the fact that
the clock API isn't reliably available and so on...

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] ASoC: fsl: imx-audmux: Use devm_clk_get()
  2013-03-12 23:51 [PATCH 2/2] ASoC: fsl: imx-audmux: Use devm_clk_get() Fabio Estevam
  2013-03-12 23:51 ` [PATCH 1/2] ASoC: fsl: imx-sgtl5000: " Fabio Estevam
@ 2013-03-13 10:39 ` Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2013-03-13 10:39 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: Fabio Estevam, alsa-devel


[-- Attachment #1.1: Type: text/plain, Size: 201 bytes --]

On Tue, Mar 12, 2013 at 08:51:28PM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> By using devm_clk_get() we can save a call to clk_put().

Applied, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-03-13 10:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-12 23:51 [PATCH 2/2] ASoC: fsl: imx-audmux: Use devm_clk_get() Fabio Estevam
2013-03-12 23:51 ` [PATCH 1/2] ASoC: fsl: imx-sgtl5000: " Fabio Estevam
2013-03-13 10:39   ` Mark Brown
2013-03-13 10:39 ` [PATCH 2/2] ASoC: fsl: imx-audmux: " Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).