linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/8] ASoC: simple-card: simplify code
       [not found] <20140115113551.0eb13409@armhf>
@ 2014-01-15 15:51 ` Jean-Francois Moine
  2014-01-22 19:04   ` Mark Brown
  2014-01-15 15:51 ` [PATCH v2 2/8] " Jean-Francois Moine
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Jean-Francois Moine @ 2014-01-15 15:51 UTC (permalink / raw)
  To: Mark Brown, lgirdwood
  Cc: alsa-devel, linux-kernel, kuninori.morimoto.gx, Xiubo Li

The check of the mandatory fields is done for DT in its specific sequence.
Move the global check to the non-DT sequence.

Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
---
 sound/soc/generic/simple-card.c      | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 2a1b1b5..f0784ca 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -225,16 +225,16 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
 
 		memcpy(cinfo, dev->platform_data, sizeof(*cinfo));
 		cinfo->snd_card.dev = dev;
-	}
 
-	if (!cinfo->name	||
-	    !cinfo->card	||
-	    !cinfo->codec_dai.name	||
-	    !(cinfo->codec		|| of_codec)	||
-	    !(cinfo->platform		|| of_platform)	||
-	    !(cinfo->cpu_dai.name	|| of_cpu)) {
-		dev_err(dev, "insufficient asoc_simple_card_info settings\n");
-		return -EINVAL;
+		if (!cinfo->name	||
+		    !cinfo->card	||
+		    !cinfo->codec_dai.name	||
+		    !cinfo->codec	||
+		    !cinfo->platform	||
+		    !cinfo->cpu_dai.name) {
+			dev_err(dev, "insufficient asoc_simple_card_info settings\n");
+			return -EINVAL;
+		}
 	}
 
 	/*
-- 
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 2/8] ASoC: simple-card: simplify code
       [not found] <20140115113551.0eb13409@armhf>
  2014-01-15 15:51 ` [PATCH v2 1/8] ASoC: simple-card: simplify code Jean-Francois Moine
@ 2014-01-15 15:51 ` Jean-Francois Moine
  2014-01-22 19:06   ` Mark Brown
  2014-01-15 15:51 ` [PATCH v2 3/8] " Jean-Francois Moine
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Jean-Francois Moine @ 2014-01-15 15:51 UTC (permalink / raw)
  To: Mark Brown, lgirdwood
  Cc: alsa-devel, linux-kernel, kuninori.morimoto.gx, Xiubo Li

The DT values are copied to the non-DT structure before being moved to
the card structure.
Set directly the DT values in the card and move the non-DT copy to the
non-DT sequence.

Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
---
 sound/soc/generic/simple-card.c     | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index f0784ca..7c5dc73 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -169,12 +169,13 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 			    strlen(info->codec_dai.name) + 2,
 			    GFP_KERNEL);
 	sprintf(name, "%s-%s", info->cpu_dai.name, info->codec_dai.name);
-	info->name = info->card = name;
+	info->snd_card.name = name;
+	info->snd_link.name = info->snd_link.stream_name = name;
 
 	/* simple-card assumes platform == cpu */
 	*of_platform = *of_cpu;
 
-	dev_dbg(dev, "card-name : %s\n", info->card);
+	dev_dbg(dev, "card-name : %s\n", name);
 	dev_dbg(dev, "platform : %04x\n", info->daifmt);
 	dev_dbg(dev, "cpu : %s / %04x / %d\n",
 		info->cpu_dai.name,
@@ -217,6 +218,9 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
 				dev_err(dev, "parse error %d\n", ret);
 			return ret;
 		}
+		cinfo->snd_link.cpu_of_node	= of_cpu;
+		cinfo->snd_link.codec_of_node	= of_codec;
+		cinfo->snd_link.platform_of_node = of_platform;
 	} else {
 		if (!dev->platform_data) {
 			dev_err(dev, "no info for asoc-simple-card\n");
@@ -235,26 +239,24 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
 			dev_err(dev, "insufficient asoc_simple_card_info settings\n");
 			return -EINVAL;
 		}
+
+		cinfo->snd_card.name		= cinfo->card;
+		cinfo->snd_link.name		= cinfo->name;
+		cinfo->snd_link.stream_name	= cinfo->name;
+		cinfo->snd_link.platform_name	= cinfo->platform;
+		cinfo->snd_link.codec_name	= cinfo->codec;
 	}
 
 	/*
 	 * init snd_soc_dai_link
 	 */
-	cinfo->snd_link.name		= cinfo->name;
-	cinfo->snd_link.stream_name	= cinfo->name;
 	cinfo->snd_link.cpu_dai_name	= cinfo->cpu_dai.name;
-	cinfo->snd_link.platform_name	= cinfo->platform;
-	cinfo->snd_link.codec_name	= cinfo->codec;
 	cinfo->snd_link.codec_dai_name	= cinfo->codec_dai.name;
-	cinfo->snd_link.cpu_of_node	= of_cpu;
-	cinfo->snd_link.codec_of_node	= of_codec;
-	cinfo->snd_link.platform_of_node = of_platform;
 	cinfo->snd_link.init		= asoc_simple_card_dai_init;
 
 	/*
 	 * init snd_soc_card
 	 */
-	cinfo->snd_card.name		= cinfo->card;
 	cinfo->snd_card.owner		= THIS_MODULE;
 	cinfo->snd_card.dai_link	= &cinfo->snd_link;
 	cinfo->snd_card.num_links	= 1;
-- 
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 3/8] ASoC: simple-card: simplify code
       [not found] <20140115113551.0eb13409@armhf>
  2014-01-15 15:51 ` [PATCH v2 1/8] ASoC: simple-card: simplify code Jean-Francois Moine
  2014-01-15 15:51 ` [PATCH v2 2/8] " Jean-Francois Moine
@ 2014-01-15 15:51 ` Jean-Francois Moine
  2014-01-22 19:25   ` Mark Brown
  2014-01-15 15:51 ` [PATCH v2 4/8] " Jean-Francois Moine
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Jean-Francois Moine @ 2014-01-15 15:51 UTC (permalink / raw)
  To: Mark Brown, lgirdwood
  Cc: alsa-devel, linux-kernel, kuninori.morimoto.gx, Xiubo Li

