[alsa-devel] [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.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- include/sound/dmaengine_pcm.h | 4 ++++ sound/soc/soc-generic-dmaengine-pcm.c | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+)
diff --git a/include/sound/dmaengine_pcm.h b/include/sound/dmaengine_pcm.h index 1501731..4ef986c 100644 --- a/include/sound/dmaengine_pcm.h +++ b/include/sound/dmaengine_pcm.h @@ -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); diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index cbc9c96..20690c0 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c @@ -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");
Makes the code shorter.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- 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(-)
diff --git a/sound/soc/atmel/atmel-pcm-dma.c b/sound/soc/atmel/atmel-pcm-dma.c index 06082e5..7dbc0e9 100644 --- a/sound/soc/atmel/atmel-pcm-dma.c +++ b/sound/soc/atmel/atmel-pcm-dma.c @@ -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 voice.shen@atmel.com"); MODULE_DESCRIPTION("Atmel DMA based PCM module"); MODULE_LICENSE("GPL"); diff --git a/sound/soc/atmel/atmel-pcm.h b/sound/soc/atmel/atmel-pcm.h index 12ae814..bb71069 100644 --- a/sound/soc/atmel/atmel-pcm.h +++ b/sound/soc/atmel/atmel-pcm.h @@ -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 */ diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index 8697ced..13aaa7d 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -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);
Hi Lars-Perter,
On 11/24/2013 09:20 PM, Lars-Peter Clausen wrote:
Makes the code shorter.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de
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---
diff --git a/sound/soc/atmel/atmel-pcm-dma.c b/sound/soc/atmel/atmel-pcm-dma.c index 06082e5..7dbc0e9 100644 --- a/sound/soc/atmel/atmel-pcm-dma.c +++ b/sound/soc/atmel/atmel-pcm-dma.c @@ -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 voice.shen@atmel.com"); MODULE_DESCRIPTION("Atmel DMA based PCM module"); MODULE_LICENSE("GPL");
diff --git a/sound/soc/atmel/atmel-pcm.h b/sound/soc/atmel/atmel-pcm.h index 12ae814..bb71069 100644 --- a/sound/soc/atmel/atmel-pcm.h +++ b/sound/soc/atmel/atmel-pcm.h @@ -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 */ diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index 8697ced..13aaa7d 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -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
On 11/25/2013 11:36 AM, Bo Shen wrote:
Hi Lars-Perter,
On 11/24/2013 09:20 PM, Lars-Peter Clausen wrote:
Makes the code shorter.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de
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).
Does it work without the patch?
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---
diff --git a/sound/soc/atmel/atmel-pcm-dma.c b/sound/soc/atmel/atmel-pcm-dma.c index 06082e5..7dbc0e9 100644 --- a/sound/soc/atmel/atmel-pcm-dma.c +++ b/sound/soc/atmel/atmel-pcm-dma.c @@ -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 voice.shen@atmel.com"); MODULE_DESCRIPTION("Atmel DMA based PCM module"); MODULE_LICENSE("GPL");
diff --git a/sound/soc/atmel/atmel-pcm.h b/sound/soc/atmel/atmel-pcm.h index 12ae814..bb71069 100644 --- a/sound/soc/atmel/atmel-pcm.h +++ b/sound/soc/atmel/atmel-pcm.h @@ -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 */ diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index 8697ced..13aaa7d 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -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
On 11/25/2013 11:41 AM, Lars-Peter Clausen wrote:
On 11/25/2013 11:36 AM, Bo Shen wrote:
Hi Lars-Perter,
On 11/24/2013 09:20 PM, Lars-Peter Clausen wrote:
Makes the code shorter.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de
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).
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
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---
diff --git a/sound/soc/atmel/atmel-pcm-dma.c b/sound/soc/atmel/atmel-pcm-dma.c index 06082e5..7dbc0e9 100644 --- a/sound/soc/atmel/atmel-pcm-dma.c +++ b/sound/soc/atmel/atmel-pcm-dma.c @@ -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 voice.shen@atmel.com"); MODULE_DESCRIPTION("Atmel DMA based PCM module"); MODULE_LICENSE("GPL");
diff --git a/sound/soc/atmel/atmel-pcm.h b/sound/soc/atmel/atmel-pcm.h index 12ae814..bb71069 100644 --- a/sound/soc/atmel/atmel-pcm.h +++ b/sound/soc/atmel/atmel-pcm.h @@ -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 */ diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index 8697ced..13aaa7d 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -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
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Makes the code slightly shorter.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- sound/soc/cirrus/ep93xx-pcm.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/sound/soc/cirrus/ep93xx-pcm.c b/sound/soc/cirrus/ep93xx-pcm.c index cfe517e..fdb8b8f 100644 --- a/sound/soc/cirrus/ep93xx-pcm.c +++ b/sound/soc/cirrus/ep93xx-pcm.c @@ -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);
Makes the code shorter.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- 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(-)
diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c index 55193a5..4d075f1 100644 --- a/sound/soc/fsl/fsl_spdif.c +++ b/sound/soc/fsl/fsl_spdif.c @@ -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); diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index fb8f52a..3df0318 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -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) diff --git a/sound/soc/fsl/imx-pcm-dma.c b/sound/soc/fsl/imx-pcm-dma.c index aee2307..c5e47f8 100644 --- a/sound/soc/fsl/imx-pcm-dma.c +++ b/sound/soc/fsl/imx-pcm-dma.c @@ -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"); diff --git a/sound/soc/fsl/imx-pcm.h b/sound/soc/fsl/imx-pcm.h index 5d5b733..c79cb27 100644 --- a/sound/soc/fsl/imx-pcm.h +++ b/sound/soc/fsl/imx-pcm.h @@ -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) diff --git a/sound/soc/fsl/imx-ssi.c b/sound/soc/fsl/imx-ssi.c index f5f248c..cc7376f 100644 --- a/sound/soc/fsl/imx-ssi.c +++ b/sound/soc/fsl/imx-ssi.c @@ -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);
Makes the code slightly shorter.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- sound/soc/spear/spear_pcm.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/sound/soc/spear/spear_pcm.c b/sound/soc/spear/spear_pcm.c index 4707f2b..9a02141 100644 --- a/sound/soc/spear/spear_pcm.c +++ b/sound/soc/spear/spear_pcm.c @@ -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);
On 11/24/2013 6:51 PM, Lars-Peter Clausen wrote:
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;
-}
Acked-by: Rajeev Kumar rajeev-dlh.kumar@st.com
Makes the code shorter.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- 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(-)
diff --git a/sound/soc/mxs/mxs-pcm.c b/sound/soc/mxs/mxs-pcm.c index b16abbb..04a6b0d 100644 --- a/sound/soc/mxs/mxs-pcm.c +++ b/sound/soc/mxs/mxs-pcm.c @@ -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"); diff --git a/sound/soc/mxs/mxs-pcm.h b/sound/soc/mxs/mxs-pcm.h index bc685b6..035ea04 100644 --- a/sound/soc/mxs/mxs-pcm.h +++ b/sound/soc/mxs/mxs-pcm.h @@ -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 diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index 54e622a..92db74d 100644 --- a/sound/soc/mxs/mxs-saif.c +++ b/sound/soc/mxs/mxs-saif.c @@ -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",
On Sun, Nov 24, 2013 at 02:20:57PM +0100, Lars-Peter Clausen wrote:
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!
On 11/25/2013 06:19 PM, Mark Brown wrote:
On Sun, Nov 24, 2013 at 02:20:57PM +0100, Lars-Peter Clausen wrote:
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
On Mon, Nov 25, 2013 at 06:42:56PM +0100, Lars-Peter Clausen wrote:
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.
On 11/25/2013 07:23 PM, Mark Brown wrote:
On Mon, Nov 25, 2013 at 06:42:56PM +0100, Lars-Peter Clausen wrote:
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.
participants (4)
-
Bo Shen
-
Lars-Peter Clausen
-
Mark Brown
-
Rajeev kumar