public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean-Francois Moine <moinejf@free.fr>
To: Xiubo Li <Li.Xiubo@freescale.com>
Cc: <broonie@linaro.org>,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	<kuninori.morimoto.gx@renesas.com>
Subject: Re: [alsa-devel] [PATCH] ASoC: simple-card: fix one bug to writing to the platform data
Date: Fri, 10 Jan 2014 08:17:29 +0100	[thread overview]
Message-ID: <20140110081729.035ce46f@armhf> (raw)

Xiubo Li wrote:

> It's a bug that writing to the platform data directly, for it should
> be constant. So just copy it before writing.
> 
> Signed-off-by: Xiubo Li <Li.Xiubo at freescale.com>
> ---
>  sound/soc/generic/simple-card.c | 40 +++++++++++++++++++++-------------------
>  1 file changed, 21 insertions(+), 19 deletions(-)
> 
> diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
> index 406e4ea..5b65324 100644
> --- a/sound/soc/generic/simple-card.c
> +++ b/sound/soc/generic/simple-card.c
	[snip]
> @@ -204,36 +205,37 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
>  	struct device_node *np = pdev->dev.of_node;
>  	struct device_node *of_cpu, *of_codec, *of_platform;
>  	struct device *dev = &pdev->dev;
> +	int ret;
>  
>  	cinfo		= NULL;
>  	of_cpu		= NULL;
>  	of_codec	= NULL;
>  	of_platform	= NULL;
> +
> +	cinfo = devm_kzalloc(dev, sizeof(*cinfo), GFP_KERNEL);
> +	if (!cinfo)
> +		return -ENOMEM;
> +
>  	if (np && of_device_is_available(np)) {
> -		cinfo = devm_kzalloc(dev, sizeof(*cinfo), GFP_KERNEL);
> -		if (cinfo) {
> -			int ret;
> -			cinfo->snd_card.dev = &pdev->dev;
> -			ret = asoc_simple_card_parse_of(np, cinfo, dev,
> -							&of_cpu,
> -							&of_codec,
> -							&of_platform);
> -			if (ret < 0) {
> -				if (ret != -EPROBE_DEFER)
> -					dev_err(dev, "parse error %d\n", ret);
> -				return ret;
> -			}
> -		} else {
> -			return -ENOMEM;
> +		cinfo->snd_card.dev = dev;
> +
> +		ret = asoc_simple_card_parse_of(np, cinfo, dev,
> +						&of_cpu,
> +						&of_codec,
> +						&of_platform);
> +		if (ret < 0) {
> +			if (ret != -EPROBE_DEFER)
> +				dev_err(dev, "parse error %d\n", ret);
> +			return ret;
>  		}
>  	} else {
> -		cinfo = pdev->dev.platform_data;
> -		if (!cinfo) {
> +		if (!pdev->dev.platform_data) {
>  			dev_err(dev, "no info for asoc-simple-card\n");
>  			return -EINVAL;
>  		}
>  
> -		cinfo->snd_card.dev = &pdev->dev;
> +		memcpy(cinfo, pdev->dev.platform_data, sizeof(cinfo));
> +		cinfo->snd_card.dev = dev;
>  	}
>  
>  	if (!cinfo->name	||

If the original cinfo is not used anymore, the use of its structure to
handle the card information is not a good idea:

- almost all cinfo information are in the struct snd_soc_card,

- this cinfo structure cannot be extended to handle many DAI links,

- it contains simple-card information which are of no use for the
  platform caller.

So, I'd rather have seen:

- the removal of 'snd_link' and 'snd_card' from the platform interface
  (struct asoc_simple_card_info),

- the definition of a local struct simple_card_data containing the
  struct snd_soc_card and a pointer to an array of fmt/sysclk values
  (one per DAI link).

-- 
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/

             reply	other threads:[~2014-01-10  7:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-10  7:17 Jean-Francois Moine [this message]
2014-01-13  2:02 ` [alsa-devel] [PATCH] ASoC: simple-card: fix one bug to writing to the platform data Li.Xiubo
2014-01-13  9:09 ` Li.Xiubo
2014-01-13 11:25   ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140110081729.035ce46f@armhf \
    --to=moinejf@free.fr \
    --cc=Li.Xiubo@freescale.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@linaro.org \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox