[alsa-devel] [PATCH v2 01/10] ASoC: Change the PCM runtime array to a list

Lin, Mengdong mengdong.lin at intel.com
Mon Aug 17 08:28:48 CEST 2015


> -----Original Message-----
> From: Mark Brown [mailto:broonie at kernel.org]
> Sent: Saturday, August 15, 2015 4:03 AM

> On Mon, Aug 10, 2015 at 10:45:28PM +0800, mengdong.lin at intel.com wrote:
> 
> > +	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name);
> > +	codec_dai = rtd->codec_dai;
> > +
> 
> For ease of review please split the addition of this new interface for getting
> the runtime from the change to the implementation - the same function can
> be written in terms of a list.  As ever please make one change per commit :(

Okay. I'll split adding snd_soc_get_pcm_runtime() to a new commit.

> > +static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
> > +	struct snd_soc_card *card, struct snd_soc_dai_link *dai_link) {
> > +	struct snd_soc_pcm_runtime *rtd;
> > +
> > +	rtd = devm_kzalloc(card->dev,
> > +			sizeof(struct snd_soc_pcm_runtime), GFP_KERNEL);
> > +	if (!rtd)
> > +		return NULL;
> 
> Why are we allocating something with devm_kzalloc()...

I'll change to use kzalloc() and free the memory for the error path.

> > +static void soc_free_pcm_runtime(struct snd_soc_card *card,
> > +	struct snd_soc_pcm_runtime *rtd)
> > +{
> > +	if (rtd->codec_dai)
> > +		devm_kfree(card->dev, rtd->codec_dais);
> > +	devm_kfree(card->dev, rtd);
> > +}
> 
> ...things that we later explicitly free in (hopefully?) all cases.

Okay. 

> > +static void soc_remove_pcm_runtimes(struct snd_soc_card *card) {
> > +	struct snd_soc_pcm_runtime *rtd, *_rtd;
> > +
> > +	list_for_each_entry_safe(rtd, _rtd, &card->rtd_list, list) {
> > +		list_del(&rtd->list);
> > +		soc_free_pcm_runtime(card, rtd);
> > +	}
> > +
> > +	card->num_rtd = 0;
> > +}
> 
> Why doesn't the free function do the list removal?

Sorry, I'll add the list removal.

Thanks
Mengdong


More information about the Alsa-devel mailing list