diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2013-01-28 01:25:43 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-01-28 01:46:09 -0500 |
commit | 1927661b1748480692f1fa2c390fe031c86d862a (patch) | |
tree | 674f9c0a5f08285d2b6c472bc2bdbfa635ea9668 /sound/soc/fsl | |
parent | 93d7b7622c199f1be25ca8fe64b3cbf468ea49b9 (diff) |
ASoC: fsl: fix snd-soc-imx-pcm module build
When building modules with CONFIG_SND_IMX_SOC=m in imx_v6_v7_defconfig,
we will see the following link error.
LD [M] sound/soc/fsl/snd-soc-fsl-ssi.o
LD [M] sound/soc/fsl/snd-soc-fsl-utils.o
LD [M] sound/soc/fsl/snd-soc-imx-ssi.o
LD [M] sound/soc/fsl/snd-soc-imx-audmux.o
LD [M] sound/soc/fsl/snd-soc-imx-pcm.o
sound/soc/fsl/imx-pcm-dma.o: In function `init_module':
imx-pcm-dma.c:(.init.text+0x0): multiple definition of `init_module'
sound/soc/fsl/imx-pcm-fiq.o:imx-pcm-fiq.c:(.init.text+0x0): first defined here
sound/soc/fsl/imx-pcm-dma.o: In function `cleanup_module':
imx-pcm-dma.c:(.exit.text+0x0): multiple definition of `cleanup_module'
sound/soc/fsl/imx-pcm-fiq.o:imx-pcm-fiq.c:(.exit.text+0x0): first defined here
make[4]: *** [sound/soc/fsl/snd-soc-imx-pcm.o] Error 1
The module snd-soc-imx-pcm is designed to link imx-pcm.o with
imx-pcm-dma.o or imx-pcm-fiq.o depending on if option SND_SOC_IMX_PCM_DMA
or SND_SOC_IMX_PCM_FIQ is enabled. Both imx-pcm-dma and imx-pcm-fiq
register their own module_platform_driver. However, these two options
are not mutually exclusive and can be enabled together. And that's
why we see above multiple init_module definition error.
Instead of having both imx-pcm-dma and imx-pcm-fiq register their
own platform_driver, we should do only once in imx-pcm.c. Using
platform_device_id to distinguish between imx-pcm-dma and imx-pcm-fiq,
we can run-time call imx-pcm-dma/fiq specific initialization in .probe
hook to have module snd-soc-imx-pcm work for both cases.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/fsl')
-rw-r--r-- | sound/soc/fsl/imx-pcm-dma.c | 21 | ||||
-rw-r--r-- | sound/soc/fsl/imx-pcm-fiq.c | 22 | ||||
-rw-r--r-- | sound/soc/fsl/imx-pcm.c | 32 | ||||
-rw-r--r-- | sound/soc/fsl/imx-pcm.h | 18 |
4 files changed, 52 insertions, 41 deletions
diff --git a/sound/soc/fsl/imx-pcm-dma.c b/sound/soc/fsl/imx-pcm-dma.c index bf363d8d044a..500f8ce55d78 100644 --- a/sound/soc/fsl/imx-pcm-dma.c +++ b/sound/soc/fsl/imx-pcm-dma.c | |||
@@ -154,26 +154,7 @@ static struct snd_soc_platform_driver imx_soc_platform_mx2 = { | |||
154 | .pcm_free = imx_pcm_free, | 154 | .pcm_free = imx_pcm_free, |
155 | }; | 155 | }; |
156 | 156 | ||
157 | static int imx_soc_platform_probe(struct platform_device *pdev) | 157 | int imx_pcm_dma_init(struct platform_device *pdev) |
158 | { | 158 | { |
159 | return snd_soc_register_platform(&pdev->dev, &imx_soc_platform_mx2); | 159 | return snd_soc_register_platform(&pdev->dev, &imx_soc_platform_mx2); |
160 | } | 160 | } |
161 | |||
162 | static int imx_soc_platform_remove(struct platform_device *pdev) | ||
163 | { | ||
164 | snd_soc_unregister_platform(&pdev->dev); | ||
165 | return 0; | ||
166 | } | ||
167 | |||
168 | static struct platform_driver imx_pcm_driver = { | ||
169 | .driver = { | ||
170 | .name = "imx-pcm-audio", | ||
171 | .owner = THIS_MODULE, | ||
172 | }, | ||
173 | .probe = imx_soc_platform_probe, | ||
174 | .remove = imx_soc_platform_remove, | ||
175 | }; | ||
176 | |||
177 | module_platform_driver(imx_pcm_driver); | ||
178 | MODULE_LICENSE("GPL"); | ||
179 | MODULE_ALIAS("platform:imx-pcm-audio"); | ||
diff --git a/sound/soc/fsl/imx-pcm-fiq.c b/sound/soc/fsl/imx-pcm-fiq.c index 5ec362ae4d01..920f945cb2f4 100644 --- a/sound/soc/fsl/imx-pcm-fiq.c +++ b/sound/soc/fsl/imx-pcm-fiq.c | |||
@@ -281,7 +281,7 @@ static struct snd_soc_platform_driver imx_soc_platform_fiq = { | |||
281 | .pcm_free = imx_pcm_fiq_free, | 281 | .pcm_free = imx_pcm_fiq_free, |
282 | }; | 282 | }; |
283 | 283 | ||
284 | static int imx_soc_platform_probe(struct platform_device *pdev) | 284 | int imx_pcm_fiq_init(struct platform_device *pdev) |
285 | { | 285 | { |
286 | struct imx_ssi *ssi = platform_get_drvdata(pdev); | 286 | struct imx_ssi *ssi = platform_get_drvdata(pdev); |
287 | int ret; | 287 | int ret; |
@@ -314,23 +314,3 @@ failed_register: | |||
314 | 314 | ||
315 | return ret; | 315 | return ret; |
316 | } | 316 | } |
317 | |||
318 | static int imx_soc_platform_remove(struct platform_device *pdev) | ||
319 | { | ||
320 | snd_soc_unregister_platform(&pdev->dev); | ||
321 | return 0; | ||
322 | } | ||
323 | |||
324 | static struct platform_driver imx_pcm_driver = { | ||
325 | .driver = { | ||
326 | .name = "imx-fiq-pcm-audio", | ||
327 | .owner = THIS_MODULE, | ||
328 | }, | ||
329 | |||
330 | .probe = imx_soc_platform_probe, | ||
331 | .remove = imx_soc_platform_remove, | ||
332 | }; | ||
333 | |||
334 | module_platform_driver(imx_pcm_driver); | ||
335 | |||
336 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/fsl/imx-pcm.c b/sound/soc/fsl/imx-pcm.c index d5cd9eff3b48..0d0625bfcb65 100644 --- a/sound/soc/fsl/imx-pcm.c +++ b/sound/soc/fsl/imx-pcm.c | |||
@@ -104,6 +104,38 @@ void imx_pcm_free(struct snd_pcm *pcm) | |||
104 | } | 104 | } |
105 | EXPORT_SYMBOL_GPL(imx_pcm_free); | 105 | EXPORT_SYMBOL_GPL(imx_pcm_free); |
106 | 106 | ||
107 | static int imx_pcm_probe(struct platform_device *pdev) | ||
108 | { | ||
109 | if (strcmp(pdev->id_entry->name, "imx-fiq-pcm-audio") == 0) | ||
110 | return imx_pcm_fiq_init(pdev); | ||
111 | |||
112 | return imx_pcm_dma_init(pdev); | ||
113 | } | ||
114 | |||
115 | static int imx_pcm_remove(struct platform_device *pdev) | ||
116 | { | ||
117 | snd_soc_unregister_platform(&pdev->dev); | ||
118 | return 0; | ||
119 | } | ||
120 | |||
121 | static struct platform_device_id imx_pcm_devtype[] = { | ||
122 | { .name = "imx-pcm-audio", }, | ||
123 | { .name = "imx-fiq-pcm-audio", }, | ||
124 | { /* sentinel */ } | ||
125 | }; | ||
126 | MODULE_DEVICE_TABLE(platform, imx_pcm_devtype); | ||
127 | |||
128 | static struct platform_driver imx_pcm_driver = { | ||
129 | .driver = { | ||
130 | .name = "imx-pcm", | ||
131 | .owner = THIS_MODULE, | ||
132 | }, | ||
133 | .id_table = imx_pcm_devtype, | ||
134 | .probe = imx_pcm_probe, | ||
135 | .remove = imx_pcm_remove, | ||
136 | }; | ||
137 | module_platform_driver(imx_pcm_driver); | ||
138 | |||
107 | MODULE_DESCRIPTION("Freescale i.MX PCM driver"); | 139 | MODULE_DESCRIPTION("Freescale i.MX PCM driver"); |
108 | MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>"); | 140 | MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>"); |
109 | MODULE_LICENSE("GPL"); | 141 | MODULE_LICENSE("GPL"); |
diff --git a/sound/soc/fsl/imx-pcm.h b/sound/soc/fsl/imx-pcm.h index 83c0ed7d55c9..5ae13a13a353 100644 --- a/sound/soc/fsl/imx-pcm.h +++ b/sound/soc/fsl/imx-pcm.h | |||
@@ -30,4 +30,22 @@ int snd_imx_pcm_mmap(struct snd_pcm_substream *substream, | |||
30 | int imx_pcm_new(struct snd_soc_pcm_runtime *rtd); | 30 | int imx_pcm_new(struct snd_soc_pcm_runtime *rtd); |
31 | void imx_pcm_free(struct snd_pcm *pcm); | 31 | void imx_pcm_free(struct snd_pcm *pcm); |
32 | 32 | ||
33 | #ifdef CONFIG_SND_SOC_IMX_PCM_DMA | ||
34 | int imx_pcm_dma_init(struct platform_device *pdev); | ||
35 | #else | ||
36 | static inline int imx_pcm_dma_init(struct platform_device *pdev) | ||
37 | { | ||
38 | return -ENODEV; | ||
39 | } | ||
40 | #endif | ||
41 | |||
42 | #ifdef CONFIG_SND_SOC_IMX_PCM_FIQ | ||
43 | int imx_pcm_fiq_init(struct platform_device *pdev); | ||
44 | #else | ||
45 | static inline int imx_pcm_fiq_init(struct platform_device *pdev) | ||
46 | { | ||
47 | return -ENODEV; | ||
48 | } | ||
49 | #endif | ||
50 | |||
33 | #endif /* _IMX_PCM_H */ | 51 | #endif /* _IMX_PCM_H */ |