Skip to contentSkip to conversation

ASoC: Add resource managed snd_dmaengine_pcm_register()

PATCH Applied Lars-Peter Clausen 2 participants 12 messages Nov 28, 2013 – Dec 2, 2013

Subsystems (7)
lore
Share & tools
lore

Lars-Peter Clausen

author maintainer
#0 lore raw

PATCH 1/6 ASoC: Add resource managed snd_dmaengine_pcm_register()

For many drivers using the generic dmaengine PCM driver one of the few (or the only) things left to do in the drivers remove function is to unregister the PCM device. This patch adds a resource managed version of snd_dmaengine_pcm_register() which makes it possible to simplify the remove function as well as the error path in the probe function for those drivers.

---
Changes since v1:
* Moved snd_dmaengine_pcm_register() to soc-devres.c

---
 include/sound/dmaengine_pcm.h |  4 ++++
 sound/soc/soc-devres.c        | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)
include/sound/dmaengine_pcm.h +4 -0
index 1501731..4ef986c 100644
@@ -140,6 +140,10 @@ int snd_dmaengine_pcm_register(struct device *dev,
 	unsigned int flags);
 void snd_dmaengine_pcm_unregister(struct device *dev);
 
+int devm_snd_dmaengine_pcm_register(struct device *dev,
+	const struct snd_dmaengine_pcm_config *config,
+	unsigned int flags);
+
 int snd_dmaengine_pcm_prepare_slave_config(struct snd_pcm_substream *substream,
 	struct snd_pcm_hw_params *params,
 	struct dma_slave_config *slave_config);
sound/soc/soc-devres.c +41 -0

50 lines not on this page · raw message

Signature · 1 line
1.8.0
author maintainer
#1 lore raw

PATCH 2/6 ASoC: bcm2835-i2s: Use devm_snd_dmaengine_pcm_register()

Makes the code slightly shorter.

---
New in v2

---
 sound/soc/bcm/bcm2835-i2s.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