The OF pointers are put in the stack and then copied to the card
descriptor.
Put them directly at their right place.

Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
---
 sound/soc/generic/simple-card.c     | 55 ++++++++--------------
 1 file changed, 20 insertions(+), 35 deletions(-)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 7c5dc73..89f83b3 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -60,8 +60,9 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
 static int
 asoc_simple_card_sub_parse_of(struct device_node *np,
 			      struct asoc_simple_dai *dai,
-			      struct device_node **node)
+			      const struct device_node **p_node)
 {
+	struct device_node *node;
 	struct clk *clk;
 	int ret;
 
@@ -69,9 +70,10 @@ asoc_simple_card_sub_parse_of(struct device_node *np,
 	 * get node via "sound-dai = <&phandle port>"
 	 * it will be used as xxx_of_node on soc_bind_dai_link()
 	 */
-	*node = of_parse_phandle(np, "sound-dai", 0);
-	if (!*node)
+	node = of_parse_phandle(np, "sound-dai", 0);
+	if (!node)
 		return -ENODEV;
+	*p_node = node;
 
 	/* get dai->name */
 	ret = snd_soc_of_get_dai_name(np, &dai->name);
@@ -104,7 +106,7 @@ asoc_simple_card_sub_parse_of(struct device_node *np,
 				     "system-clock-frequency",
 				     &dai->sysclk);
 	} else {
-		clk = of_clk_get(*node, 0);
+		clk = of_clk_get(node, 0);
 		if (!IS_ERR(clk))
 			dai->sysclk = clk_get_rate(clk);
 	}
@@ -112,17 +114,14 @@ asoc_simple_card_sub_parse_of(struct device_node *np,
 	ret = 0;
 
 parse_error:
-	of_node_put(*node);
+	of_node_put(node);
 
 	return ret;
 }
 
 static int asoc_simple_card_parse_of(struct device_node *node,
 				     struct asoc_simple_card_info *info,
-				     struct device *dev,
-				     struct device_node **of_cpu,
-				     struct device_node **of_codec,
-				     struct device_node **of_platform)
+				     struct device *dev)
 {
 	struct device_node *np;
 	char *name;
@@ -146,7 +145,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 	if (np)
 		ret = asoc_simple_card_sub_parse_of(np,
 						  &info->cpu_dai,
-						  of_cpu);
+						  &info->snd_link.cpu_of_node);
 	if (ret < 0)
 		return ret;
 
@@ -156,7 +155,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 	if (np)
 		ret = asoc_simple_card_sub_parse_of(np,
 						  &info->codec_dai,
-						  of_codec);
+						  &info->snd_link.codec_of_node);
 	if (ret < 0)
 		return ret;
 
@@ -173,7 +172,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 	info->snd_link.name = info->snd_link.stream_name = name;
 
 	/* simple-card assumes platform == cpu */
-	*of_platform = *of_cpu;
+	info->snd_link.platform_of_node = info->snd_link.cpu_of_node;
 
 	dev_dbg(dev, "card-name : %s\n", name);
 	dev_dbg(dev, "platform : %04x\n", info->daifmt);
