Skip to contentSkip to conversation

ASoC: simple-card: fix one bug to writing to the platform data

PATCH Jean-Francois Moine 3 participants 4 messages Jan 10, 2014 – Jan 13, 2014

lore
Share & tools
lore
#0 lore raw

sound/soc/generic/simple-card.c

Quoted 12 lines · Xiubo Li

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(-)
sound/soc/generic/simple-card.c +0 -0
index 406e4ea..5b65324 100644
	[snip]
Quoted 46 lines
sound/soc/generic/simple-card.c +17 -17
@@ -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) {

sound/soc/generic/simple-card.c static int asoc_simple_card_probe(struct platform_device *pdev) · line 241

Quoted 10 lines
sound/soc/generic/simple-card.c +2 -1
 			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).

Signature · 2 lines
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/
#1 lore raw

Hi Jean-Francois,

Quoted 11 lines

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.

Quoted 9 lines

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).

I have sent one patch to fix some of these and mainly fixed the bug from Mark's comments in another early email.

Thanks,

--
Best Regards,
Xiubo

#2 lore raw
In reply to Jean-Francois Moine

Hi Mark, Jean-Francios

Quoted 10 lines

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.

Quoted 9 lines

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).

@Jean-Francios, apart from this separate issue we're discussing, do you have any comment on this patch itself?

@Mark, Since what Jean-Francios is concerned by is another issue apart from this patch itself and being discussed, can you apply the patch?

Thanks,

--
Best Regards,
Xiubo

#3 lore raw
Quoted 2 lines · On Mon, Jan 13, 2014 at 09:09:43AM +0000, [email protected] wrote:

@Mark, Since what Jean-Francios is concerned by is another issue apart from this patch itself and being discussed, can you apply the patch?

I thought I'd already applied it but if I didn't you'll need to resend.