* [PATCH] ASoC: Fix passing platform_data to ac97 bus users and fix a leak.
@ 2010-03-24 4:29 Graham Gower
2010-03-24 9:23 ` Liam Girdwood
2010-03-24 13:06 ` Mark Brown
0 siblings, 2 replies; 6+ messages in thread
From: Graham Gower @ 2010-03-24 4:29 UTC (permalink / raw)
To: alsa-devel
snd_soc_new_ac97_codec() allocates for codec->ac97, snd_soc_new_pcms()
then sets the platform_data. However, snd_ac97_mixer() overwrites
codec->ac97 with its own allocated struct snd_ac97.
Signed-off-by: Graham Gower <graham.gower@gmail.com>
---
sound/soc/codecs/ac97.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c
index a1bbe16..64ec797 100644
--- a/sound/soc/codecs/ac97.c
+++ b/sound/soc/codecs/ac97.c
@@ -80,9 +80,11 @@ static int ac97_write(struct snd_soc_codec *codec, unsigned int reg,
static int ac97_soc_probe(struct platform_device *pdev)
{
struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+ struct snd_soc_card *card = socdev->card;
struct snd_soc_codec *codec;
struct snd_ac97_bus *ac97_bus;
struct snd_ac97_template ac97_template;
+ int i;
int ret = 0;
printk(KERN_INFO "AC97 SoC Audio Codec %s\n", AC97_VERSION);
@@ -118,11 +120,21 @@ static int ac97_soc_probe(struct platform_device *pdev)
if (ret < 0)
goto bus_err;
+ /* free the ac97 here so that we don't leak it in snd_ac97_mixer */
+ snd_soc_free_ac97_codec(codec);
+
memset(&ac97_template, 0, sizeof(struct snd_ac97_template));
ret = snd_ac97_mixer(ac97_bus, &ac97_template, &codec->ac97);
if (ret < 0)
goto bus_err;
+ for (i = 0; i < card->num_links; i++) {
+ if (card->dai_link[i].codec_dai->ac97_control) {
+ snd_ac97_dev_add_pdata(codec->ac97,
+ card->dai_link[i].cpu_dai->ac97_pdata);
+ }
+ }
+
return 0;
bus_err:
--
1.6.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] ASoC: Fix passing platform_data to ac97 bus users and fix a leak.
2010-03-24 4:29 [PATCH] ASoC: Fix passing platform_data to ac97 bus users and fix a leak Graham Gower
@ 2010-03-24 9:23 ` Liam Girdwood
2010-03-24 13:06 ` Mark Brown
1 sibling, 0 replies; 6+ messages in thread
From: Liam Girdwood @ 2010-03-24 9:23 UTC (permalink / raw)
To: Graham Gower; +Cc: alsa-devel
On Wed, 2010-03-24 at 14:59 +1030, Graham Gower wrote:
> snd_soc_new_ac97_codec() allocates for codec->ac97, snd_soc_new_pcms()
> then sets the platform_data. However, snd_ac97_mixer() overwrites
> codec->ac97 with its own allocated struct snd_ac97.
>
> Signed-off-by: Graham Gower <graham.gower@gmail.com>
> ---
> sound/soc/codecs/ac97.c | 12 ++++++++++++
> 1 files changed, 12 insertions(+), 0 deletions(-)
>
> diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c
> index a1bbe16..64ec797 100644
> --- a/sound/soc/codecs/ac97.c
> +++ b/sound/soc/codecs/ac97.c
> @@ -80,9 +80,11 @@ static int ac97_write(struct snd_soc_codec *codec, unsigned int reg,
> static int ac97_soc_probe(struct platform_device *pdev)
> {
> struct snd_soc_device *socdev = platform_get_drvdata(pdev);
> + struct snd_soc_card *card = socdev->card;
> struct snd_soc_codec *codec;
> struct snd_ac97_bus *ac97_bus;
> struct snd_ac97_template ac97_template;
> + int i;
> int ret = 0;
>
> printk(KERN_INFO "AC97 SoC Audio Codec %s\n", AC97_VERSION);
> @@ -118,11 +120,21 @@ static int ac97_soc_probe(struct platform_device *pdev)
> if (ret < 0)
> goto bus_err;
>
> + /* free the ac97 here so that we don't leak it in snd_ac97_mixer */
> + snd_soc_free_ac97_codec(codec);
> +
Can you try removing the call to snd_soc_new_ac97_codec() instead. I've
just had a quick look and the codec->ac97 is not used by any calls upto
this point except for snd_soc_new_pcms() adding the AC97 pdata (please
also add a check for valid codec->ac97 in snd_soc_new_pcms() before
setting pdata).
Sorry, I don't have any working AC97 hardware to test this myself today.
Thanks
Liam
--
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ASoC: Fix passing platform_data to ac97 bus users and fix a leak.
2010-03-24 4:29 [PATCH] ASoC: Fix passing platform_data to ac97 bus users and fix a leak Graham Gower
2010-03-24 9:23 ` Liam Girdwood
@ 2010-03-24 13:06 ` Mark Brown
2010-03-25 0:22 ` Graham Gower
1 sibling, 1 reply; 6+ messages in thread
From: Mark Brown @ 2010-03-24 13:06 UTC (permalink / raw)
To: Graham Gower; +Cc: alsa-devel
On Wed, Mar 24, 2010 at 02:59:08PM +1030, Graham Gower wrote:
> snd_soc_new_ac97_codec() allocates for codec->ac97, snd_soc_new_pcms()
> then sets the platform_data. However, snd_ac97_mixer() overwrites
> codec->ac97 with its own allocated struct snd_ac97.
Please remember to CC maintainers on patches, this helps avoid patches
getting lost in mailing lists - the procedure in SubmittingPatches
should generally be followed.
> @@ -118,11 +120,21 @@ static int ac97_soc_probe(struct platform_device *pdev)
> if (ret < 0)
> goto bus_err;
>
> + /* free the ac97 here so that we don't leak it in snd_ac97_mixer */
> + snd_soc_free_ac97_codec(codec);
> +
Like Liam says this seems wrong - why would we have allocated this early
on in the probe() only to free it later?
Note also that this code needs to work with both ASoC-native AC97
drivers and the ac97.c bodge.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ASoC: Fix passing platform_data to ac97 bus users and fix a leak.
2010-03-24 13:06 ` Mark Brown
@ 2010-03-25 0:22 ` Graham Gower
2010-03-25 8:55 ` Liam Girdwood
2010-03-25 16:09 ` Mark Brown
0 siblings, 2 replies; 6+ messages in thread
From: Graham Gower @ 2010-03-25 0:22 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood; +Cc: alsa-devel
Mark, Liam,
As requested, this patch removes the initial allocation of codec->ac97.
Signed-off-by: Graham Gower <graham.gower@gmail.com>
---
sound/soc/codecs/ac97.c | 15 +++++++++------
sound/soc/soc-core.c | 2 +-
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c
index a1bbe16..bcfa532 100644
--- a/sound/soc/codecs/ac97.c
+++ b/sound/soc/codecs/ac97.c
@@ -80,9 +80,11 @@ static int ac97_write(struct snd_soc_codec *codec, unsigned int reg,
static int ac97_soc_probe(struct platform_device *pdev)
{
struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+ struct snd_soc_card *card = socdev->card;
struct snd_soc_codec *codec;
struct snd_ac97_bus *ac97_bus;
struct snd_ac97_template ac97_template;
+ int i;
int ret = 0;
printk(KERN_INFO "AC97 SoC Audio Codec %s\n", AC97_VERSION);
@@ -102,12 +104,6 @@ static int ac97_soc_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&codec->dapm_widgets);
INIT_LIST_HEAD(&codec->dapm_paths);
- ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0);
- if (ret < 0) {
- printk(KERN_ERR "ASoC: failed to init gen ac97 glue\n");
- goto err;
- }
-
/* register pcms */
ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
if (ret < 0)
@@ -123,6 +119,13 @@ static int ac97_soc_probe(struct platform_device *pdev)
if (ret < 0)
goto bus_err;
+ for (i = 0; i < card->num_links; i++) {
+ if (card->dai_link[i].codec_dai->ac97_control) {
+ snd_ac97_dev_add_pdata(codec->ac97,
+ card->dai_link[i].cpu_dai->ac97_pdata);
+ }
+ }
+
return 0;
bus_err:
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index c8b0556..5704923 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1548,7 +1548,7 @@ int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid)
mutex_unlock(&codec->mutex);
return ret;
}
- if (card->dai_link[i].codec_dai->ac97_control) {
+ if (card->dai_link[i].codec_dai->ac97_control && codec->ac97) {
snd_ac97_dev_add_pdata(codec->ac97,
card->dai_link[i].cpu_dai->ac97_pdata);
}
--
1.6.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] ASoC: Fix passing platform_data to ac97 bus users and fix a leak.
2010-03-25 0:22 ` Graham Gower
@ 2010-03-25 8:55 ` Liam Girdwood
2010-03-25 16:09 ` Mark Brown
1 sibling, 0 replies; 6+ messages in thread
From: Liam Girdwood @ 2010-03-25 8:55 UTC (permalink / raw)
To: Graham Gower; +Cc: alsa-devel, Mark Brown
On Thu, 2010-03-25 at 10:52 +1030, Graham Gower wrote:
> Mark, Liam,
>
> As requested, this patch removes the initial allocation of codec->ac97.
>
>
> Signed-off-by: Graham Gower <graham.gower@gmail.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
--
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ASoC: Fix passing platform_data to ac97 bus users and fix a leak.
2010-03-25 0:22 ` Graham Gower
2010-03-25 8:55 ` Liam Girdwood
@ 2010-03-25 16:09 ` Mark Brown
1 sibling, 0 replies; 6+ messages in thread
From: Mark Brown @ 2010-03-25 16:09 UTC (permalink / raw)
To: Graham Gower; +Cc: alsa-devel, Liam Girdwood
On Thu, Mar 25, 2010 at 10:52:12AM +1030, Graham Gower wrote:
> Mark, Liam,
>
> As requested, this patch removes the initial allocation of codec->ac97.
Please recheck SubmittingPatches - this'd end up in the changelog (and
now your changelog is empty so it's not clear what the actual problem is
any more). I've applied this with a changelog added and...
> }
> - if (card->dai_link[i].codec_dai->ac97_control) {
> + if (card->dai_link[i].codec_dai->ac97_control && codec->ac97) {
> snd_ac97_dev_add_pdata(codec->ac97,
> card->dai_link[i].cpu_dai->ac97_pdata);
...a comment here since otherwise it's not obvious why we're not
complaining about the missing codec->ac97 otherwise.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-03-25 16:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-24 4:29 [PATCH] ASoC: Fix passing platform_data to ac97 bus users and fix a leak Graham Gower
2010-03-24 9:23 ` Liam Girdwood
2010-03-24 13:06 ` Mark Brown
2010-03-25 0:22 ` Graham Gower
2010-03-25 8:55 ` Liam Girdwood
2010-03-25 16:09 ` Mark Brown
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.