Re: [alsa-devel] [PATCH] ASoC: Allocate PCM operations dynamically to support multiple DAIs
This looks wrong. It will probably cause regression for all non ASoC sound card drivers.
The issue this patch addresses came up before and I think the conclusion was that it is best to embed the snd_pcm_ops struct into the snd_soc_pcm_runtime struct.
Hi, I'm Sangsu Park. (sangsu4u.park@samsung.com) I'm using gmail because of company's firewall problems...
I agree you, So I've changed some code like follows. If you like that, I'll make patch version 2nd using that.
//------------------------------------------------------------------------------ diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 42ad2db..d1468aa 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -918,6 +918,9 @@ static void soc_remove_dai_link(struct snd_soc_card *card, int num, int order) list_del(&cpu_dai->card_list); module_put(cpu_dai->dev->driver->owner); } + + /* free the ops memory */ + if (rtd->ops) kfree(rtd->ops); } diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 8aa7cec..4eb793b 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -641,22 +645,23 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) INIT_DELAYED_WORK(&rtd->delayed_work, close_delayed_work); rtd->pcm = pcm; + rtd->ops = soc_pcm_ops; pcm->private_data = rtd; if (platform->driver->ops) { ------------------------------------------------------------------------------//
Thanks.
On Tue, Dec 27, 2011 at 05:06:56PM +0900, Sangsu Park wrote:
/* free the ops memory */
if (rtd->ops) kfree(rtd->ops);
We shouldn't be doing a kfree() on the ops at all.
+++ b/sound/soc/soc-pcm.c @@ -641,22 +645,23 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) INIT_DELAYED_WORK(&rtd->delayed_work, close_delayed_work); rtd->pcm = pcm;
rtd->ops = soc_pcm_ops;
That *might* work if ops were changed to be a member variable, though it's racy against two things initializing simultaneously.
What I'd expect is something like:
INIT_DELAYED_WORK(&rtd->delayed_work, close_delayed_work); rtd->pcm = pcm; rtd->pcm_ops = soc_pcm_ops; pcm->private_data = rtd; if (platform->driver->ops) { rtd->pcm_ops.mmap = platform->driver->ops->mmap; rtd->pcm_ops.pointer = platform->driver->ops->pointer;
and so on so we start off by taking a copy of the default ops then copy the new ops in in the same fashion.
Ideally we should also have an indirection for ioctl() though using it at all is dodgy.
participants (2)
-
Mark Brown
-
Sangsu Park