sound/soc/bcm/bcm2835-i2s.c +1 -8
index f49b007..2685fe4 100644
@@ -848,7 +848,7 @@ static int bcm2835_i2s_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	ret = snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
+	ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
 	if (ret) {
 		dev_err(&pdev->dev, "Could not register PCM: %d\n", ret);
 		return ret;
@@ -862,15 +862,8 @@ static const struct of_device_id bcm2835_i2s_of_match[] = {
 	{},
 };
 
-static int bcm2835_i2s_remove(struct platform_device *pdev)
-{
-	snd_dmaengine_pcm_unregister(&pdev->dev);
-	return 0;
-}
-
 static struct platform_driver bcm2835_i2s_driver = {
 	.probe		= bcm2835_i2s_probe,
-	.remove		= bcm2835_i2s_remove,
 	.driver		= {
 		.name	= "bcm2835-i2s",
 		.owner	= THIS_MODULE,
Signature · 1 line
1.8.0
maintainer Applied
#2 lore raw

Re: [PATCH 2/6] ASoC: bcm2835-i2s: Use devm_snd_dmaengine_pcm_register()

Quoted 1 line · Lars-Peter Clausen

Makes the code slightly shorter.

Applied, thanks.

author maintainer
#3 lore raw

PATCH 3/6 ASoC: ep93xx: Use devm_snd_dmaengine_pcm_register()

In reply to Lars-Peter Clausen

Makes the code slightly shorter.

---
No changes since v1

---
 sound/soc/cirrus/ep93xx-pcm.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
sound/soc/cirrus/ep93xx-pcm.c +1 -8
index cfe517e..fdb8b8f 100644
@@ -78,19 +78,13 @@ static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = {
 
 static int ep93xx_soc_platform_probe(struct platform_device *pdev)
 {
-	return snd_dmaengine_pcm_register(&pdev->dev,
+	return devm_snd_dmaengine_pcm_register(&pdev->dev,
 		&ep93xx_dmaengine_pcm_config,
 		SND_DMAENGINE_PCM_FLAG_NO_RESIDUE |
 		SND_DMAENGINE_PCM_FLAG_NO_DT |
 		SND_DMAENGINE_PCM_FLAG_COMPAT);
 }
 
-static int ep93xx_soc_platform_remove(struct platform_device *pdev)
-{
-	snd_dmaengine_pcm_unregister(&pdev->dev);
-	return 0;
-}
-
 static struct platform_driver ep93xx_pcm_driver = {
 	.driver = {
 			.name = "ep93xx-pcm-audio",
@@ -98,7 +92,6 @@ static struct platform_driver ep93xx_pcm_driver = {
 	},
 
 	.probe = ep93xx_soc_platform_probe,
-	.remove = ep93xx_soc_platform_remove,
 };
 
 module_platform_driver(ep93xx_pcm_driver);
Signature · 1 line
1.8.0
maintainer Applied
#4 lore raw

Re: [PATCH 3/6] ASoC: ep93xx: Use devm_snd_dmaengine_pcm_register()

Quoted 1 line · Lars-Peter Clausen

Makes the code slightly shorter.

Applied, thanks.

author maintainer
#5 lore raw

PATCH 4/6 ASoC: fsl: Use devm_snd_dmaengine_pcm_register()

In reply to Lars-Peter Clausen

Makes the code shorter.

---
No changes since v1

---
 sound/soc/fsl/fsl_spdif.c   | 8 --------
 sound/soc/fsl/fsl_ssi.c     | 4 ----
 sound/soc/fsl/imx-pcm-dma.c | 9 ++-------
 sound/soc/fsl/imx-pcm.h     | 5 -----
 sound/soc/fsl/imx-ssi.c     | 3 ---
 5 files changed, 2 insertions(+), 27 deletions(-)
sound/soc/fsl/fsl_spdif.c +0 -8
index 55193a5..4d075f1 100644
@@ -1181,13 +1181,6 @@ static int fsl_spdif_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int fsl_spdif_remove(struct platform_device *pdev)
-{
-	imx_pcm_dma_exit(pdev);
-
-	return 0;
-}
-
 static const struct of_device_id fsl_spdif_dt_ids[] = {
 	{ .compatible = "fsl,imx35-spdif", },
 	{}
@@ -1201,7 +1194,6 @@ static struct platform_driver fsl_spdif_driver = {
 		.of_match_table = fsl_spdif_dt_ids,
 	},
 	.probe = fsl_spdif_probe,
-	.remove = fsl_spdif_remove,
 };
 
 module_platform_driver(fsl_spdif_driver);
sound/soc/fsl/fsl_ssi.c +0 -4
index fb8f52a..3df0318 100644
@@ -1109,8 +1109,6 @@ done:
 	return 0;
 
 error_dai:
-	if (ssi_private->ssi_on_imx)
-		imx_pcm_dma_exit(pdev);
 	snd_soc_unregister_component(&pdev->dev);
 
 error_dev:
@@ -1132,8 +1130,6 @@ static int fsl_ssi_remove(struct platform_device *pdev)
 
 	if (!ssi_private->new_binding)
 		platform_device_unregister(ssi_private->pdev);
-	if (ssi_private->ssi_on_imx)
-		imx_pcm_dma_exit(pdev);
 	snd_soc_unregister_component(&pdev->dev);
 	device_remove_file(&pdev->dev, &ssi_private->dev_attr);
 	if (ssi_private->ssi_on_imx)
sound/soc/fsl/imx-pcm-dma.c +2 -7
index aee2307..c5e47f8 100644
@@ -61,16 +61,11 @@ static const struct snd_dmaengine_pcm_config imx_dmaengine_pcm_config = {
 
 int imx_pcm_dma_init(struct platform_device *pdev)
 {
-	return snd_dmaengine_pcm_register(&pdev->dev, &imx_dmaengine_pcm_config,
+	return devm_snd_dmaengine_pcm_register(&pdev->dev,
+		&imx_dmaengine_pcm_config,
 		SND_DMAENGINE_PCM_FLAG_NO_RESIDUE |
 		SND_DMAENGINE_PCM_FLAG_COMPAT);
 }
 EXPORT_SYMBOL_GPL(imx_pcm_dma_init);
 
-void imx_pcm_dma_exit(struct platform_device *pdev)
-{
-	snd_dmaengine_pcm_unregister(&pdev->dev);
-}
-EXPORT_SYMBOL_GPL(imx_pcm_dma_exit);
-
 MODULE_LICENSE("GPL");
sound/soc/fsl/imx-pcm.h +0 -5
index 5d5b733..c79cb27 100644
@@ -40,16 +40,11 @@ struct imx_pcm_fiq_params {
 
 #if IS_ENABLED(CONFIG_SND_SOC_IMX_PCM_DMA)
 int imx_pcm_dma_init(struct platform_device *pdev);
-void imx_pcm_dma_exit(struct platform_device *pdev);
 #else
 static inline int imx_pcm_dma_init(struct platform_device *pdev)
 {
 	return -ENODEV;
 }
-
-static inline void imx_pcm_dma_exit(struct platform_device *pdev)
-{
-}
 #endif
 
 #if IS_ENABLED(CONFIG_SND_SOC_IMX_PCM_FIQ)
sound/soc/fsl/imx-ssi.c +0 -3
index f5f248c..cc7376f 100644
@@ -624,9 +624,6 @@ static int imx_ssi_remove(struct platform_device *pdev)
 {
 	struct imx_ssi *ssi = platform_get_drvdata(pdev);
 
-	if (!ssi->dma_init)
-		imx_pcm_dma_exit(pdev);
-
 	if (!ssi->fiq_init)
 		imx_pcm_fiq_exit(pdev);
 
Signature · 1 line
1.8.0
maintainer Applied
#6 lore raw

Re: [PATCH 4/6] ASoC: fsl: Use devm_snd_dmaengine_pcm_register()

Quoted 1 line · Lars-Peter Clausen

Makes the code shorter.

Applied, thanks.

author maintainer
#7 lore raw

PATCH 5/6 ASoC: spear: Use devm_snd_dmaengine_pcm_register

In reply to Lars-Peter Clausen

Makes the code slightly shorter.

---
No changes since v1

---
 sound/soc/spear/spear_pcm.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
sound/soc/spear/spear_pcm.c +1 -8
index 4707f2b..9a02141 100644
@@ -49,18 +49,12 @@ static const struct snd_dmaengine_pcm_config spear_dmaengine_pcm_config = {
 
 static int spear_soc_platform_probe(struct platform_device *pdev)
 {
-	return snd_dmaengine_pcm_register(&pdev->dev,
+	return devm_snd_dmaengine_pcm_register(&pdev->dev,
 		&spear_dmaengine_pcm_config,
 		SND_DMAENGINE_PCM_FLAG_NO_DT |
 		SND_DMAENGINE_PCM_FLAG_COMPAT);
 }
 
-static int spear_soc_platform_remove(struct platform_device *pdev)
-{
-	snd_dmaengine_pcm_unregister(&pdev->dev);
-	return 0;
-}
-
 static struct platform_driver spear_pcm_driver = {
 	.driver = {
 		.name = "spear-pcm-audio",
@@ -68,7 +62,6 @@ static struct platform_driver spear_pcm_driver = {
 	},
 
 	.probe = spear_soc_platform_probe,
-	.remove = spear_soc_platform_remove,
 };
 
 module_platform_driver(spear_pcm_driver);
Signature · 1 line
1.8.0
maintainer Applied
#8 lore raw

Re: [PATCH 5/6] ASoC: spear: Use devm_snd_dmaengine_pcm_register

Quoted 1 line · Lars-Peter Clausen

Makes the code slightly shorter.

Applied, thanks.

author maintainer
#9 lore raw

PATCH 6/6 ASoC: mxs: Use devm_snd_dmaengine_pcm_register()

In reply to Lars-Peter Clausen

Makes the code shorter.

---
No changes since v1

---
 sound/soc/mxs/mxs-pcm.c  | 8 +-------
 sound/soc/mxs/mxs-pcm.h  | 1 -
 sound/soc/mxs/mxs-saif.c | 8 --------
 3 files changed, 1 insertion(+), 16 deletions(-)
sound/soc/mxs/mxs-pcm.c +1 -7
index b16abbb..04a6b0d 100644
@@ -56,16 +56,10 @@ static const struct snd_dmaengine_pcm_config mxs_dmaengine_pcm_config = {
 
 int mxs_pcm_platform_register(struct device *dev)
 {
-	return snd_dmaengine_pcm_register(dev, &mxs_dmaengine_pcm_config,
+	return devm_snd_dmaengine_pcm_register(dev, &mxs_dmaengine_pcm_config,
 		SND_DMAENGINE_PCM_FLAG_NO_RESIDUE |
 		SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX);
 }
 EXPORT_SYMBOL_GPL(mxs_pcm_platform_register);
 
-void mxs_pcm_platform_unregister(struct device *dev)
-{
-	snd_dmaengine_pcm_unregister(dev);
-}
-EXPORT_SYMBOL_GPL(mxs_pcm_platform_unregister);
-
 MODULE_LICENSE("GPL");
sound/soc/mxs/mxs-pcm.h +0 -1
index bc685b6..035ea04 100644
@@ -20,6 +20,5 @@
 #define _MXS_PCM_H
 
 int mxs_pcm_platform_register(struct device *dev);
-void mxs_pcm_platform_unregister(struct device *dev);
 
 #endif
sound/soc/mxs/mxs-saif.c +0 -8
index 54e622a..92db74d 100644
@@ -804,13 +804,6 @@ static int mxs_saif_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int mxs_saif_remove(struct platform_device *pdev)
-{
-	mxs_pcm_platform_unregister(&pdev->dev);
-
-	return 0;
-}
-
 static const struct of_device_id mxs_saif_dt_ids[] = {
 	{ .compatible = "fsl,imx28-saif", },
 	{ /* sentinel */ }
@@ -819,7 +812,6 @@ MODULE_DEVICE_TABLE(of, mxs_saif_dt_ids);
 
 static struct platform_driver mxs_saif_driver = {
 	.probe = mxs_saif_probe,
-	.remove = mxs_saif_remove,
 
 	.driver = {
 		.name = "mxs-saif",
Signature · 1 line
1.8.0
maintainer Applied
#10 lore raw

Re: [PATCH 6/6] ASoC: mxs: Use devm_snd_dmaengine_pcm_register()

Quoted 1 line · Lars-Peter Clausen

Makes the code shorter.

Applied, thanks.

maintainer Applied
#11 lore raw
In reply to Lars-Peter Clausen
Quoted 2 lines · Lars-Peter Clausen

For many drivers using the generic dmaengine PCM driver one of the few (or the only) things left to do in the drivers remove function is to unregister the PCM

Applied, thanks.