All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] ASoC: simple-card: tidyup and synchronize patches
@ 2016-08-25  1:48 Kuninori Morimoto
  2016-08-25  1:49 ` [PATCH 1/9] ASoC: simple-card: call of_node_put() for dai_link Kuninori Morimoto
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Kuninori Morimoto @ 2016-08-25  1:48 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood


Hi Mark

These are cleanup/tidyup and synchronize patches for simple-card.
We have now simple-card and simple-scu-card.
These are almost same, difference is very small.
But, because of historical reason, these have "code" difference.
This patch cleanup and synchronize these.

Kuninori Morimoto (9):
  ASoC: simple-card: call of_node_put() for dai_link
  ASoC: simple-card: tidyup mclk-fs of_property_read_u32() usage
  ASoC: simple-card: code sync: tidyup simple_priv_to_xxx() macro
  ASoC: simple-card: code sync: use simple_priv_to_props() macro
  ASoC: simple-card: is GPL v2
  ASoC: simple-card: code sync: tidyup white line
  ASoC: simple-card: code sync: use tag
  ASoC: simple-card: code sync: rename num_link to num
  ASoC: simple-card: use kzalloc() for dai_props / dai_link

 sound/soc/generic/simple-card.c | 87 ++++++++++++++++++++---------------------
 1 file changed, 43 insertions(+), 44 deletions(-)

-- 
1.9.1

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

* [PATCH 1/9] ASoC: simple-card: call of_node_put() for dai_link
  2016-08-25  1:48 [PATCH 0/9] ASoC: simple-card: tidyup and synchronize patches Kuninori Morimoto
@ 2016-08-25  1:49 ` Kuninori Morimoto
  2016-08-25  1:50 ` [PATCH 2/9] ASoC: simple-card: tidyup mclk-fs of_property_read_u32() usage Kuninori Morimoto
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Kuninori Morimoto @ 2016-08-25  1:49 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

We need to call of_node_put() if we used of_get_child_by_name(),
but missing it for "dai-link" loop.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/simple-card.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 55638a8..3ce8bb6 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -322,18 +322,21 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 				     struct simple_card_data *priv)
 {
 	struct device *dev = simple_priv_to_dev(priv);
+	struct device_node *dai_link;
 	u32 val;
 	int ret;
 
 	if (!node)
 		return -EINVAL;
 
+	dai_link = of_get_child_by_name(node, PREFIX "dai-link");
+
 	/* The off-codec widgets */
 	if (of_property_read_bool(node, PREFIX "widgets")) {
 		ret = snd_soc_of_parse_audio_simple_widgets(&priv->snd_card,
 					PREFIX "widgets");
 		if (ret)
-			return ret;
+			goto card_parse_end;
 	}
 
 	/* DAPM routes */
@@ -341,7 +344,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 		ret = snd_soc_of_parse_audio_routing(&priv->snd_card,
 					PREFIX "routing");
 		if (ret)
-			return ret;
+			goto card_parse_end;
 	}
 
 	/* Factor to mclk, used in hw_params() */
@@ -350,7 +353,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 		priv->mclk_fs = val;
 
 	/* Single/Muti DAI link(s) & New style of DT node */
-	if (of_get_child_by_name(node, PREFIX "dai-link")) {
+	if (dai_link) {
 		struct device_node *np = NULL;
 		int i = 0;
 
@@ -360,7 +363,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 							   i, false);
 			if (ret < 0) {
 				of_node_put(np);
-				return ret;
+				goto card_parse_end;
 			}
 			i++;
 		}
@@ -368,14 +371,15 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 		/* For single DAI link & old style of DT node */
 		ret = asoc_simple_card_dai_link_of(node, priv, 0, true);
 		if (ret < 0)
-			return ret;
+			goto card_parse_end;
 	}
 
 	ret = asoc_simple_card_parse_card_name(&priv->snd_card, PREFIX);
-	if (ret)
-		return ret;
 
-	return 0;
+card_parse_end:
+	of_node_put(dai_link);
+
+	return ret;
 }
 
 static int asoc_simple_card_probe(struct platform_device *pdev)
-- 
1.9.1

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

* [PATCH 2/9] ASoC: simple-card: tidyup mclk-fs of_property_read_u32() usage
  2016-08-25  1:48 [PATCH 0/9] ASoC: simple-card: tidyup and synchronize patches Kuninori Morimoto
  2016-08-25  1:49 ` [PATCH 1/9] ASoC: simple-card: call of_node_put() for dai_link Kuninori Morimoto
