ASoC don't clobber platform DMA driver ops
PATCH 1/1 ASoC don't clobber platform DMA driver ops
Previously, only one static struct for ops existed for all platform DMA drivers to share. Half of the ops are shared functions and the other half are initialized to point directly to ops in the platform driver. This creates problems where each time soc_new_pcm is called, the new platform driver's ops would overwrite a subset of the ops.
This patch creates and populates a ops struct for each call to soc_pcm_new.
--- sound/soc/soc-core.c | 6 ++++++ sound/soc/soc-pcm.c | 48 ++++++++++++++++++++++++++++-------------------- 2 files changed, 34 insertions(+), 20 deletions(-)
sound/soc/soc-core.c +6 -0
@@ -1541,6 +1541,12 @@ static int soc_cleanup_card_resources(struct snd_soc_card *card)soc_cleanup_card_debugfs (card); +/* free the ops */ +for (i =0 ; i < card->num_rtd; i++) { +struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; +kfree (rtd->ops); + } +/* remove the card */ if (card->remove) card->remove (card);
sound/soc/soc-pcm.c +28 -20
88 lines not on this page · raw message
Signature · 1 line
1.6.0.4
Quoted 7 lines · Alan Tull
Previously, only one static struct for ops existed for all platform DMA drivers to share. Half of the ops are shared functions and the other half are initialized to point directly to ops in the platform driver. This creates problems where each time
soc_new_pcmis called, the new platform driver's ops would overwrite a subset of the ops.
Quoted 5 lines
This patch creates and populates a ops struct for each call to
soc_pcm_new.Signed-off-by Alan Tull <[email protected]>---
Something is wrong. When I apply this patch, I get this:
CC sound/soc/soc-core.o/home/b04825/git/linux.34/sound/soc/soc-core.c: In function 'soc_cleanup_card_resources':/home/b04825/git/linux.34/sound/soc/soc-core.c:1583:3: error:
incompatible type for argument 1 of 'kfree' /home/b04825/git/linux.34/include/linux/slab.h:161:6: note: expected 'const void *' but argument is of type 'struct snd_pcm_ops'
/* free the ops */
for (i = 0; i < card->num_rtd; i++) {
struct snd_soc_pcm_runtime *rtd = &card->rtd[i];
kfree(rtd->ops);
}rtd->ops is not a pointer, so it can't be freed. Also, this:
+ rtd->ops = soc_pcm_ops;
is a memcpy. Why not just write to rtd->ops directly?
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
Quoted 20 lines · On 11/15/2011 10:56 AM, Tabi Timur-B04825 wrote:
Something is wrong. When I apply this patch, I get this:
CC
sound/soc/soc-core.o/home/b04825/git/linux.34/sound/soc/soc-core.c: In function 'soc_cleanup_card_resources':/home/b04825/git/linux.34/sound/soc/soc-core.c:1583:3: error:
incompatible type for argument 1 of 'kfree'/home/b04825/git/linux.34/include/linux/slab.h:161:6: note: expected 'const void *' but argument is of type 'structsnd_pcm_ops'/* free the ops */ for (i = 0; i< card->num_rtd; i++) { struct snd_soc_pcm_runtime *rtd =&card->rtd[i]; kfree(rtd->ops); }
rtd->opsis not a pointer, so it can't be freed. Also, this:sound/soc/soc-pcm.c +1
-0+ rtd->ops = soc_pcm_ops;
Quoted 2 lines
is a memcpy. Why not just write to
rtd->opsdirectly?
I see the problem. I implemented this under 2.6.38. rtd->ops was a pointer under 2.6.38. This could change much then.
Signature · 2 lines
Regards, Alan