Skip to contentSkip to conversation

ASoC: Add resource managed snd_dmaengine_pcm_register()

PATCH In review Lars-Peter Clausen 4 participants 14 messages Nov 24, 2013 – Nov 25, 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.

---
 include/sound/dmaengine_pcm.h         |  4 ++++
 sound/soc/soc-generic-dmaengine-pcm.c | 36 +++++++++++++++++++++++++++++++++++
 2 files changed, 40 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-generic-dmaengine-pcm.c +36 -0
index cbc9c96..20690c0 100644
@@ -366,4 +366,40 @@ void snd_dmaengine_pcm_unregister(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_unregister);
 
+static void devm_dmaengine_pcm_release(struct device *dev, void *res)
+{
+	snd_dmaengine_pcm_unregister(*(struct device **)res);
+}
+
+/**
+ * devm_snd_dmaengine_pcm_register - resource managed dmaengine PCM registration
+ * @dev: The parent device for the PCM device
+ * @config: Platform specific PCM configuration
+ * @flags: Platform specific quirks
+ *
+ * Register a dmaengine based PCM device with automatic unregistration when the
+ * device is unregistered.
+ */
+int devm_snd_dmaengine_pcm_register(struct device *dev,
+	const struct snd_dmaengine_pcm_config *config, unsigned int flags)
+{
+	struct device **ptr;
+	int ret;
+
+	ptr = devres_alloc(devm_dmaengine_pcm_release, sizeof(*ptr), GFP_KERNEL);
+	if (!ptr)
+		return -ENOMEM;
+
+	ret = snd_dmaengine_pcm_register(dev, config, flags);
+	if (ret == 0) {
+		*ptr = dev;
+		devres_add(dev, ptr);
+	} else {
+		devres_free(ptr);
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(devm_snd_dmaengine_pcm_register);
+
 MODULE_LICENSE("GPL");
Signature · 1 line
1.8.0
author maintainer
#1 lore raw

PATCH 2/6 ASoC: atmel: Use devm_snd_dmaengine_pcm_register()

Makes the code shorter.

---
 sound/soc/atmel/atmel-pcm-dma.c | 8 +-------
 sound/soc/atmel/atmel-pcm.h     | 4 ----
 sound/soc/atmel/atmel_ssc_dai.c | 4 +---
 3 files changed, 2 insertions(+), 14 deletions(-)
sound/soc/atmel/atmel-pcm-dma.c +1 -7
index 06082e5..7dbc0e9 100644
@@ -129,17 +129,11 @@ static const struct snd_dmaengine_pcm_config atmel_dmaengine_pcm_config = {
 
 int atmel_pcm_dma_platform_register(struct device *dev)
 {
-	return snd_dmaengine_pcm_register(dev, &atmel_dmaengine_pcm_config,
+	return devm_snd_dmaengine_pcm_register(dev, &atmel_dmaengine_pcm_config,
 			SND_DMAENGINE_PCM_FLAG_NO_RESIDUE);
 }
 EXPORT_SYMBOL(atmel_pcm_dma_platform_register);
 
-void atmel_pcm_dma_platform_unregister(struct device *dev)
-{
-	snd_dmaengine_pcm_unregister(dev);
-}
-EXPORT_SYMBOL(atmel_pcm_dma_platform_unregister);
-
 MODULE_AUTHOR("Bo Shen <[email protected]>");
 MODULE_DESCRIPTION("Atmel DMA based PCM module");
 MODULE_LICENSE("GPL");
sound/soc/atmel/atmel-pcm.h +0 -4
index 12ae814..bb71069 100644
@@ -105,15 +105,11 @@ static inline void atmel_pcm_pdc_platform_unregister(struct device *dev)
 #if defined(CONFIG_SND_ATMEL_SOC_DMA) || \
 	defined(CONFIG_SND_ATMEL_SOC_DMA_MODULE)
 int atmel_pcm_dma_platform_register(struct device *dev);
-void atmel_pcm_dma_platform_unregister(struct device *dev);
 #else
 static inline int atmel_pcm_dma_platform_register(struct device *dev)
 {
 	return 0;
 }
-static inline void atmel_pcm_dma_platform_unregister(struct device *dev)
-{
-}
 #endif
 
 #endif /* _ATMEL_PCM_H */
sound/soc/atmel/atmel_ssc_dai.c +1 -3
index 8697ced..13aaa7d 100644
@@ -792,9 +792,7 @@ static void asoc_ssc_exit(struct device *dev)
 	struct platform_device *pdev = to_platform_device(dev);
 	struct ssc_device *ssc = platform_get_drvdata(pdev);
 
-	if (ssc->pdata->use_dma)
-		atmel_pcm_dma_platform_unregister(dev);
-	else
+	if (!ssc->pdata->use_dma)
 		atmel_pcm_pdc_platform_unregister(dev);
 
 	snd_soc_unregister_component(dev);
Signature · 1 line
1.8.0
#2 lore raw

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

Hi Lars-Perter,

Quoted 8 lines · Lars-Peter Clausen

Makes the code shorter.

---
  sound/soc/atmel/atmel-pcm-dma.c | 8 +-------
  sound/soc/atmel/atmel-pcm.h     | 4 ----
  sound/soc/atmel/atmel_ssc_dai.c | 4 +---
  3 files changed, 2 insertions(+), 14 deletions(-)

Tested on at91sam9n12ek board, it will cause oops at the second time load the driver module (insmod --> rmmod --> insmod: oops).

Some log information as following:
---8>---

Unable to handle kernel paging request at virtual address bf000190
pgd = c77c0000
[bf000190] *pgd=27457811, *pte=00000000, *ppte=00000000
Internal error: Oops: 7 [#1] ARM
Modules linked in: snd_atmel_soc_wm8904(+) snd_soc_wm8904 snd_soc_atmel_ssc_dai snd_soc_atmel_pcm_dma [last unloaded: snd_soc_atmel_pcm_dma]
CPU: 0 PID: 574 Comm: insmod Not tainted 3.13.0-rc1+ #65
task: c774d800 ti: c754e000 task.ti: c754e000
PC is at dmaengine_pcm_new+0x28/0x1a0
LR is at soc_new_pcm+0x2ec/0x394
pc : [<c02b5dcc>]    lr : [<c02b4cb4>]    psr: a0000013

sp : c754fc88 ip : 00000000 fp : c77682ec
r10: c7768220 r9 : c77682e0 r8 : 00000000
r7 : c77682ec r6 : 00000001 r5 : 00000001 r4 : c7685810 r3 : bf000180 r2 : c7467010 r1 : c7777020 r0 : c7685810
Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
Control: 0005317f Table: 277c0000 DAC: 00000015 Process insmod (pid: 574, stack limit = 0xc754e1c0)

Stack: (0xc754fc88 to 0xc7550000)

......
[<c02b5dcc>] (dmaengine_pcm_new+0x28/0x1a0) from [<c02b4cb4>] (soc_new_pcm+0x2ec/0x394)
[<c02b4cb4>] (soc_new_pcm+0x2ec/0x394) from [<c02abfe8>] (snd_soc_register_card+0xadc/0x1180)
[<c02abfe8>] (snd_soc_register_card+0xadc/0x1180) from [<bf02d24c>] (atmel_asoc_wm8904_probe+0x18c/0x214 [snd_atmel_soc_wm8904]) [<bf02d24c>] (atmel_asoc_wm8904_probe+0x18c/0x214 [snd_atmel_soc_wm8904]) from [<c01dedcc>] (platform_drv_probe+0x18/0x48) [<c01dedcc>] (platform_drv_probe+0x18/0x48) from [<c01dda6c>] (driver_probe_device+0xac/0x1f4)
[<c01dda6c>] (driver_probe_device+0xac/0x1f4) from [<c01ddc1c>] (__driver_attach+0x68/0x88)
[<c01ddc1c>] (__driver_attach+0x68/0x88) from [<c01dc4bc>] (bus_for_each_dev+0x54/0x8c)
[<c01dc4bc>] (bus_for_each_dev+0x54/0x8c) from [<c01dd2d8>] (bus_add_driver+0xc8/0x1c4)
[<c01dd2d8>] (bus_add_driver+0xc8/0x1c4) from [<c01de228>] (driver_register+0x9c/0xe0)
[<c01de228>] (driver_register+0x9c/0xe0) from [<c0008910>] (do_one_initcall+0xa8/0x15c)
[<c0008910>] (do_one_initcall+0xa8/0x15c) from [<c004d8fc>] (load_module+0x1724/0x19d8)
[<c004d8fc>] (load_module+0x1724/0x19d8) from [<c004dc70>] (SyS_init_module+0xc0/0xd8)
[<c004dc70>] (SyS_init_module+0xc0/0xd8) from [<c00094a0>] (ret_fast_syscall+0x0/0x2c)

Code: e1a04000 e24b900c e58d200c 0a000004 (e5938010)
---[ end trace 484369a6aa2ca38d ]---

Segmentation fault
---<8---

Quoted 49 lines
sound/soc/atmel/atmel-pcm-dma.c +1 -7
index 06082e5..7dbc0e9 100644
@@ -129,17 +129,11 @@ static const struct snd_dmaengine_pcm_config atmel_dmaengine_pcm_config = {
 
  int atmel_pcm_dma_platform_register(struct device *dev)
  {
-	return snd_dmaengine_pcm_register(dev, &atmel_dmaengine_pcm_config,
+	return devm_snd_dmaengine_pcm_register(dev, &atmel_dmaengine_pcm_config,
  			SND_DMAENGINE_PCM_FLAG_NO_RESIDUE);
  }
  EXPORT_SYMBOL(atmel_pcm_dma_platform_register);
 
-void atmel_pcm_dma_platform_unregister(struct device *dev)
-{
-	snd_dmaengine_pcm_unregister(dev);
-}
-EXPORT_SYMBOL(atmel_pcm_dma_platform_unregister);
-
  MODULE_AUTHOR("Bo Shen <[email protected]>");
  MODULE_DESCRIPTION("Atmel DMA based PCM module");
  MODULE_LICENSE("GPL");
sound/soc/atmel/atmel-pcm.h +0 -4
index 12ae814..bb71069 100644
@@ -105,15 +105,11 @@ static inline void atmel_pcm_pdc_platform_unregister(struct device *dev)
  #if defined(CONFIG_SND_ATMEL_SOC_DMA) || \
  	defined(CONFIG_SND_ATMEL_SOC_DMA_MODULE)
  int atmel_pcm_dma_platform_register(struct device *dev);
-void atmel_pcm_dma_platform_unregister(struct device *dev);
  #else
  static inline int atmel_pcm_dma_platform_register(struct device *dev)
  {
  	return 0;
  }
-static inline void atmel_pcm_dma_platform_unregister(struct device *dev)
-{
-}
  #endif
 
  #endif /* _ATMEL_PCM_H */
sound/soc/atmel/atmel_ssc_dai.c +0 -0
index 8697ced..13aaa7d 100644

sound/soc/atmel/atmel_ssc_dai.c static void asoc_ssc_exit(struct device *dev) · line 798

Quoted 10 lines
sound/soc/atmel/atmel_ssc_dai.c +1 -3
@@ -792,9 +792,7 @@ static void asoc_ssc_exit(struct device *dev)
  	struct platform_device *pdev = to_platform_device(dev);
  	struct ssc_device *ssc = platform_get_drvdata(pdev);
 
-	if (ssc->pdata->use_dma)
-		atmel_pcm_dma_platform_unregister(dev);
-	else
+	if (!ssc->pdata->use_dma)
  		atmel_pcm_pdc_platform_unregister(dev);
 
  	snd_soc_unregister_component(dev);

Best Regards,
Bo Shen

author maintainer
#3 lore raw

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

Quoted 12 lines · Bo Shen

Hi Lars-Perter,

Quoted 8 lines · Lars-Peter Clausen

Makes the code shorter.

---
  sound/soc/atmel/atmel-pcm-dma.c | 8 +-------
  sound/soc/atmel/atmel-pcm.h     | 4 ----
  sound/soc/atmel/atmel_ssc_dai.c | 4 +---
  3 files changed, 2 insertions(+), 14 deletions(-)
Quoted 2 lines

Tested on at91sam9n12ek board, it will cause oops at the second time load the driver module (insmod --> rmmod --> insmod: oops).

Does it work without the patch?

Quoted 122 lines

Some log information as following:
---8>---

Unable to handle kernel paging request at virtual address bf000190
pgd = c77c0000
[bf000190] *pgd=27457811, *pte=00000000, *ppte=00000000
Internal error: Oops: 7 [#1] ARM
Modules linked in: snd_atmel_soc_wm8904(+) snd_soc_wm8904
snd_soc_atmel_ssc_dai snd_soc_atmel_pcm_dma [last unloaded:
snd_soc_atmel_pcm_dma]
CPU: 0 PID: 574 Comm: insmod Not tainted 3.13.0-rc1+ #65
task: c774d800 ti: c754e000 task.ti: c754e000
PC is at dmaengine_pcm_new+0x28/0x1a0
LR is at soc_new_pcm+0x2ec/0x394
pc : [<c02b5dcc>]    lr : [<c02b4cb4>]    psr: a0000013

sp : c754fc88 ip : 00000000 fp : c77682ec
r10: c7768220 r9 : c77682e0 r8 : 00000000
r7 : c77682ec r6 : 00000001 r5 : 00000001 r4 : c7685810 r3 : bf000180 r2 : c7467010 r1 : c7777020 r0 : c7685810
Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
Control: 0005317f Table: 277c0000 DAC: 00000015 Process insmod (pid: 574, stack limit = 0xc754e1c0)

Stack: (0xc754fc88 to 0xc7550000)

......
[<c02b5dcc>] (dmaengine_pcm_new+0x28/0x1a0) from [<c02b4cb4>] (soc_new_pcm+0x2ec/0x394)
[<c02b4cb4>] (soc_new_pcm+0x2ec/0x394) from [<c02abfe8>] (snd_soc_register_card+0xadc/0x1180)
[<c02abfe8>] (snd_soc_register_card+0xadc/0x1180) from [<bf02d24c>] (atmel_asoc_wm8904_probe+0x18c/0x214 [snd_atmel_soc_wm8904]) [<bf02d24c>] (atmel_asoc_wm8904_probe+0x18c/0x214 [snd_atmel_soc_wm8904]) from [<c01dedcc>] (platform_drv_probe+0x18/0x48)
[<c01dedcc>] (platform_drv_probe+0x18/0x48) from [<c01dda6c>] (driver_probe_device+0xac/0x1f4)
[<c01dda6c>] (driver_probe_device+0xac/0x1f4) from [<c01ddc1c>] (__driver_attach+0x68/0x88)
[<c01ddc1c>] (__driver_attach+0x68/0x88) from [<c01dc4bc>] (bus_for_each_dev+0x54/0x8c)
[<c01dc4bc>] (bus_for_each_dev+0x54/0x8c) from [<c01dd2d8>] (bus_add_driver+0xc8/0x1c4)
[<c01dd2d8>] (bus_add_driver+0xc8/0x1c4) from [<c01de228>] (driver_register+0x9c/0xe0)
[<c01de228>] (driver_register+0x9c/0xe0) from [<c0008910>] (do_one_initcall+0xa8/0x15c)
[<c0008910>] (do_one_initcall+0xa8/0x15c) from [<c004d8fc>] (load_module+0x1724/0x19d8)
[<c004d8fc>] (load_module+0x1724/0x19d8) from [<c004dc70>] (SyS_init_module+0xc0/0xd8)
[<c004dc70>] (SyS_init_module+0xc0/0xd8) from [<c00094a0>] (ret_fast_syscall+0x0/0x2c)

Code: e1a04000 e24b900c e58d200c 0a000004 (e5938010)
---[ end trace 484369a6aa2ca38d ]---

Segmentation fault
---<8---

Quoted 53 lines
sound/soc/atmel/atmel-pcm-dma.c +1 -7
index 06082e5..7dbc0e9 100644
@@ -129,17 +129,11 @@ static const struct snd_dmaengine_pcm_config
 atmel_dmaengine_pcm_config = {
 
  int atmel_pcm_dma_platform_register(struct device *dev)
  {
-    return snd_dmaengine_pcm_register(dev, &atmel_dmaengine_pcm_config,
+    return devm_snd_dmaengine_pcm_register(dev, &atmel_dmaengine_pcm_config,
              SND_DMAENGINE_PCM_FLAG_NO_RESIDUE);
  }
  EXPORT_SYMBOL(atmel_pcm_dma_platform_register);
 
-void atmel_pcm_dma_platform_unregister(struct device *dev)
-{
-    snd_dmaengine_pcm_unregister(dev);
-}
-EXPORT_SYMBOL(atmel_pcm_dma_platform_unregister);
-
  MODULE_AUTHOR("Bo Shen <[email protected]>");
  MODULE_DESCRIPTION("Atmel DMA based PCM module");
  MODULE_LICENSE("GPL");
sound/soc/atmel/atmel-pcm.h +0 -4
index 12ae814..bb71069 100644
@@ -105,15 +105,11 @@ static inline void
 atmel_pcm_pdc_platform_unregister(struct device *dev)
  #if defined(CONFIG_SND_ATMEL_SOC_DMA) || \
      defined(CONFIG_SND_ATMEL_SOC_DMA_MODULE)
  int atmel_pcm_dma_platform_register(struct device *dev);
-void atmel_pcm_dma_platform_unregister(struct device *dev);
  #else
  static inline int atmel_pcm_dma_platform_register(struct device *dev)
  {
      return 0;
  }
-static inline void atmel_pcm_dma_platform_unregister(struct device *dev)
-{
-}
  #endif
 
  #endif /* _ATMEL_PCM_H */
sound/soc/atmel/atmel_ssc_dai.c +0 -0
index 8697ced..13aaa7d 100644

sound/soc/atmel/atmel_ssc_dai.c static void asoc_ssc_exit(struct device *dev) · line 798

Quoted 10 lines
sound/soc/atmel/atmel_ssc_dai.c +1 -3
@@ -792,9 +792,7 @@ static void asoc_ssc_exit(struct device *dev)
      struct platform_device *pdev = to_platform_device(dev);
      struct ssc_device *ssc = platform_get_drvdata(pdev);
 
-    if (ssc->pdata->use_dma)
-        atmel_pcm_dma_platform_unregister(dev);
-    else
+    if (!ssc->pdata->use_dma)
          atmel_pcm_pdc_platform_unregister(dev);
 
      snd_soc_unregister_component(dev);

Best Regards,
Bo Shen

author maintainer
#4 lore raw

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

Quoted 13 lines · Lars-Peter Clausen
Quoted 12 lines · Bo Shen

Hi Lars-Perter,

Quoted 8 lines · Lars-Peter Clausen

Makes the code shorter.

---
  sound/soc/atmel/atmel-pcm-dma.c | 8 +-------
  sound/soc/atmel/atmel-pcm.h     | 4 ----
  sound/soc/atmel/atmel_ssc_dai.c | 4 +---
  3 files changed, 2 insertions(+), 14 deletions(-)
Quoted 5 lines
Quoted 2 lines

Tested on at91sam9n12ek board, it will cause oops at the second time load the driver module (insmod --> rmmod --> insmod: oops).

Does it work without the patch?

Ok, I see atmel is special. asoc_ssc_init() and asoc_ssc_exit() are not called from the drivers probe or remove function, so we can't use the resource managed version here. Thanks for testing.

- Lars

Quoted 128 lines
Quoted 116 lines

Some log information as following:
---8>---

Unable to handle kernel paging request at virtual address bf000190
pgd = c77c0000
[bf000190] *pgd=27457811, *pte=00000000, *ppte=00000000
Internal error: Oops: 7 [#1] ARM
Modules linked in: snd_atmel_soc_wm8904(+) snd_soc_wm8904
snd_soc_atmel_ssc_dai snd_soc_atmel_pcm_dma [last unloaded:
snd_soc_atmel_pcm_dma]
CPU: 0 PID: 574 Comm: insmod Not tainted 3.13.0-rc1+ #65
task: c774d800 ti: c754e000 task.ti: c754e000
PC is at dmaengine_pcm_new+0x28/0x1a0
LR is at soc_new_pcm+0x2ec/0x394
pc : [<c02b5dcc>]    lr : [<c02b4cb4>]    psr: a0000013

sp : c754fc88 ip : 00000000 fp : c77682ec
r10: c7768220 r9 : c77682e0 r8 : 00000000
r7 : c77682ec r6 : 00000001 r5 : 00000001 r4 : c7685810 r3 : bf000180 r2 : c7467010 r1 : c7777020 r0 : c7685810
Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
Control: 0005317f Table: 277c0000 DAC: 00000015 Process insmod (pid: 574, stack limit = 0xc754e1c0)

Stack: (0xc754fc88 to 0xc7550000)

......
[<c02b5dcc>] (dmaengine_pcm_new+0x28/0x1a0) from [<c02b4cb4>] (soc_new_pcm+0x2ec/0x394)
[<c02b4cb4>] (soc_new_pcm+0x2ec/0x394) from [<c02abfe8>] (snd_soc_register_card+0xadc/0x1180)
[<c02abfe8>] (snd_soc_register_card+0xadc/0x1180) from [<bf02d24c>] (atmel_asoc_wm8904_probe+0x18c/0x214 [snd_atmel_soc_wm8904]) [<bf02d24c>] (atmel_asoc_wm8904_probe+0x18c/0x214 [snd_atmel_soc_wm8904]) from [<c01dedcc>] (platform_drv_probe+0x18/0x48)
[<c01dedcc>] (platform_drv_probe+0x18/0x48) from [<c01dda6c>] (driver_probe_device+0xac/0x1f4)
[<c01dda6c>] (driver_probe_device+0xac/0x1f4) from [<c01ddc1c>] (__driver_attach+0x68/0x88)
[<c01ddc1c>] (__driver_attach+0x68/0x88) from [<c01dc4bc>] (bus_for_each_dev+0x54/0x8c)
[<c01dc4bc>] (bus_for_each_dev+0x54/0x8c) from [<c01dd2d8>] (bus_add_driver+0xc8/0x1c4)
[<c01dd2d8>] (bus_add_driver+0xc8/0x1c4) from [<c01de228>] (driver_register+0x9c/0xe0)
[<c01de228>] (driver_register+0x9c/0xe0) from [<c0008910>] (do_one_initcall+0xa8/0x15c)
[<c0008910>] (do_one_initcall+0xa8/0x15c) from [<c004d8fc>] (load_module+0x1724/0x19d8)
[<c004d8fc>] (load_module+0x1724/0x19d8) from [<c004dc70>] (SyS_init_module+0xc0/0xd8)
[<c004dc70>] (SyS_init_module+0xc0/0xd8) from [<c00094a0>] (ret_fast_syscall+0x0/0x2c)

Code: e1a04000 e24b900c e58d200c 0a000004 (e5938010)
---[ end trace 484369a6aa2ca38d ]---

Segmentation fault
---<8---

Quoted 61 lines
sound/soc/atmel/atmel-pcm-dma.c +1 -7
index 06082e5..7dbc0e9 100644
@@ -129,17 +129,11 @@ static const struct snd_dmaengine_pcm_config
 atmel_dmaengine_pcm_config = {
 
  int atmel_pcm_dma_platform_register(struct device *dev)
  {
-    return snd_dmaengine_pcm_register(dev, &atmel_dmaengine_pcm_config,
+    return devm_snd_dmaengine_pcm_register(dev, &atmel_dmaengine_pcm_config,
              SND_DMAENGINE_PCM_FLAG_NO_RESIDUE);
  }
  EXPORT_SYMBOL(atmel_pcm_dma_platform_register);
 
-void atmel_pcm_dma_platform_unregister(struct device *dev)
-{
-    snd_dmaengine_pcm_unregister(dev);
-}
-EXPORT_SYMBOL(atmel_pcm_dma_platform_unregister);
-
  MODULE_AUTHOR("Bo Shen <[email protected]>");
  MODULE_DESCRIPTION("Atmel DMA based PCM module");
  MODULE_LICENSE("GPL");
sound/soc/atmel/atmel-pcm.h +0 -4
index 12ae814..bb71069 100644
@@ -105,15 +105,11 @@ static inline void
 atmel_pcm_pdc_platform_unregister(struct device *dev)
  #if defined(CONFIG_SND_ATMEL_SOC_DMA) || \
      defined(CONFIG_SND_ATMEL_SOC_DMA_MODULE)
  int atmel_pcm_dma_platform_register(struct device *dev);
-void atmel_pcm_dma_platform_unregister(struct device *dev);
  #else
  static inline int atmel_pcm_dma_platform_register(struct device *dev)
  {
      return 0;
  }
-static inline void atmel_pcm_dma_platform_unregister(struct device *dev)
-{
-}
  #endif
 
  #endif /* _ATMEL_PCM_H */
sound/soc/atmel/atmel_ssc_dai.c +1 -3
index 8697ced..13aaa7d 100644
@@ -792,9 +792,7 @@ static void asoc_ssc_exit(struct device *dev)
      struct platform_device *pdev = to_platform_device(dev);
      struct ssc_device *ssc = platform_get_drvdata(pdev);
 
-    if (ssc->pdata->use_dma)
-        atmel_pcm_dma_platform_unregister(dev);
-    else
+    if (!ssc->pdata->use_dma)
          atmel_pcm_pdc_platform_unregister(dev);
 
Quoted 6 lines

sound/soc/atmel/atmel_ssc_dai.c static void asoc_ssc_exit(struct device *dev) · line 798

Quoted 2 lines
sound/soc/atmel/atmel_ssc_dai.c +0 -0
      snd_soc_unregister_component(dev);

Best Regards,
Bo Shen

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

author maintainer
#5 lore raw

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

In reply to Lars-Peter Clausen

Makes the code slightly shorter.

---
 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
author maintainer
#6 lore raw

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

In reply to Lars-Peter Clausen

Makes the code shorter.

---
 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
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.

---
 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
Acked-by on v1 5/6
#8 lore raw

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

sound/soc/spear/spear_pcm.c static const struct snd_dmaengine_pcm_config spear_dmaengine_pcm_config = { · line 62

Quoted 11 lines · Lars-Peter Clausen

snd_dmaengine_pcm_register(&pdev->dev,
&spear_dmaengine_pcm_config,
SND_DMAENGINE_PCM_FLAG_NO_DT |
SND_DMAENGINE_PCM_FLAG_COMPAT);
}

sound/soc/spear/spear_pcm.c +0 -5
-static int spear_soc_platform_remove(struct platform_device *pdev)
-{
-	snd_dmaengine_pcm_unregister(&pdev->dev);
-	return 0;
-}
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.

---
 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
#10 lore raw
In reply to Lars-Peter Clausen
Quoted 3 lines · Lars-Peter Clausen
---
 include/sound/dmaengine_pcm.h         |  4 ++++
 sound/soc/soc-generic-dmaengine-pcm.c | 36 +++++++++++++++++++++++++++++++++++

Please put the code in soc-devres.c. Otherwise this looks good, thanks!

author maintainer
#11 lore raw
Quoted 8 lines · Mark Brown
Quoted 3 lines · Lars-Peter Clausen
---
  include/sound/dmaengine_pcm.h         |  4 ++++
  sound/soc/soc-generic-dmaengine-pcm.c | 36 +++++++++++++++++++++++++++++++++++

Please put the code in soc-devres.c. Otherwise this looks good, thanks!

I didn't put it there because it has a dependency on SND_SOC_GENERIC_DMAENGINE_PCM. Sothe options were to either add ifdefery to soc-devres.c or to put the managed function in soc-generic-dmaengine-pcm.c.

- Lars

maintainer
#12 lore raw
Quoted 4 lines · Lars-Peter Clausen

I didn't put it there because it has a dependency on SND_SOC_GENERIC_DMAENGINE_PCM. Sothe options were to either add ifdefery to soc-devres.c or to put the managed function in soc-generic-dmaengine-pcm.c.

Hrm, OK though I'd probably have gone with the ifdefs on this one. I'll wait for more testing anyway.

author maintainer
#13 lore raw
Quoted 10 lines · Mark Brown
Quoted 4 lines · Lars-Peter Clausen

I didn't put it there because it has a dependency on SND_SOC_GENERIC_DMAENGINE_PCM. Sothe options were to either add ifdefery to soc-devres.c or to put the managed function in soc-generic-dmaengine-pcm.c.

Hrm, OK though I'd probably have gone with the ifdefs on this one. I'll wait for more testing anyway.

I'll change it for v2, no problem.