@ 2016-08-25  1:50 ` Kuninori Morimoto
  2016-08-25  1:50 ` [PATCH 3/9] ASoC: simple-card: code sync: tidyup simple_priv_to_xxx() macro Kuninori Morimoto
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Kuninori Morimoto @ 2016-08-25  1:50 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

of_property_read_u32() do nothing in error case.
Let's tidyup useless usage.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/simple-card.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 3ce8bb6..a4a39d4 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -222,7 +222,6 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
 	char prop[128];
 	char *prefix = "";
 	int ret, single_cpu;
-	u32 val;
 
 	/* For single DAI link & old style of DT node */
 	if (is_top_level_node)
@@ -248,8 +247,7 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
 	if (ret < 0)
 		goto dai_link_of_err;
 
-	if (!of_property_read_u32(node, "mclk-fs", &val))
-		dai_props->mclk_fs = val;
+	of_property_read_u32(node, "mclk-fs", &dai_props->mclk_fs);
 
 	ret = asoc_simple_card_parse_cpu(cpu, dai_link,
 					 DAI, CELL, &single_cpu);
@@ -323,7 +321,6 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 {
 	struct device *dev = simple_priv_to_dev(priv);
 	struct device_node *dai_link;
-	u32 val;
 	int ret;
 
 	if (!node)
@@ -348,9 +345,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 	}
 
 	/* Factor to mclk, used in hw_params() */