@@ -193,34 +192,29 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
 {
 	struct asoc_simple_card_info *cinfo;
 	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;
 
+	/*
+	 * init snd_soc_card
+	 */
+	cinfo->snd_card.owner		= THIS_MODULE;
+	cinfo->snd_card.dev = dev;
+	cinfo->snd_card.dai_link	= &cinfo->snd_link;
+	cinfo->snd_card.num_links	= 1;
+
 	if (np && of_device_is_available(np)) {
-		cinfo->snd_card.dev = dev;
 
-		ret = asoc_simple_card_parse_of(np, cinfo, dev,
-						&of_cpu,
-						&of_codec,
-						&of_platform);
+		ret = asoc_simple_card_parse_of(np, cinfo, dev);
 		if (ret < 0) {
 			if (ret != -EPROBE_DEFER)
 				dev_err(dev, "parse error %d\n", ret);
 			return ret;
 		}
-		cinfo->snd_link.cpu_of_node	= of_cpu;
-		cinfo->snd_link.codec_of_node	= of_codec;
-		cinfo->snd_link.platform_of_node = of_platform;
 	} else {
 		if (!dev->platform_data) {
 			dev_err(dev, "no info for asoc-simple-card\n");
@@ -228,8 +222,6 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
 		}
 
 		memcpy(cinfo, dev->platform_data, sizeof(*cinfo));
-		cinfo->snd_card.dev = dev;
-
 		if (!cinfo->name	||
 		    !cinfo->card	||
 		    !cinfo->codec_dai.name	||
@@ -254,13 +246,6 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
 	cinfo->snd_link.codec_dai_name	= cinfo->codec_dai.name;
 	cinfo->snd_link.init		= asoc_simple_card_dai_init;
 
-	/*
-	 * init snd_soc_card
-	 */
-	cinfo->snd_card.owner		= THIS_MODULE;
-	cinfo->snd_card.dai_link	= &cinfo->snd_link;
-	cinfo->snd_card.num_links	= 1;
-
 	snd_soc_card_set_drvdata(&cinfo->snd_card, cinfo);
 
 	return devm_snd_soc_register_card(&pdev->dev, &cinfo->snd_card);
-- 
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 4/8] ASoC: simple-card: simplify code
       [not found] <20140115113551.0eb13409@armhf>
                   ` (2 preceding siblings ...)
  2014-01-15 15:51 ` [PATCH v2 3/8] " Jean-Francois Moine
@ 2014-01-15 15:51 ` Jean-Francois Moine
  2014-01-22 19:26   ` Mark Brown
  2014-01-15 15:51 ` [PATCH v2 5/8] " Jean-Francois Moine
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Jean-Francois Moine @ 2014-01-15 15:51 UTC (permalink / raw)
  To: Mark Brown, lgirdwood
  Cc: alsa-devel, linux-kernel, kuninori.morimoto.gx, Xiubo Li

Have a cleaner code using a DAI link pointer.

Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
---
 sound/soc/generic/simple-card.c     | 29 ++++++++++++----------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 89f83b3..797696f 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -123,6 +123,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 				     struct asoc_simple_card_info *info,
 				     struct device *dev)
 {
+	struct snd_soc_dai_link *dai_link = info->snd_card.dai_link;
 	struct device_node *np;
 	char *name;
 	int ret;
@@ -145,7 +146,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 	if (np)
 		ret = asoc_simple_card_sub_parse_of(np,
 						  &info->cpu_dai,
-						  &info->snd_link.cpu_of_node);
+						  &dai_link->cpu_of_node);
 	if (ret < 0)
 		return ret;
 
@@ -155,7 +156,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 	if (np)
 		ret = asoc_simple_card_sub_parse_of(np,
 						  &info->codec_dai,
-						  &info->snd_link.codec_of_node);
+						  &dai_link->codec_of_node);
 	if (ret < 0)
 		return ret;
 
@@ -169,10 +170,10 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 			    GFP_KERNEL);
 	sprintf(name, "%s-%s", info->cpu_dai.name, info->codec_dai.name);
 	info->snd_card.name = name;
-	info->snd_link.name = info->snd_link.stream_name = name;
+	dai_link->name = dai_link->stream_name = name;
 
 	/* simple-card assumes platform == cpu */
-	info->snd_link.platform_of_node = info->snd_link.cpu_of_node;
+	dai_link->platform_of_node = dai_link->cpu_of_node;
 
 	dev_dbg(dev, "card-name : %s\n", name);
 	dev_dbg(dev, "platform : %04x\n", info->daifmt);
@@ -191,6 +192,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 static int asoc_simple_card_probe(struct platform_device *pdev)
 {
 	struct asoc_simple_card_info *cinfo;
+	struct snd_soc_dai_link *dai_link;
 	struct device_node *np = pdev->dev.of_node;
 	struct device *dev = &pdev->dev;
 	int ret;
@@ -204,8 +206,9 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
 	 */
 	cinfo->snd_card.owner		= THIS_MODULE;
 	cinfo->snd_card.dev = dev;
-	cinfo->snd_card.dai_link	= &cinfo->snd_link;
-	cinfo->snd_card.num_links	= 1;
+	dai_link = &cinfo->snd_link;
+	cinfo->snd_card.dai_link = dai_link;
+	cinfo->snd_card.num_links = 1;
 
 	if (np && of_device_is_available(np)) {
 
@@ -233,18 +236,18 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
 		}
 
 		cinfo->snd_card.name		= cinfo->card;
-		cinfo->snd_link.name		= cinfo->name;
-		cinfo->snd_link.stream_name	= cinfo->name;
-		cinfo->snd_link.platform_name	= cinfo->platform;
-		cinfo->snd_link.codec_name	= cinfo->codec;
+		dai_link->name		= cinfo->name;
+		dai_link->stream_name	= cinfo->name;
+		dai_link->platform_name	= cinfo->platform;
+		dai_link->codec_name	= cinfo->codec;
 	}
 
 	/*
 	 * init snd_soc_dai_link
 	 */
-	cinfo->snd_link.cpu_dai_name	= cinfo->cpu_dai.name;
-	cinfo->snd_link.codec_dai_name	= cinfo->codec_dai.name;
-	cinfo->snd_link.init		= asoc_simple_card_dai_init;
+	dai_link->cpu_dai_name	= cinfo->cpu_dai.name;
+	dai_link->codec_dai_name = cinfo->codec_dai.name;
+	dai_link->init = asoc_simple_card_dai_init;
 
 	snd_soc_card_set_drvdata(&cinfo->snd_card, cinfo);
 
-- 
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 5/8] ASoC: simple-card: simplify code
       [not found] <20140115113551.0eb13409@armhf>
                   ` (3 preceding siblings ...)
  2014-01-15 15:51 ` [PATCH v2 4/8] " Jean-Francois Moine
@ 2014-01-15 15:51 ` Jean-Francois Moine
  2014-01-22 19:42   ` Mark Brown
  2014-01-15 15:51 ` [PATCH v2 6/8] " Jean-Francois Moine
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Jean-Francois Moine @ 2014-01-15 15:51 UTC (permalink / raw)
  To: Mark Brown, lgirdwood
  Cc: alsa-devel, linux-kernel, kuninori.morimoto.gx, Xiubo Li

The CPU and CODEC DAI names are still copied to the user info structure.
Put them directly in the DAI links.

Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
---
 sound/soc/generic/simple-card.c     | 28 ++++++++++++----------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 797696f..9068ab4 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -60,7 +60,8 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
 static int
 asoc_simple_card_sub_parse_of(struct device_node *np,
 			      struct asoc_simple_dai *dai,
-			      const struct device_node **p_node)
+			      const struct device_node **p_node,
+			      const char **name)
 {
 	struct device_node *node;
 	struct clk *clk;
@@ -76,7 +77,7 @@ asoc_simple_card_sub_parse_of(struct device_node *np,
 	*p_node = node;
 
 	/* get dai->name */
-	ret = snd_soc_of_get_dai_name(np, &dai->name);
+	ret = snd_soc_of_get_dai_name(np, name);
 	if (ret < 0)
 		goto parse_error;
 
@@ -146,7 +147,8 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 	if (np)
 		ret = asoc_simple_card_sub_parse_of(np,
 						  &info->cpu_dai,
-						  &dai_link->cpu_of_node);
+						  &dai_link->cpu_of_node,
+						  &dai_link->cpu_dai_name);
 	if (ret < 0)
 		return ret;
 
@@ -156,19 +158,21 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 	if (np)
 		ret = asoc_simple_card_sub_parse_of(np,
 						  &info->codec_dai,
-						  &dai_link->codec_of_node);
+						  &dai_link->codec_of_node,
+						  &dai_link->codec_dai_name);
 	if (ret < 0)
 		return ret;
 
-	if (!info->cpu_dai.name || !info->codec_dai.name)
+	if (!dai_link->cpu_dai_name || !dai_link->codec_dai_name)
 		return -EINVAL;
 
 	/* card name is created from CPU/CODEC dai name */
 	name = devm_kzalloc(dev,
-			    strlen(info->cpu_dai.name)   +
-			    strlen(info->codec_dai.name) + 2,
+			    strlen(dai_link->cpu_dai_name)   +
+			    strlen(dai_link->codec_dai_name) + 2,
 			    GFP_KERNEL);
-	sprintf(name, "%s-%s", info->cpu_dai.name, info->codec_dai.name);
+	sprintf(name, "%s-%s", dai_link->cpu_dai_name,
+				dai_link->codec_dai_name);
 	info->snd_card.name = name;
 	dai_link->name = dai_link->stream_name = name;
 
@@ -178,11 +182,11 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 	dev_dbg(dev, "card-name : %s\n", name);
 	dev_dbg(dev, "platform : %04x\n", info->daifmt);
 	dev_dbg(dev, "cpu : %s / %04x / %d\n",
-		info->cpu_dai.name,
+		dai_link->cpu_dai_name,
 		info->cpu_dai.fmt,
 		info->cpu_dai.sysclk);
 	dev_dbg(dev, "codec : %s / %04x / %d\n",
-		info->codec_dai.name,
+		dai_link->codec_dai_name,
 		info->codec_dai.fmt,
 		info->codec_dai.sysclk);
 
@@ -240,13 +244,13 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
 		dai_link->stream_name	= cinfo->name;
 		dai_link->platform_name	= cinfo->platform;
 		dai_link->codec_name	= cinfo->codec;
+		dai_link->cpu_dai_name	= cinfo->cpu_dai.name;
+		dai_link->codec_dai_name = cinfo->codec_dai.name;
 	}
 
 	/*
 	 * init snd_soc_dai_link
 	 */
