From: Xiubo Li <Li.Xiubo@freescale.com>
To: broonie@kernel.org, perex@perex.cz, lgirdwood@gmail.com,
tiwai@suse.de, moinejf@free.fr, andrew@lunn.ch,
kuninori.morimoto.gx@renesas.com, jsarha@ti.com,
devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com,
ijc+devicetree@hellion.org.uk, galak@codeaurora.org
Cc: linux-kernel@vger.kernel.org, Xiubo Li <Li.Xiubo@freescale.com>
Subject: [PATCHv2 2/4] ASoC: simple-card: Merge single and muti DAI link(s) code.
Date: Tue, 2 Sep 2014 17:26:07 +0800 [thread overview]
Message-ID: <1409649969-15759-3-git-send-email-Li.Xiubo@freescale.com> (raw)
In-Reply-To: <1409649969-15759-1-git-send-email-Li.Xiubo@freescale.com>
This patch will split the DT node into old style and new style:
The new style will merge the single DAI link and muti DAI links code
together, the new style will be easier to add muti DAI links from old
single DAI link DTs.
This patch will maintian compatibility with the old DTs.
Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
---
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 cad2b30..667fa49 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -198,6 +198,7 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
char *prefix = "";
int ret;
+ /* For single DAI link & old style of DT node */
if (is_top_level_node)
prefix = "simple-audio-card,";
@@ -306,14 +307,16 @@ dai_link_of_err:
static int asoc_simple_card_parse_of(struct device_node *node,
struct simple_card_data *priv,
- struct device *dev,
- int multi)
+ struct device *dev)
{
struct snd_soc_dai_link *dai_link = priv->snd_card.dai_link;
struct simple_dai_props *dai_props = priv->dai_props;
u32 val;
int ret;
+ if (!node)
+ return -EINVAL;
+
/* parsing the card name from DT */
snd_soc_of_parse_card_name(&priv->snd_card, "simple-audio-card,name");
@@ -341,7 +344,8 @@ static int asoc_simple_card_parse_of(struct device_node *node,
dev_dbg(dev, "New simple-card: %s\n", priv->snd_card.name ?
priv->snd_card.name : "");
- if (multi) {
+ /* Single/Muti DAI link(s) & New style of DT node */
+ if (of_get_child_by_name(node, "simple-audio-card,dai-link")) {
struct device_node *np = NULL;
int i = 0;
@@ -358,6 +362,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
i++;
}
} else {
+ /* For single DAI link & old style of DT node */
ret = asoc_simple_card_dai_link_of(node, dev,
dai_link, dai_props, true);
if (ret < 0)
@@ -397,16 +402,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, multi, ret;
+ int num_links, ret;
/* get the number of DAI links */
- if (np && of_get_child_by_name(np, "simple-audio-card,dai-link")) {
+ if (np && of_get_child_by_name(np, "simple-audio-card,dai-link"))
num_links = of_get_child_count(np);
- multi = 1;
- } else {
+ else
num_links = 1;
- multi = 0;
- }
/* allocate the private data and the DAI link array */
priv = devm_kzalloc(dev,
@@ -433,7 +435,7 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
if (np && of_device_is_available(np)) {
- ret = asoc_simple_card_parse_of(np, priv, dev, multi);
+ ret = asoc_simple_card_parse_of(np, priv, dev);
if (ret < 0) {
if (ret != -EPROBE_DEFER)
dev_err(dev, "parse error %d\n", ret);
--
1.8.4
next prev parent reply other threads:[~2014-09-02 9:26 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-02 9:26 [PATCHv2 0/4] simple-card: simplify the code Xiubo Li
[not found] ` <1409649969-15759-1-git-send-email-Li.Xiubo-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2014-09-02 9:26 ` [PATCHv2 1/4] ASoC: simple-card: add asoc_simple_card_fmt_master() to " Xiubo Li
2014-09-02 10:21 ` Varka Bhadram
2014-09-02 10:38 ` Jean-Francois Moine
2014-09-02 10:42 ` Varka Bhadram
2014-09-02 11:04 ` Takashi Iwai
[not found] ` <54059F20.4080509-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-09-02 11:09 ` Jean-Francois Moine
2014-09-02 11:32 ` Jyri Sarha
2014-09-02 11:10 ` Jyri Sarha
2014-09-03 2:37 ` Li.Xiubo
2014-09-03 8:36 ` Jyri Sarha
[not found] ` <5406D317.5000403-l0cyMroinI0@public.gmane.org>
2014-09-03 8:39 ` Li.Xiubo-KZfg59tc24xl57MIdRCFDg
[not found] ` <1409649969-15759-2-git-send-email-Li.Xiubo-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2014-09-03 0:26 ` [alsa-devel] " Kuninori Morimoto
2014-09-03 2:21 ` Li.Xiubo
[not found] ` <b0ce0040e47a4ea8ab00ae7e113ecb41-swgC6WJTr6EbUgZD/0KOGpwN6zqB+hSMnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2014-09-03 3:36 ` Kuninori Morimoto
[not found] ` <87y4u15qa2.wl%kuninori.morimoto.gx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-09-03 3:41 ` Li.Xiubo-KZfg59tc24xl57MIdRCFDg
2014-09-03 3:37 ` Li.Xiubo-KZfg59tc24xl57MIdRCFDg
[not found] ` <df7936d5863948b0a0a33aa8283d6a67-swgC6WJTr6EbUgZD/0KOGpwN6zqB+hSMnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2014-09-03 4:13 ` Kuninori Morimoto
[not found] ` <87wq9l5ojn.wl%kuninori.morimoto.gx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-09-03 5:33 ` Li.Xiubo-KZfg59tc24xl57MIdRCFDg
2014-09-03 6:48 ` Jean-Francois Moine
2014-09-02 9:26 ` Xiubo Li [this message]
2014-09-02 9:26 ` [PATCHv2 3/4] ASoC: simple-card: Adjust the comments of simple card Xiubo Li
[not found] ` <1409649969-15759-4-git-send-email-Li.Xiubo-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2014-09-02 10:44 ` Jean-Francois Moine
2014-09-03 1:55 ` Li.Xiubo-KZfg59tc24xl57MIdRCFDg
[not found] ` <37e5ba204cb340bc9fe01b7473721a9d-swgC6WJTr6EbUgZD/0KOGpwN6zqB+hSMnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2014-09-03 2:14 ` [alsa-devel] " Kuninori Morimoto
[not found] ` <87zjeh5u2o.wl%kuninori.morimoto.gx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-09-03 2:24 ` Li.Xiubo-KZfg59tc24xl57MIdRCFDg
2014-09-02 9:26 ` [PATCHv2 4/4] ASoC: simple-card: binding: update binding to support the new style Xiubo Li
2014-09-02 10:41 ` Jean-Francois Moine
2014-09-03 1:54 ` Li.Xiubo-KZfg59tc24xl57MIdRCFDg
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=1409649969-15759-3-git-send-email-Li.Xiubo@freescale.com \
--to=li.xiubo@freescale.com \
--cc=alsa-devel@alsa-project.org \
--cc=andrew@lunn.ch \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=galak@codeaurora.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=jsarha@ti.com \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=moinejf@free.fr \
--cc=pawel.moll@arm.com \
--cc=perex@perex.cz \
--cc=robh+dt@kernel.org \
--cc=tiwai@suse.de \
/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;
as well as URLs for NNTP newsgroup(s).