-	ret = of_property_read_u32(node, PREFIX "mclk-fs", &val);
-	if (ret == 0)
-		priv->mclk_fs = val;
+	of_property_read_u32(node, PREFIX "mclk-fs", &priv->mclk_fs);
 
 	/* Single/Muti DAI link(s) & New style of DT node */
 	if (dai_link) {
-- 
1.9.1

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

* [PATCH 3/9] ASoC: simple-card: code sync: tidyup simple_priv_to_xxx() macro
  2016-08-25  1:48 [PATCH 0/9] ASoC: simple-card: tidyup and synchronize patches Kuninori Morimoto
  2016-08-25  1:49 ` [PATCH 1/9] ASoC: simple-card: call of_node_put() for dai_link Kuninori Morimoto
  2016-08-25  1:50 ` [PATCH 2/9] ASoC: simple-card: tidyup mclk-fs of_property_read_u32() usage Kuninori Morimoto
@ 2016-08-25  1:50 ` Kuninori Morimoto
  2016-08-25  1:50 ` [PATCH 4/9] ASoC: simple-card: code sync: use simple_priv_to_props() macro Kuninori Morimoto
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Kuninori Morimoto @ 2016-08-25  1:50 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/simple-card.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index a4a39d4..8774d803 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -41,8 +41,8 @@ struct simple_card_data {
 };
 
 #define simple_priv_to_dev(priv) ((priv)->snd_card.dev)
-#define simple_priv_to_link(priv, i) ((priv)->snd_card.dai_link + i)
-#define simple_priv_to_props(priv, i) ((priv)->dai_props + i)
+#define simple_priv_to_link(priv, i) ((priv)->snd_card.dai_link + (i))
+#define simple_priv_to_props(priv, i) ((priv)->dai_props + (i))
 
 #define DAI	"sound-dai"
 #define CELL	"#sound-dai-cells"
-- 
1.9.1

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

* [PATCH 4/9] ASoC: simple-card: code sync: use simple_priv_to_props() macro
  2016-08-25  1:48 [PATCH 0/9] ASoC: simple-card: tidyup and synchronize patches Kuninori Morimoto
                   ` (2 preceding siblings ...)
  2016-08-25  1:50 ` [PATCH 3/9] ASoC: simple-card: code sync: tidyup simple_priv_to_xxx() macro Kuninori Morimoto
@ 2016-08-25  1:50 ` Kuninori Morimoto
  2016-08-25  1:51 ` [PATCH 5/9] ASoC: simple-card: is GPL v2 Kuninori Morimoto
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Kuninori Morimoto @ 2016-08-25  1:50 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/simple-card.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 8774d803..939c827 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -114,7 +114,7 @@ static int asoc_simple_card_startup(struct snd_pcm_substream *substream)
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct simple_card_data *priv =	snd_soc_card_get_drvdata(rtd->card);
 	struct simple_dai_props *dai_props =
-		&priv->dai_props[rtd->num];
+		simple_priv_to_props(priv, rtd->num);
 	int ret;
 
 	ret = clk_prepare_enable(dai_props->cpu_dai.clk);
@@ -133,7 +133,7 @@ static void asoc_simple_card_shutdown(struct snd_pcm_substream *substream)
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct simple_card_data *priv =	snd_soc_card_get_drvdata(rtd->card);
 	struct simple_dai_props *dai_props =
-		&priv->dai_props[rtd->num];
+		simple_priv_to_props(priv, rtd->num);
 
 	clk_disable_unprepare(dai_props->cpu_dai.clk);
 
@@ -147,7 +147,8 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream,
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
-	struct simple_dai_props *dai_props = &priv->dai_props[rtd->num];
+	struct simple_dai_props *dai_props =
+		simple_priv_to_props(priv, rtd->num);
 	unsigned int mclk, mclk_fs = 0;
 	int ret = 0;
 
@@ -184,7 +185,8 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
 	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;
-	struct simple_dai_props *dai_props = &priv->dai_props[rtd->num];
+	struct simple_dai_props *dai_props =
+		simple_priv_to_props(priv, rtd->num);
 	int ret;
 
 	ret = asoc_simple_card_init_dai(codec, &dai_props->codec_dai);
-- 
1.9.1

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

* [PATCH 5/9] ASoC: simple-card: is GPL v2
  2016-08-25  1:48 [PATCH 0/9] ASoC: simple-card: tidyup and synchronize patches Kuninori Morimoto
                   ` (3 preceding siblings ...)
  2016-08-25  1:50 ` [PATCH 4/9] ASoC: simple-card: code sync: use simple_priv_to_props() macro Kuninori Morimoto
@ 2016-08-25  1:51 ` Kuninori Morimoto
  2016-08-25  1:51 ` [PATCH 6/9] ASoC: simple-card: code sync: tidyup white line Kuninori Morimoto
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Kuninori Morimoto @ 2016-08-25  1:51 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

It is indicating that this driver is GPL v2 on top of C code.
Let's fixup it on MODULE_LICENSE()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/simple-card.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 939c827..7b0a56f 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -498,6 +498,6 @@ static struct platform_driver asoc_simple_card = {
 module_platform_driver(asoc_simple_card);
 
 MODULE_ALIAS("platform:asoc-simple-card");
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("ASoC Simple Sound Card");
 MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");
-- 
1.9.1

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

* [PATCH 6/9] ASoC: simple-card: code sync: tidyup white line
  2016-08-25  1:48 [PATCH 0/9] ASoC: simple-card: tidyup and synchronize patches Kuninori Morimoto
                   ` (4 preceding siblings ...)
  2016-08-25  1:51 ` [PATCH 5/9] ASoC: simple-card: is GPL v2 Kuninori Morimoto
@ 2016-08-25  1:51 ` Kuninori Morimoto
  2016-08-25  1:52 ` [PATCH 7/9] ASoC: simple-card: code sync: use tag Kuninori Morimoto
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Kuninori Morimoto @ 2016-08-25  1:51 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

simple sound card family are using very similar style, but because of its
historical reason, there are small differences. For example pointer style,
function name, caller postion etc...
This patch synchronized simple card style to other simple card family.

This patch tidyups white line

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/simple-card.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 7b0a56f..7d15b50 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -120,7 +120,7 @@ static int asoc_simple_card_startup(struct snd_pcm_substream *substream)
 	ret = clk_prepare_enable(dai_props->cpu_dai.clk);
 	if (ret)
 		return ret;
-	
+
 	ret = clk_prepare_enable(dai_props->codec_dai.clk);
 	if (ret)
 		clk_disable_unprepare(dai_props->cpu_dai.clk);
@@ -454,7 +454,6 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
 					sizeof(priv->dai_props->cpu_dai));
 		memcpy(&priv->dai_props->codec_dai, &cinfo->codec_dai,
 					sizeof(priv->dai_props->codec_dai));