-	dai_link->cpu_dai_name	= cinfo->cpu_dai.name;
-	dai_link->codec_dai_name = cinfo->codec_dai.name;
 	dai_link->init = asoc_simple_card_dai_init;
 
 	snd_soc_card_set_drvdata(&cinfo->snd_card, cinfo);
-- 
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 6/8] ASoC: simple-card: simplify code
       [not found] <20140115113551.0eb13409@armhf>
                   ` (4 preceding siblings ...)
  2014-01-15 15:51 ` [PATCH v2 5/8] " Jean-Francois Moine
@ 2014-01-15 15:51 ` Jean-Francois Moine
  2014-01-22 20:05   ` Mark Brown
  2014-01-15 15:51 ` [PATCH v2 7/8] " Jean-Francois Moine
  2014-01-15 15:52 ` [PATCH v2 8/8] " Jean-Francois Moine
  7 siblings, 1 reply; 16+ messages in thread
From: Jean-Francois Moine @ 2014-01-15 15:51 UTC (permalink / raw)
  To: Mark Brown, lgirdwood
  Cc: alsa-devel, linux-kernel, kuninori.morimoto.gx, Xiubo Li

In the non-DT sequence, the platform data is copied as a whole to the
dynamic card info and the same pointer 'cinfo' is used to copy the
platform information to the card.

