All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Mark Brown <broonie@kernel.org>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>,
	Simon <horms@verge.net.au>, Liam Girdwood <lgirdwood@gmail.com>
Subject: [PATCH 9/9] ASoC: simple-card: use kzalloc() for dai_props / dai_link
Date: Thu, 25 Aug 2016 01:53:02 +0000	[thread overview]
Message-ID: <87oa4h1v1u.wl%kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <871t1d39ta.wl%kuninori.morimoto.gx@renesas.com>


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

      parent reply	other threads:[~2016-08-25  1:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Kuninori Morimoto [this message]

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=87oa4h1v1u.wl%kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=horms@verge.net.au \
    --cc=lgirdwood@gmail.com \
    /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 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.