-
 	}
 
 	snd_soc_card_set_drvdata(&priv->snd_card, priv);
@@ -462,9 +461,9 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
 	ret = devm_snd_soc_register_card(&pdev->dev, &priv->snd_card);
 	if (ret >= 0)
 		return ret;
-
 err:
 	asoc_simple_card_clean_reference(&priv->snd_card);
+
 	return ret;
 }
 
-- 
1.9.1

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

* [PATCH 7/9] ASoC: simple-card: code sync: use tag
  2016-08-25  1:48 [PATCH 0/9] ASoC: simple-card: tidyup and synchronize patches Kuninori Morimoto
                   ` (5 preceding siblings ...)
  2016-08-25  1:51 ` [PATCH 6/9] ASoC: simple-card: code sync: tidyup white line Kuninori Morimoto
@ 2016-08-25  1:52 ` Kuninori Morimoto
  2016-08-25  1:52 ` [PATCH 8/9] ASoC: simple-card: code sync: rename num_link to num Kuninori Morimoto
  2016-08-25  1:53 ` [PATCH 9/9] ASoC: simple-card: use kzalloc() for dai_props / dai_link Kuninori Morimoto
  8 siblings, 0 replies; 11+ messages in thread
From: Kuninori Morimoto @ 2016-08-25  1:52 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

simple sound card family are using very similar style, but because of its
historical reason, there are small differences. For example pointer style,
function name, caller postion etc...
This patch synchronized simple card style to other simple card family.

This patch uses tag on asoc_simple_card_probe

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/simple-card.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 7d15b50..c17f851 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -401,11 +401,11 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	/* Init snd_soc_card */
-	priv->snd_card.owner = THIS_MODULE;
-	priv->snd_card.dev = dev;
 	dai_link = priv->dai_link;
-	priv->snd_card.dai_link = dai_link;
-	priv->snd_card.num_links = num_links;
+	priv->snd_card.owner		= THIS_MODULE;
+	priv->snd_card.dev		= dev;
+	priv->snd_card.dai_link		= priv->dai_link;
+	priv->snd_card.num_links	= num_links;
 
 	/* Get room for the other properties */
 	priv->dai_props = devm_kzalloc(dev,
-- 
1.9.1

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

* [PATCH 8/9] ASoC: simple-card: code sync: rename num_link to num
  2016-08-25  1:48 [PATCH 0/9] ASoC: simple-card: tidyup and synchronize patches Kuninori Morimoto
                   ` (6 preceding siblings ...)
  2016-08-25  1:52 ` [PATCH 7/9] ASoC: simple-card: code sync: use tag Kuninori Morimoto
@ 2016-08-25  1:52 ` Kuninori Morimoto
       [not found]   ` <201608251635.kJNOT64O%fengguang.wu@intel.com>
  2016-08-25  1:53 ` [PATCH 9/9] ASoC: simple-card: use kzalloc() for dai_props / dai_link Kuninori Morimoto
  8 siblings, 1 reply; 11+ messages in thread
From: Kuninori Morimoto @ 2016-08-25  1:52 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

simple sound card family are using very similar style, but because of its
historical reason, there are small differences. For example pointer style,
function name, caller postion etc...
This patch synchronized simple card style to other simple card family.

This patch renames num_link to num

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/simple-card.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index c17f851..0a4bcc1 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -385,13 +385,13 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
 	struct snd_soc_dai_link *dai_link;
 	struct device_node *np = pdev->dev.of_node;
 	struct device *dev = &pdev->dev;
-	int num_links, ret;
+	int num, ret;
 
 	/* Get the number of DAI links */
 	if (np && of_get_child_by_name(np, PREFIX "dai-link"))
-		num_links = of_get_child_count(np);
+		num = of_get_child_count(np);
 	else
