* [PATCH 0/4] ASoC: simple-card: DT fix and multi DAI links extension @ 2014-02-21 15:12 Jean-Francois Moine 2014-02-20 17:25 ` [PATCH 1/4] ASoC: simple-card: Fix device node locks Jean-Francois Moine 2014-02-21 11:43 ` [PATCH 4/4] ASoC: simple-card: add DT documentation for multi-DAI links Jean-Francois Moine 0 siblings, 2 replies; 6+ messages in thread From: Jean-Francois Moine @ 2014-02-21 15:12 UTC (permalink / raw) To: Mark Brown Cc: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw, Kuninori Morimoto, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Xiubo Li, devicetree-u79uwXL29TY76Z2rM5mHXA This patch series fixes a small problem about node device locks and also extends the simple card driver to handle many DAI links as this exists in the Cubox audio subsystem. Jean-Francois Moine (4): ASoC: simple-card: Fix device node locks ASoC: simple-card: dynamically allocate the DAI link array ASoC: simple-card: accept many DAI links ASoC: simple-card: add DT documentation for multi-DAI links .../devicetree/bindings/sound/simple-card.txt | 34 ++++- sound/soc/generic/simple-card.c | 148 +++++++++++++++------ 2 files changed, 137 insertions(+), 45 deletions(-) -- 1.9.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] ASoC: simple-card: Fix device node locks 2014-02-21 15:12 [PATCH 0/4] ASoC: simple-card: DT fix and multi DAI links extension Jean-Francois Moine @ 2014-02-20 17:25 ` Jean-Francois Moine [not found] ` <4dca81f45b67a4dcb21271e57409ba114c3b59cb.1392995566.git.moinejf-GANU6spQydw@public.gmane.org> 2014-02-21 11:43 ` [PATCH 4/4] ASoC: simple-card: add DT documentation for multi-DAI links Jean-Francois Moine 1 sibling, 1 reply; 6+ messages in thread From: Jean-Francois Moine @ 2014-02-20 17:25 UTC (permalink / raw) To: Mark Brown Cc: alsa-devel, Kuninori Morimoto, linux-kernel, Xiubo Li, devicetree Some device nodes stay locked and some other ones are not locked while being used during the card lifetime. Signed-off-by: Jean-Francois Moine <moinejf@free.fr> --- sound/soc/generic/simple-card.c | 51 +++++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 4fe8abc..8809ab4 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -92,7 +92,7 @@ asoc_simple_card_sub_parse_of(struct device_node *np, /* get dai->name */ ret = snd_soc_of_get_dai_name(np, name); if (ret < 0) - goto parse_error; + return ret; /* * bitclock-inversion, frame-inversion @@ -112,7 +112,7 @@ asoc_simple_card_sub_parse_of(struct device_node *np, clk = of_clk_get(np, 0); if (IS_ERR(clk)) { ret = PTR_ERR(clk); - goto parse_error; + return ret; } dai->sysclk = clk_get_rate(clk); @@ -126,12 +126,7 @@ asoc_simple_card_sub_parse_of(struct device_node *np, dai->sysclk = clk_get_rate(clk); } - ret = 0; - -parse_error: - of_node_put(node); - - return ret; + return 0; } static int asoc_simple_card_parse_of(struct device_node *node, @@ -169,22 +164,26 @@ static int asoc_simple_card_parse_of(struct device_node *node, /* CPU sub-node */ ret = -EINVAL; np = of_get_child_by_name(node, "simple-audio-card,cpu"); - if (np) + if (np) { ret = asoc_simple_card_sub_parse_of(np, priv->daifmt, &priv->cpu_dai, &dai_link->cpu_of_node, &dai_link->cpu_dai_name); + of_node_put(np); + } if (ret < 0) return ret; /* CODEC sub-node */ ret = -EINVAL; np = of_get_child_by_name(node, "simple-audio-card,codec"); - if (np) + if (np) { ret = asoc_simple_card_sub_parse_of(np, priv->daifmt, &priv->codec_dai, &dai_link->codec_of_node, &dai_link->codec_dai_name); + of_node_put(np); + } if (ret < 0) return ret; @@ -219,6 +218,26 @@ static int asoc_simple_card_parse_of(struct device_node *node, return 0; } +static int asoc_simple_card_purge(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + struct snd_soc_dai_link *dai_link; + struct device_node *np; + int num_links; + + for (num_links = 0, dai_link = card->dai_link; + num_links < card->num_links; + num_links++, dai_link++) { + np = (struct device_node *) dai_link->cpu_of_node; + if (np) + of_node_put(np); + np = (struct device_node *) dai_link->codec_of_node; + if (np) + of_node_put(np); + } + return 0; +} + static int asoc_simple_card_probe(struct platform_device *pdev) { struct simple_card_data *priv; @@ -246,7 +265,7 @@ static int asoc_simple_card_probe(struct platform_device *pdev) if (ret < 0) { if (ret != -EPROBE_DEFER) dev_err(dev, "parse error %d\n", ret); - return ret; + goto err; } } else { struct asoc_simple_card_info *cinfo; @@ -287,7 +306,14 @@ static int asoc_simple_card_probe(struct platform_device *pdev) snd_soc_card_set_drvdata(&priv->snd_card, priv); - return devm_snd_soc_register_card(&pdev->dev, &priv->snd_card); + ret = devm_snd_soc_register_card(&pdev->dev, &priv->snd_card); + if (ret < 0) + goto err; + return 0; + +err: + asoc_simple_card_purge(pdev); + return ret; } static const struct of_device_id asoc_simple_of_match[] = { @@ -303,6 +329,7 @@ static struct platform_driver asoc_simple_card = { .of_match_table = asoc_simple_of_match, }, .probe = asoc_simple_card_probe, + .remove = asoc_simple_card_purge, }; module_platform_driver(asoc_simple_card); -- 1.9.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
[parent not found: <4dca81f45b67a4dcb21271e57409ba114c3b59cb.1392995566.git.moinejf-GANU6spQydw@public.gmane.org>]
* RE: [PATCH 1/4] ASoC: simple-card: Fix device node locks [not found] ` <4dca81f45b67a4dcb21271e57409ba114c3b59cb.1392995566.git.moinejf-GANU6spQydw@public.gmane.org> @ 2014-02-24 2:17 ` Li.Xiubo-KZfg59tc24xl57MIdRCFDg [not found] ` <23e531e0edb34aa9b84799e558abaf26-+7O3WWA3DPshjIn37xzcLOO6mTEJWrR4XA4E9RH9d+qIuWR1G4zioA@public.gmane.org> 2014-02-25 12:42 ` Mark Brown 1 sibling, 1 reply; 6+ messages in thread From: Li.Xiubo-KZfg59tc24xl57MIdRCFDg @ 2014-02-24 2:17 UTC (permalink / raw) To: Jean-Francois Moine, Mark Brown Cc: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org, Kuninori Morimoto, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > @@ -169,22 +164,26 @@ static int asoc_simple_card_parse_of(struct device_node > *node, > /* CPU sub-node */ > ret = -EINVAL; > np = of_get_child_by_name(node, "simple-audio-card,cpu"); > - if (np) > + if (np) { > ret = asoc_simple_card_sub_parse_of(np, priv->daifmt, > &priv->cpu_dai, > &dai_link->cpu_of_node, > &dai_link->cpu_dai_name); > + of_node_put(np); Does the of_node_put(np) is really needed here ? > + } > if (ret < 0) > return ret; > > /* CODEC sub-node */ > ret = -EINVAL; > np = of_get_child_by_name(node, "simple-audio-card,codec"); > - if (np) > + if (np) { > ret = asoc_simple_card_sub_parse_of(np, priv->daifmt, > &priv->codec_dai, > &dai_link->codec_of_node, > &dai_link->codec_dai_name); > + of_node_put(np); The same here... > + } > if (ret < 0) > return ret; > Thanks, -- Best Regards, Xiubo -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <23e531e0edb34aa9b84799e558abaf26-+7O3WWA3DPshjIn37xzcLOO6mTEJWrR4XA4E9RH9d+qIuWR1G4zioA@public.gmane.org>]
* Re: [PATCH 1/4] ASoC: simple-card: Fix device node locks [not found] ` <23e531e0edb34aa9b84799e558abaf26-+7O3WWA3DPshjIn37xzcLOO6mTEJWrR4XA4E9RH9d+qIuWR1G4zioA@public.gmane.org> @ 2014-02-25 7:30 ` Jean-Francois Moine 0 siblings, 0 replies; 6+ messages in thread From: Jean-Francois Moine @ 2014-02-25 7:30 UTC (permalink / raw) To: Li.Xiubo-KZfg59tc24xl57MIdRCFDg@public.gmane.org Cc: Mark Brown, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org, Kuninori Morimoto, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Mon, 24 Feb 2014 02:17:00 +0000 "Li.Xiubo-KZfg59tc24xl57MIdRCFDg@public.gmane.org" <Li.Xiubo-KZfg59tc24xl57MIdRCFDg@public.gmane.org> wrote: > > @@ -169,22 +164,26 @@ static int asoc_simple_card_parse_of(struct device_node > > *node, > > /* CPU sub-node */ > > ret = -EINVAL; > > np = of_get_child_by_name(node, "simple-audio-card,cpu"); > > - if (np) > > + if (np) { > > ret = asoc_simple_card_sub_parse_of(np, priv->daifmt, > > &priv->cpu_dai, > > &dai_link->cpu_of_node, > > &dai_link->cpu_dai_name); > > + of_node_put(np); > > Does the of_node_put(np) is really needed here ? [snip] Yes, of_get_child_by_name() increments the node refcount and np is not used afterwards. But, you are right, this creates a bug in the next patch when using of_get_next_child(). I will fix it. Thanks. -- Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/ -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/4] ASoC: simple-card: Fix device node locks [not found] ` <4dca81f45b67a4dcb21271e57409ba114c3b59cb.1392995566.git.moinejf-GANU6spQydw@public.gmane.org> 2014-02-24 2:17 ` Li.Xiubo-KZfg59tc24xl57MIdRCFDg @ 2014-02-25 12:42 ` Mark Brown 1 sibling, 0 replies; 6+ messages in thread From: Mark Brown @ 2014-02-25 12:42 UTC (permalink / raw) To: Jean-Francois Moine Cc: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw, Kuninori Morimoto, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Xiubo Li, devicetree-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 790 bytes --] On Thu, Feb 20, 2014 at 06:25:12PM +0100, Jean-Francois Moine wrote: > Some device nodes stay locked and some other ones are not locked > while being used during the card lifetime. Please pay more attention to describing your patches clearly in changelogs and to splitting them up for review. This is a frequent issue and it does make it much harder to check what's happening. In this case you're not actually working with locking but rather with reference counting and there's no real description of the actual errors either. Saying something like "function X takes a reference which we need to drop" would help a lot, and it would let us think about if it's sensible for the function to return holding the reference in the first place and how long the reference needs to be held for. [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 4/4] ASoC: simple-card: add DT documentation for multi-DAI links 2014-02-21 15:12 [PATCH 0/4] ASoC: simple-card: DT fix and multi DAI links extension Jean-Francois Moine 2014-02-20 17:25 ` [PATCH 1/4] ASoC: simple-card: Fix device node locks Jean-Francois Moine @ 2014-02-21 11:43 ` Jean-Francois Moine 1 sibling, 0 replies; 6+ messages in thread From: Jean-Francois Moine @ 2014-02-21 11:43 UTC (permalink / raw) To: Mark Brown Cc: alsa-devel, Kuninori Morimoto, linux-kernel, Xiubo Li, devicetree There may be many couples of CPU/CODEC DAI links. The example 2 is extracted from the Cubox DT. Signed-off-by: Jean-Francois Moine <moinejf@free.fr> --- .../devicetree/bindings/sound/simple-card.txt | 34 +++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt index 0527358..60306bf 100644 --- a/Documentation/devicetree/bindings/sound/simple-card.txt +++ b/Documentation/devicetree/bindings/sound/simple-card.txt @@ -24,6 +24,9 @@ Required subnodes: - simple-audio-card,cpu : CPU sub-node - simple-audio-card,codec : CODEC sub-node + There may be one or many couples (simple-audio-card,cpu, simple-audio-card,codec) + (see example 2). + Required CPU/CODEC subnodes properties: - sound-dai : phandle and port of CPU/CODEC @@ -41,7 +44,7 @@ Optional CPU/CODEC subnodes properties: clock node (= common clock), or "system-clock-frequency" (if system doens't support common clock) -Example: +Example 1: sound { compatible = "simple-audio-card"; @@ -83,3 +86,32 @@ sh_fsi2: sh_fsi2@ec230000 { interrupt-parent = <&gic>; interrupts = <0 146 0x4>; }; + +Example 2: + +sound { + compatible = "simple-audio-card"; + simple-audio-card,name = "Cubox Audio"; + + simple-audio-card,cpu@0 { /* I2S - HDMI */ + sound-dai = <&audio1 0>; + format = "i2s"; + }; + simple-audio-card,codec@0 { + sound-dai = <&tda998x 0>; + }; + + simple-audio-card,cpu@1 { /* S/PDIF - HDMI */ + sound-dai = <&audio1 1>; + }; + simple-audio-card,codec@1 { + sound-dai = <&tda998x 1>; + }; + + simple-audio-card,cpu@2 { /* S/PDIF - S/PDIF */ + sound-dai = <&audio1 1>; + }; + simple-audio-card,codec@2 { + sound-dai = <&spdif_codec>; + }; +}; -- 1.9.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-02-25 12:42 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-02-21 15:12 [PATCH 0/4] ASoC: simple-card: DT fix and multi DAI links extension Jean-Francois Moine 2014-02-20 17:25 ` [PATCH 1/4] ASoC: simple-card: Fix device node locks Jean-Francois Moine [not found] ` <4dca81f45b67a4dcb21271e57409ba114c3b59cb.1392995566.git.moinejf-GANU6spQydw@public.gmane.org> 2014-02-24 2:17 ` Li.Xiubo-KZfg59tc24xl57MIdRCFDg [not found] ` <23e531e0edb34aa9b84799e558abaf26-+7O3WWA3DPshjIn37xzcLOO6mTEJWrR4XA4E9RH9d+qIuWR1G4zioA@public.gmane.org> 2014-02-25 7:30 ` Jean-Francois Moine 2014-02-25 12:42 ` Mark Brown 2014-02-21 11:43 ` [PATCH 4/4] ASoC: simple-card: add DT documentation for multi-DAI links Jean-Francois Moine
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).