RE: [PATCH 2/4] ASoC: simple-card: dynamically allocate the DAI link array

From: Li.Xiubo@xxxxxxxxxxxxx
Date: Sun Feb 23 2014 - 22:34:08 EST




> @@ -20,7 +20,6 @@ struct simple_card_data {
> unsigned int daifmt;
> struct asoc_simple_dai cpu_dai;
> struct asoc_simple_dai codec_dai;
> - struct snd_soc_dai_link snd_link;
> };
>
> static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai,
> @@ -246,7 +245,9 @@ static int asoc_simple_card_probe(struct platform_device
> *pdev)
> struct device *dev = &pdev->dev;
> int ret;
>
> - priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> + priv = devm_kzalloc(dev,
> + sizeof(*priv) + sizeof(*dai_link),

This is okey for me.

Well, how about splitting the *priv and *dai_link into two separated
memory blocks? As we can get the dai-link pointer via priv->snd_card.dai_link
in other places.

IMHO, then the code will be much more simplifier and readable.

Just for one suggestion.

Thanks,

--
Best regards,
Xiubo


> + GFP_KERNEL);
> if (!priv)
> return -ENOMEM;
>
> @@ -255,7 +256,7 @@ static int asoc_simple_card_probe(struct platform_device
> *pdev)
> */
> priv->snd_card.owner = THIS_MODULE;
> priv->snd_card.dev = dev;
> - dai_link = &priv->snd_link;
> + dai_link = (struct snd_soc_dai_link *) (priv + 1);
> priv->snd_card.dai_link = dai_link;
> priv->snd_card.num_links = 1;
>
> --
> 1.9.0
>
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/