-		num_links = 1;
+		num = 1;
 
 	/* Allocate the private data and the DAI link array */
 	priv = devm_kzalloc(dev,
@@ -405,7 +405,7 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
 	priv->snd_card.owner		= THIS_MODULE;
 	priv->snd_card.dev		= dev;
 	priv->snd_card.dai_link		= priv->dai_link;
-	priv->snd_card.num_links	= num_links;
+	priv->snd_card.num_links	= num;
 
 	/* Get room for the other properties */
 	priv->dai_props = devm_kzalloc(dev,
-- 
1.9.1

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

* [PATCH 9/9] ASoC: simple-card: use kzalloc() for dai_props / dai_link
  2016-08-25  1:48 [PATCH 0/9] ASoC: simple-card: tidyup and synchronize patches Kuninori Morimoto
                   ` (7 preceding siblings ...)
  2016-08-25  1:52 ` [PATCH 8/9] ASoC: simple-card: code sync: rename num_link to num Kuninori Morimoto
@ 2016-08-25  1:53 ` Kuninori Morimoto
  8 siblings, 0 replies; 11+ messages in thread
From: Kuninori Morimoto @ 2016-08-25  1:53 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

simple sound card family are using very similar style, but because of its
historical reason, there are small differences. For example pointer style,
function name, caller postion etc...
This patch synchronized simple card style to other simple card family.

Now, simple card needs to 2 type of buffer for dai_props and dai_link.
But, these used different style for buffer allocation.
This patch make these same style as other simple card family.
(= use kzalloc() for both)

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/simple-card.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 0a4bcc1..fe0bc5c 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -37,7 +37,7 @@ struct simple_card_data {
 	unsigned int mclk_fs;
 	struct asoc_simple_jack hp_jack;
 	struct asoc_simple_jack mic_jack;
-	struct snd_soc_dai_link dai_link[];	/* dynamically allocated */
+	struct snd_soc_dai_link *dai_link;
 };
 
 #define simple_priv_to_dev(priv) ((priv)->snd_card.dev)
@@ -383,6 +383,7 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
 {
 	struct simple_card_data *priv;
 	struct snd_soc_dai_link *dai_link;
+	struct simple_dai_props *dai_props;
 	struct device_node *np = pdev->dev.of_node;
 	struct device *dev = &pdev->dev;
 	int num, ret;
@@ -394,26 +395,24 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
 		num = 1;
 
 	/* Allocate the private data and the DAI link array */
-	priv = devm_kzalloc(dev,
-			sizeof(*priv) + sizeof(*dai_link) * num_links,
-			GFP_KERNEL);
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
+	dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL);
+	dai_link  = devm_kzalloc(dev, sizeof(*dai_link)  * num, GFP_KERNEL);
+	if (!dai_props || !dai_link)
+		return -ENOMEM;
+
+	priv->dai_props			= dai_props;
+	priv->dai_link			= dai_link;
+
 	/* Init snd_soc_card */
-	dai_link = priv->dai_link;
 	priv->snd_card.owner		= THIS_MODULE;
 	priv->snd_card.dev		= dev;
 	priv->snd_card.dai_link		= priv->dai_link;
 	priv->snd_card.num_links	= num;
 
-	/* Get room for the other properties */
-	priv->dai_props = devm_kzalloc(dev,
-			sizeof(*priv->dai_props) * num_links,
-			GFP_KERNEL);
-	if (!priv->dai_props)
-		return -ENOMEM;
-
 	if (np && of_device_is_available(np)) {
 
 		ret = asoc_simple_card_parse_of(np, priv);
-- 
1.9.1

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

* Re: [PATCH 8/9] ASoC: simple-card: code sync: rename num_link to num
       [not found]   ` <201608251635.kJNOT64O%fengguang.wu@intel.com>
@ 2016-08-26  2:51     ` Kuninori Morimoto
  0 siblings, 0 replies; 11+ messages in thread
From: Kuninori Morimoto @ 2016-08-26  2:51 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood


Hi Mark

This is my fault.
I will post v2 patch.

> [auto build test ERROR on asoc/for-next]
> [also build test ERROR on next-20160824]
> [cannot apply to v4.8-rc3]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
> [Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
> [Check https://git-scm.com/docs/git-format-patch for more information]
> 
> url:    https://github.com/0day-ci/linux/commits/Kuninori-Morimoto/ASoC-simple-card-tidyup-and-synchronize-patches/20160825-100058
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
> config: i386-randconfig-x011-201634 (attached as .config)
> compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
> reproduce:
>         # save the attached .config to linux build tree
>         make ARCH=i386 
> 
> Note: the linux-review/Kuninori-Morimoto/ASoC-simple-card-tidyup-and-synchronize-patches/20160825-100058 HEAD 36fb10f61ffb92eb287328e22cad00a486495747 builds fine.
>       It only hurts bisectibility.
> 
> All errors (new ones prefixed by >>):
> 
>    sound/soc/generic/simple-card.c: In function 'asoc_simple_card_probe':
> >> sound/soc/generic/simple-card.c:398:40: error: 'num_links' undeclared (first use in this function)
>        sizeof(*priv) + sizeof(*dai_link) * num_links,
>                                            ^~~~~~~~~
>    sound/soc/generic/simple-card.c:398:40: note: each undeclared identifier is reported only once for each function it appears in
> 
> vim +/num_links +398 sound/soc/generic/simple-card.c
> 
> 6805a759b Kuninori Morimoto   2016-08-25  392  		num = of_get_child_count(np);
> 2080437d3 Xiubo Li            2014-09-03  393  	else
> 6805a759b Kuninori Morimoto   2016-08-25  394  		num = 1;
> f2390880e Kuninori Morimoto   2012-04-08  395  
> 0dd4fc3c2 Xiubo Li            2014-09-10  396  	/* Allocate the private data and the DAI link array */
> cf7dc23cb Jean-Francois Moine 2014-03-20  397  	priv = devm_kzalloc(dev,
> 6a91a17bd Jean-Francois Moine 2014-03-20 @398  			sizeof(*priv) + sizeof(*dai_link) * num_links,
> cf7dc23cb Jean-Francois Moine 2014-03-20  399  			GFP_KERNEL);
> ca65b492c Jean-Francois Moine 2014-01-15  400  	if (!priv)
> ca919fe4b Xiubo Li            2014-01-14  401  		return -ENOMEM;
> 
> :::::: The code at line 398 was first introduced by commit
> :::::: 6a91a17bd7b92b2d2aa9ece85457f52a62fd7708 ASoC: simple-card: Handle many DAI links
> 
> :::::: TO: Jean-Francois Moine <moinejf@free.fr>
> :::::: CC: Mark Brown <broonie@linaro.org>
> 
> ---
> 0-DAY kernel test infrastructure                Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
> [2 .config.gz <application/octet-stream (base64)>]
> 


Best regards
---
Kuninori Morimoto

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

end of thread, other threads:[~2016-08-26  3:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-25  1:48 [PATCH 0/9] ASoC: simple-card: tidyup and synchronize patches Kuninori Morimoto
2016-08-25  1:49 ` [PATCH 1/9] ASoC: simple-card: call of_node_put() for dai_link Kuninori Morimoto
2016-08-25  1:50 ` [PATCH 2/9] ASoC: simple-card: tidyup mclk-fs of_property_read_u32() usage Kuninori Morimoto
2016-08-25  1:50 ` [PATCH 3/9] ASoC: simple-card: code sync: tidyup simple_priv_to_xxx() macro Kuninori Morimoto
2016-08-25  1:50 ` [PATCH 4/9] ASoC: simple-card: code sync: use simple_priv_to_props() macro Kuninori Morimoto
2016-08-25  1:51 ` [PATCH 5/9] ASoC: simple-card: is GPL v2 Kuninori Morimoto
2016-08-25  1:51 ` [PATCH 6/9] ASoC: simple-card: code sync: tidyup white line Kuninori Morimoto
2016-08-25  1:52 ` [PATCH 7/9] ASoC: simple-card: code sync: use tag Kuninori Morimoto
2016-08-25  1:52 ` [PATCH 8/9] ASoC: simple-card: code sync: rename num_link to num Kuninori Morimoto
     [not found]   ` <201608251635.kJNOT64O%fengguang.wu@intel.com>
2016-08-26  2:51     ` Kuninori Morimoto
2016-08-25  1:53 ` [PATCH 9/9] ASoC: simple-card: use kzalloc() for dai_props / dai_link Kuninori Morimoto

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.