Use 'priv' as the pointer to the dynamic card info and copy only the
useful information from the platform data.

Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
---
 sound/soc/generic/simple-card.c     | 34 +++++++++++++---------
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 9068ab4..90c6fd5 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -195,40 +195,42 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 
 static int asoc_simple_card_probe(struct platform_device *pdev)
 {
-	struct asoc_simple_card_info *cinfo;
+	struct asoc_simple_card_info *priv;
 	struct snd_soc_dai_link *dai_link;
 	struct device_node *np = pdev->dev.of_node;
 	struct device *dev = &pdev->dev;
 	int ret;
 
-	cinfo = devm_kzalloc(dev, sizeof(*cinfo), GFP_KERNEL);
-	if (!cinfo)
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
 		return -ENOMEM;
 
 	/*
 	 * init snd_soc_card
 	 */
-	cinfo->snd_card.owner		= THIS_MODULE;
-	cinfo->snd_card.dev = dev;
-	dai_link = &cinfo->snd_link;
-	cinfo->snd_card.dai_link = dai_link;
-	cinfo->snd_card.num_links = 1;
+	priv->snd_card.owner = THIS_MODULE;
+	priv->snd_card.dev = dev;
+	dai_link = &priv->snd_link;
+	priv->snd_card.dai_link = dai_link;
+	priv->snd_card.num_links = 1;
 
 	if (np && of_device_is_available(np)) {
 
-		ret = asoc_simple_card_parse_of(np, cinfo, dev);
+		ret = asoc_simple_card_parse_of(np, priv, dev);
 		if (ret < 0) {
 			if (ret != -EPROBE_DEFER)
 				dev_err(dev, "parse error %d\n", ret);
 			return ret;
 		}
 	} else {
-		if (!dev->platform_data) {
+		struct asoc_simple_card_info *cinfo;
+
+		cinfo = dev->platform_data;
+		if (!cinfo) {
 			dev_err(dev, "no info for asoc-simple-card\n");
 			return -EINVAL;
 		}
 
-		memcpy(cinfo, dev->platform_data, sizeof(*cinfo));
 		if (!cinfo->name	||
 		    !cinfo->card	||
 		    !cinfo->codec_dai.name	||
@@ -239,13 +241,17 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
 			return -EINVAL;
 		}
 
-		cinfo->snd_card.name		= cinfo->card;
+		priv->snd_card.name	= cinfo->card;
 		dai_link->name		= cinfo->name;
 		dai_link->stream_name	= cinfo->name;
 		dai_link->platform_name	= cinfo->platform;
 		dai_link->codec_name	= cinfo->codec;
 		dai_link->cpu_dai_name	= cinfo->cpu_dai.name;
 		dai_link->codec_dai_name = cinfo->codec_dai.name;
+		memcpy(&priv->cpu_dai, &cinfo->cpu_dai,
+						sizeof(priv->cpu_dai));
+		memcpy(&priv->codec_dai, &cinfo->codec_dai,
+						sizeof(priv->codec_dai));
 	}
 
 	/*
@@ -253,9 +259,9 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
 	 */
 	dai_link->init = asoc_simple_card_dai_init;
 
-	snd_soc_card_set_drvdata(&cinfo->snd_card, cinfo);
+	snd_soc_card_set_drvdata(&priv->snd_card, priv);
 
-	return devm_snd_soc_register_card(&pdev->dev, &cinfo->snd_card);
+	return devm_snd_soc_register_card(&pdev->dev, &priv->snd_card);
 }
 
 static const struct of_device_id asoc_simple_of_match[] = {
-- 
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 7/8] ASoC: simple-card: simplify code
       [not found] <20140115113551.0eb13409@armhf>
                   ` (5 preceding siblings ...)
  2014-01-15 15:51 ` [PATCH v2 6/8] " Jean-Francois Moine
@ 2014-01-15 15:51 ` Jean-Francois Moine
  2014-01-22 20:06   ` Mark Brown
  2014-01-15 15:52 ` [PATCH v2 8/8] " Jean-Francois Moine
  7 siblings, 1 reply; 16+ messages in thread
From: Jean-Francois Moine @ 2014-01-15 15:51 UTC (permalink / raw)
  To: Mark Brown, lgirdwood
  Cc: alsa-devel, linux-kernel, kuninori.morimoto.gx, Xiubo Li

The platform data structure contains information which is used only by
the driver, and the driver allocates platform information fields which
are of no use.
Move the driver specific data to a new private structure and cleanup
the platform data structure.

Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
---
 include/sound/simple_card.h     |  4 --
 sound/soc/generic/simple-card.c | 14 +++++++++++---
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/include/sound/simple_card.h b/include/sound/simple_card.h
index 6c74527..e1ac996 100644
--- a/include/sound/simple_card.h
+++ b/include/sound/simple_card.h
@@ -29,10 +29,6 @@ struct asoc_simple_card_info {
 	unsigned int daifmt;
 	struct asoc_simple_dai cpu_dai;
 	struct asoc_simple_dai codec_dai;
-
-	/* used in simple-card.c */
-	struct snd_soc_dai_link snd_link;
-	struct snd_soc_card snd_card;
 };
 
 #endif /* __SIMPLE_CARD_H */
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 90c6fd5..0f11c28 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -15,6 +15,14 @@
 #include <linux/string.h>
 #include <sound/simple_card.h>
 
+struct simple_card_data {
+	struct snd_soc_card snd_card;
+	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,
 				       struct asoc_simple_dai *set,
 				       unsigned int daifmt)
@@ -39,7 +47,7 @@ static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai,
 
 static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
 {
-	struct asoc_simple_card_info *info =
+	struct simple_card_data *info =
 				snd_soc_card_get_drvdata(rtd->card);
 	struct snd_soc_dai *codec = rtd->codec_dai;
 	struct snd_soc_dai *cpu = rtd->cpu_dai;
@@ -121,7 +129,7 @@ parse_error:
 }
 
 static int asoc_simple_card_parse_of(struct device_node *node,
-				     struct asoc_simple_card_info *info,
+				     struct simple_card_data *info,
 				     struct device *dev)
 {
 	struct snd_soc_dai_link *dai_link = info->snd_card.dai_link;
@@ -195,7 +203,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 
 static int asoc_simple_card_probe(struct platform_device *pdev)
 {
-	struct asoc_simple_card_info *priv;
+	struct simple_card_data *priv;
 	struct snd_soc_dai_link *dai_link;
 	struct device_node *np = pdev->dev.of_node;
 	struct device *dev = &pdev->dev;
-- 
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 8/8] ASoC: simple-card: simplify code
       [not found] <20140115113551.0eb13409@armhf>
                   ` (6 preceding siblings ...)
  2014-01-15 15:51 ` [PATCH v2 7/8] " Jean-Francois Moine
@ 2014-01-15 15:52 ` Jean-Francois Moine
  2014-01-22 20:06   ` Mark Brown
  7 siblings, 1 reply; 16+ messages in thread
From: Jean-Francois Moine @ 2014-01-15 15:52 UTC (permalink / raw)
  To: Mark Brown, lgirdwood
  Cc: alsa-devel, linux-kernel, kuninori.morimoto.gx, Xiubo Li

Rename the pointer to the private data structure to 'priv' to avoid confusion with the platform data pointer.

Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
---
 sound/soc/generic/simple-card.c     | 32 +++++++++++-----------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 0f11c28..6443c87 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -47,18 +47,18 @@ static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai,
 
 static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
 {
-	struct simple_card_data *info =
+	struct simple_card_data *priv =
 				snd_soc_card_get_drvdata(rtd->card);
 	struct snd_soc_dai *codec = rtd->codec_dai;
 	struct snd_soc_dai *cpu = rtd->cpu_dai;
-	unsigned int daifmt = info->daifmt;
+	unsigned int daifmt = priv->daifmt;
 	int ret;
 
-	ret = __asoc_simple_card_dai_init(codec, &info->codec_dai, daifmt);
+	ret = __asoc_simple_card_dai_init(codec, &priv->codec_dai, daifmt);
 	if (ret < 0)
 		return ret;
 
-	ret = __asoc_simple_card_dai_init(cpu, &info->cpu_dai, daifmt);
+	ret = __asoc_simple_card_dai_init(cpu, &priv->cpu_dai, daifmt);
 	if (ret < 0)
 		return ret;
 
@@ -129,21 +129,21 @@ parse_error:
 }
 
 static int asoc_simple_card_parse_of(struct device_node *node,
-				     struct simple_card_data *info,
+				     struct simple_card_data *priv,
 				     struct device *dev)
 {
-	struct snd_soc_dai_link *dai_link = info->snd_card.dai_link;
+	struct snd_soc_dai_link *dai_link = priv->snd_card.dai_link;
 	struct device_node *np;
 	char *name;
 	int ret;
 
 	/* get CPU/CODEC common format via simple-audio-card,format */
-	info->daifmt = snd_soc_of_parse_daifmt(node, "simple-audio-card,") &
+	priv->daifmt = snd_soc_of_parse_daifmt(node, "simple-audio-card,") &
 		(SND_SOC_DAIFMT_FORMAT_MASK | SND_SOC_DAIFMT_INV_MASK);
 
 	/* DAPM routes */
 	if (of_property_read_bool(node, "simple-audio-card,routing")) {
-		ret = snd_soc_of_parse_audio_routing(&info->snd_card,
+		ret = snd_soc_of_parse_audio_routing(&priv->snd_card,
 					"simple-audio-card,routing");
 		if (ret)
 			return ret;
@@ -154,7 +154,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 	np = of_get_child_by_name(node, "simple-audio-card,cpu");
 	if (np)
 		ret = asoc_simple_card_sub_parse_of(np,
-						  &info->cpu_dai,
+						  &priv->cpu_dai,
 						  &dai_link->cpu_of_node,
 						  &dai_link->cpu_dai_name);
 	if (ret < 0)
@@ -165,7 +165,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 	np = of_get_child_by_name(node, "simple-audio-card,codec");
 	if (np)
 		ret = asoc_simple_card_sub_parse_of(np,
-						  &info->codec_dai,
+						  &priv->codec_dai,
 						  &dai_link->codec_of_node,
 						  &dai_link->codec_dai_name);
 	if (ret < 0)
@@ -181,22 +181,22 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 			    GFP_KERNEL);
 	sprintf(name, "%s-%s", dai_link->cpu_dai_name,
 				dai_link->codec_dai_name);
-	info->snd_card.name = name;
+	priv->snd_card.name = name;
 	dai_link->name = dai_link->stream_name = name;
 
 	/* simple-card assumes platform == cpu */
 	dai_link->platform_of_node = dai_link->cpu_of_node;
 
 	dev_dbg(dev, "card-name : %s\n", name);
-	dev_dbg(dev, "platform : %04x\n", info->daifmt);
+	dev_dbg(dev, "platform : %04x\n", priv->daifmt);
 	dev_dbg(dev, "cpu : %s / %04x / %d\n",
 		dai_link->cpu_dai_name,
-		info->cpu_dai.fmt,
-		info->cpu_dai.sysclk);
+		priv->cpu_dai.fmt,
+		priv->cpu_dai.sysclk);
 	dev_dbg(dev, "codec : %s / %04x / %d\n",
 		dai_link->codec_dai_name,
-		info->codec_dai.fmt,
-		info->codec_dai.sysclk);
+		priv->codec_dai.fmt,
+		priv->codec_dai.sysclk);
 
 	return 0;
 }
-- 
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 1/8] ASoC: simple-card: simplify code
  2014-01-15 15:51 ` [PATCH v2 1/8] ASoC: simple-card: simplify code Jean-Francois Moine
@ 2014-01-22 19:04   ` Mark Brown
  0 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2014-01-22 19:04 UTC (permalink / raw)
  To: Jean-Francois Moine
  Cc: lgirdwood, alsa-devel, linux-kernel, kuninori.morimoto.gx, Xiubo Li

[-- Attachment #1: Type: text/plain, Size: 213 bytes --]

On Wed, Jan 15, 2014 at 04:51:33PM +0100, Jean-Francois Moine wrote:

> The check of the mandatory fields is done for DT in its specific sequence.
> Move the global check to the non-DT sequence.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 2/8] ASoC: simple-card: simplify code
  2014-01-15 15:51 ` [PATCH v2 2/8] " Jean-Francois Moine
@ 2014-01-22 19:06   ` Mark Brown
  0 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2014-01-22 19:06 UTC (permalink / raw)
  To: Jean-Francois Moine
  Cc: lgirdwood, alsa-devel, linux-kernel, kuninori.morimoto.gx, Xiubo Li

[-- Attachment #1: Type: text/plain, Size: 399 bytes --]

On Wed, Jan 15, 2014 at 04:51:37PM +0100, Jean-Francois Moine wrote:
> The DT values are copied to the non-DT structure before being moved to
> the card structure.
> Set directly the DT values in the card and move the non-DT copy to the
> non-DT sequence.

Applied, thanks.  Every patch in this series seems to have the same
subject line - please don't do that, it makes things harder to work
with.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 3/8] ASoC: simple-card: simplify code
  2014-01-15 15:51 ` [PATCH v2 3/8] " Jean-Francois Moine
@ 2014-01-22 19:25   ` Mark Brown
  0 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2014-01-22 19:25 UTC (permalink / raw)
  To: Jean-Francois Moine
  Cc: lgirdwood, alsa-devel, linux-kernel, kuninori.morimoto.gx, Xiubo Li

[-- Attachment #1: Type: text/plain, Size: 210 bytes --]

On Wed, Jan 15, 2014 at 04:51:41PM +0100, Jean-Francois Moine wrote:
> The OF pointers are put in the stack and then copied to the card
> descriptor.
> Put them directly at their right place.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 4/8] ASoC: simple-card: simplify code
  2014-01-15 15:51 ` [PATCH v2 4/8] " Jean-Francois Moine
@ 2014-01-22 19:26   ` Mark Brown
  0 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2014-01-22 19:26 UTC (permalink / raw)
  To: Jean-Francois Moine
  Cc: lgirdwood, alsa-devel, linux-kernel, kuninori.morimoto.gx, Xiubo Li

[-- Attachment #1: Type: text/plain, Size: 140 bytes --]

On Wed, Jan 15, 2014 at 04:51:45PM +0100, Jean-Francois Moine wrote:
> Have a cleaner code using a DAI link pointer.
 
Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 5/8] ASoC: simple-card: simplify code
  2014-01-15 15:51 ` [PATCH v2 5/8] " Jean-Francois Moine
@ 2014-01-22 19:42   ` Mark Brown
  0 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2014-01-22 19:42 UTC (permalink / raw)
  To: Jean-Francois Moine
  Cc: lgirdwood, alsa-devel, linux-kernel, kuninori.morimoto.gx, Xiubo Li

[-- Attachment #1: Type: text/plain, Size: 200 bytes --]

On Wed, Jan 15, 2014 at 04:51:48PM +0100, Jean-Francois Moine wrote:
> The CPU and CODEC DAI names are still copied to the user info structure.
> Put them directly in the DAI links.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 6/8] ASoC: simple-card: simplify code
  2014-01-15 15:51 ` [PATCH v2 6/8] " Jean-Francois Moine
@ 2014-01-22 20:05   ` Mark Brown
  0 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2014-01-22 20:05 UTC (permalink / raw)
  To: Jean-Francois Moine
  Cc: lgirdwood, alsa-devel, linux-kernel, kuninori.morimoto.gx, Xiubo Li

[-- Attachment #1: Type: text/plain, Size: 264 bytes --]

On Wed, Jan 15, 2014 at 04:51:52PM +0100, Jean-Francois Moine wrote:
> In the non-DT sequence, the platform data is copied as a whole to the
> dynamic card info and the same pointer 'cinfo' is used to copy the
> platform information to the card.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 7/8] ASoC: simple-card: simplify code
  2014-01-15 15:51 ` [PATCH v2 7/8] " Jean-Francois Moine
@ 2014-01-22 20:06   ` Mark Brown
  0 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2014-01-22 20:06 UTC (permalink / raw)
  To: Jean-Francois Moine
  Cc: lgirdwood, alsa-devel, linux-kernel, kuninori.morimoto.gx, Xiubo Li

[-- Attachment #1: Type: text/plain, Size: 250 bytes --]

On Wed, Jan 15, 2014 at 04:51:56PM +0100, Jean-Francois Moine wrote:
> The platform data structure contains information which is used only by
> the driver, and the driver allocates platform information fields which
> are of no use.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 8/8] ASoC: simple-card: simplify code
  2014-01-15 15:52 ` [PATCH v2 8/8] " Jean-Francois Moine
@ 2014-01-22 20:06   ` Mark Brown
  0 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2014-01-22 20:06 UTC (permalink / raw)
  To: Jean-Francois Moine
  Cc: lgirdwood, alsa-devel, linux-kernel, kuninori.morimoto.gx, Xiubo Li

[-- Attachment #1: Type: text/plain, Size: 199 bytes --]

On Wed, Jan 15, 2014 at 04:52:00PM +0100, Jean-Francois Moine wrote:
> Rename the pointer to the private data structure to 'priv' to avoid confusion with the platform data pointer.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2014-01-22 20:06 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20140115113551.0eb13409@armhf>
2014-01-15 15:51 ` [PATCH v2 1/8] ASoC: simple-card: simplify code Jean-Francois Moine
2014-01-22 19:04   ` Mark Brown
2014-01-15 15:51 ` [PATCH v2 2/8] " Jean-Francois Moine
2014-01-22 19:06   ` Mark Brown
2014-01-15 15:51 ` [PATCH v2 3/8] " Jean-Francois Moine
2014-01-22 19:25   ` Mark Brown
2014-01-15 15:51 ` [PATCH v2 4/8] " Jean-Francois Moine
2014-01-22 19:26   ` Mark Brown
2014-01-15 15:51 ` [PATCH v2 5/8] " Jean-Francois Moine
2014-01-22 19:42   ` Mark Brown
2014-01-15 15:51 ` [PATCH v2 6/8] " Jean-Francois Moine
2014-01-22 20:05   ` Mark Brown
2014-01-15 15:51 ` [PATCH v2 7/8] " Jean-Francois Moine
2014-01-22 20:06   ` Mark Brown
2014-01-15 15:52 ` [PATCH v2 8/8] " Jean-Francois Moine
2014-01-22 20:06   ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).