Re: [PATCH v3] ASOC: dapm: add code to configure dai link parameters

From: Mark Brown
Date: Mon Aug 18 2014 - 14:54:04 EST


On Wed, Aug 06, 2014 at 05:16:26PM +0100, Nikesh Oswal wrote:

> +/* create new dapm dai link control */
> +static int dapm_new_dai_link(struct snd_soc_dapm_widget *w)
> +{
> + int i, ret;
> + struct snd_kcontrol *kcontrol;
> + struct snd_soc_dapm_context *dapm = w->dapm;
> + struct snd_card *card = dapm->card->snd_card;
> +
> +
> + /* add kcontrol */
> + for (i = 0; i < w->num_kcontrols; i++) {
> + kcontrol = snd_soc_cnew(&w->kcontrol_news[i], w,
> + w->name, NULL);

We appear to be creating the control unconditionally so even a link
which has only one configuration will have a control created which
doesn't seem right. Suppressing the control creation for links that
only have one configuration seems better.

Throughout this you've got coding style problems, you're not indenting
the continuations of multi-line statements. Please try to follow the
kernel coding style, if your code is visibly different to the rest of
the codebase that's not good.

> + for (count = 0 ; count < num_params; count++) {
> + w_param_text[count] = kzalloc(sizeof(char) * 100, GFP_KERNEL);

Random number!

> + if (!w_param_text) {
> + ret = -ENOMEM;
> + goto outfree_w_param;
> + }
> +
> + sprintf(w_param_text[count], "SampleRate=%d:Channels=%d:BitsPerSample=%d",
> + config->rate_min, config->channels_min,
> + snd_pcm_format_width(ffs(config->formats) - 1));
> + config++;

The configurations have user speciable names in them which are being
ignored here - this means that users can't specify names that are
meaningful for their systems.

Attachment: signature.asc
Description: Digital signature