Linux-Amlogic Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 1/3] ASoC: core: Add common helper to parse aux devs from device tree
@ 2020-08-01 10:02 Stephan Gerhold
  2020-08-01 10:02 ` [PATCH 2/3] ASoC: simple-card: Use snd_soc_of_parse_aux_devs() Stephan Gerhold
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Stephan Gerhold @ 2020-08-01 10:02 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, Stephan Gerhold, Kuninori Morimoto, Kevin Hilman,
	Liam Girdwood, linux-amlogic, Jerome Brunet

simple-card.c and meson-card-utils.c use pretty much the same
helper function to parse auxiliary devices from the device tree.

Make it easier for other drivers to parse these from the device tree
as well by adding a shared helper function to soc-core.c.

snd_soc_of_parse_aux_devs() is pretty much a copy of
meson_card_add_aux_devices() from meson-card-utils.c
with two minor changes:

  - Make property name configurable as parameter
  - Change dev_err() message slightly for consistency with other
    error messages in soc-core.c

Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
---
I have another patch set that I will submit separately which makes
use of this function to parse aux devs from the device tree within
qcom_snd_parse_of(). This is preparation for that patch set.
---
 include/sound/soc.h  |  1 +
 sound/soc/soc-core.c | 31 +++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 5e3919ffb00c..a0918d159fd3 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1331,6 +1331,7 @@ void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card,
 
 int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
 				   const char *propname);
+int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname);
 unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 				     const char *prefix,
 				     struct device_node **bitclkmaster,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 2fe1b2ec7c8f..bf46f410c8c6 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2827,6 +2827,37 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_audio_routing);
 
+int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname)
+{
+	struct device_node *node = card->dev->of_node;
+	struct snd_soc_aux_dev *aux;
+	int num, i;
+
+	num = of_count_phandle_with_args(node, propname, NULL);
+	if (num == -ENOENT) {
+		return 0;
+	} else if (num < 0) {
+		dev_err(card->dev, "ASOC: Property '%s' could not be read: %d\n",
+			propname, num);
+		return num;
+	}
+
+	aux = devm_kcalloc(card->dev, num, sizeof(*aux), GFP_KERNEL);
+	if (!aux)
+		return -ENOMEM;
+	card->aux_dev = aux;
+	card->num_aux_devs = num;
+
+	for_each_card_pre_auxs(card, i, aux) {
+		aux->dlc.of_node = of_parse_phandle(node, propname, i);
+		if (!aux->dlc.of_node)
+			return -EINVAL;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_of_parse_aux_devs);
+
 unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 				     const char *prefix,
 				     struct device_node **bitclkmaster,
-- 
2.27.0


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* [PATCH 2/3] ASoC: simple-card: Use snd_soc_of_parse_aux_devs()
  2020-08-01 10:02 [PATCH 1/3] ASoC: core: Add common helper to parse aux devs from device tree Stephan Gerhold
@ 2020-08-01 10:02 ` Stephan Gerhold
  2020-08-01 10:02 ` [PATCH 3/3] ASoC: meson: " Stephan Gerhold
  2020-08-03  9:39 ` [PATCH 1/3] ASoC: core: Add common helper to parse aux devs from device tree Jerome Brunet
  2 siblings, 0 replies; 5+ messages in thread
From: Stephan Gerhold @ 2020-08-01 10:02 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, Stephan Gerhold, Kuninori Morimoto, Kevin Hilman,
	Liam Girdwood, linux-amlogic, Jerome Brunet

Use the new common snd_soc_of_parse_aux_devs() helper function
to parse auxiliary devices from the device tree. The code is slightly
different but the binding that is parsed is exactly the same.

Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
---
 sound/soc/generic/simple-card.c | 33 +--------------------------------
 1 file changed, 1 insertion(+), 32 deletions(-)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 04d4d28ed511..75365c7bb393 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -424,37 +424,6 @@ static int simple_for_each_link(struct asoc_simple_priv *priv,
 	return ret;
 }
 
-static int simple_parse_aux_devs(struct device_node *node,
-				 struct asoc_simple_priv *priv)
-{
-	struct device *dev = simple_priv_to_dev(priv);
-	struct device_node *aux_node;
-	struct snd_soc_card *card = simple_priv_to_card(priv);
-	int i, n, len;
-
-	if (!of_find_property(node, PREFIX "aux-devs", &len))
-		return 0;		/* Ok to have no aux-devs */
-
-	n = len / sizeof(__be32);
-	if (n <= 0)
-		return -EINVAL;
-
-	card->aux_dev = devm_kcalloc(dev,
-			n, sizeof(*card->aux_dev), GFP_KERNEL);
-	if (!card->aux_dev)
-		return -ENOMEM;
-
-	for (i = 0; i < n; i++) {
-		aux_node = of_parse_phandle(node, PREFIX "aux-devs", i);
-		if (!aux_node)
-			return -EINVAL;
-		card->aux_dev[i].dlc.of_node = aux_node;
-	}
-
-	card->num_aux_devs = n;
-	return 0;
-}
-
 static int simple_parse_of(struct asoc_simple_priv *priv)
 {
 	struct device *dev = simple_priv_to_dev(priv);
@@ -504,7 +473,7 @@ static int simple_parse_of(struct asoc_simple_priv *priv)
 	if (ret < 0)
 		return ret;
 
-	ret = simple_parse_aux_devs(top, priv);
+	ret = snd_soc_of_parse_aux_devs(card, PREFIX "aux-devs");
 
 	return ret;
 }
-- 
2.27.0


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* [PATCH 3/3] ASoC: meson: Use snd_soc_of_parse_aux_devs()
  2020-08-01 10:02 [PATCH 1/3] ASoC: core: Add common helper to parse aux devs from device tree Stephan Gerhold
  2020-08-01 10:02 ` [PATCH 2/3] ASoC: simple-card: Use snd_soc_of_parse_aux_devs() Stephan Gerhold
@ 2020-08-01 10:02 ` Stephan Gerhold
  2020-08-03  9:39 ` [PATCH 1/3] ASoC: core: Add common helper to parse aux devs from device tree Jerome Brunet
  2 siblings, 0 replies; 5+ messages in thread
From: Stephan Gerhold @ 2020-08-01 10:02 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, Stephan Gerhold, Kuninori Morimoto, Kevin Hilman,
	Liam Girdwood, linux-amlogic, Jerome Brunet

Use the new common snd_soc_of_parse_aux_devs() helper function
to parse auxiliary devices from the device tree. The new helper
is just a copy of meson_card_add_aux_devices() so there is no
functional change.

Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
---
 sound/soc/meson/meson-card-utils.c | 33 +-----------------------------
 1 file changed, 1 insertion(+), 32 deletions(-)

diff --git a/sound/soc/meson/meson-card-utils.c b/sound/soc/meson/meson-card-utils.c
index 6a64ac01b5ca..300ac8be46ef 100644
--- a/sound/soc/meson/meson-card-utils.c
+++ b/sound/soc/meson/meson-card-utils.c
@@ -254,37 +254,6 @@ static int meson_card_parse_of_optional(struct snd_soc_card *card,
 	return func(card, propname);
 }
 
-static int meson_card_add_aux_devices(struct snd_soc_card *card)
-{
-	struct device_node *node = card->dev->of_node;
-	struct snd_soc_aux_dev *aux;
-	int num, i;
-
-	num = of_count_phandle_with_args(node, "audio-aux-devs", NULL);
-	if (num == -ENOENT) {
-		return 0;
-	} else if (num < 0) {
-		dev_err(card->dev, "error getting auxiliary devices: %d\n",
-			num);
-		return num;
-	}
-
-	aux = devm_kcalloc(card->dev, num, sizeof(*aux), GFP_KERNEL);
-	if (!aux)
-		return -ENOMEM;
-	card->aux_dev = aux;
-	card->num_aux_devs = num;
-
-	for_each_card_pre_auxs(card, i, aux) {
-		aux->dlc.of_node =
-			of_parse_phandle(node, "audio-aux-devs", i);
-		if (!aux->dlc.of_node)
-			return -EINVAL;
-	}
-
-	return 0;
-}
-
 static void meson_card_clean_references(struct meson_card *priv)
 {
 	struct snd_soc_card *card = &priv->card;
@@ -357,7 +326,7 @@ int meson_card_probe(struct platform_device *pdev)
 	if (ret)
 		goto out_err;
 
-	ret = meson_card_add_aux_devices(&priv->card);
+	ret = snd_soc_of_parse_aux_devs(&priv->card, "audio-aux-devs");
 	if (ret)
 		goto out_err;
 
-- 
2.27.0


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH 1/3] ASoC: core: Add common helper to parse aux devs from device tree
  2020-08-01 10:02 [PATCH 1/3] ASoC: core: Add common helper to parse aux devs from device tree Stephan Gerhold
  2020-08-01 10:02 ` [PATCH 2/3] ASoC: simple-card: Use snd_soc_of_parse_aux_devs() Stephan Gerhold
  2020-08-01 10:02 ` [PATCH 3/3] ASoC: meson: " Stephan Gerhold
@ 2020-08-03  9:39 ` Jerome Brunet
  2020-08-03 10:35   ` Stephan Gerhold
  2 siblings, 1 reply; 5+ messages in thread
From: Jerome Brunet @ 2020-08-03  9:39 UTC (permalink / raw)
  To: Stephan Gerhold, Mark Brown
  Cc: Kevin Hilman, alsa-devel, Liam Girdwood, Kuninori Morimoto,
	linux-amlogic


On Sat 01 Aug 2020 at 12:02, Stephan Gerhold <stephan@gerhold.net> wrote:

> simple-card.c and meson-card-utils.c use pretty much the same
> helper function to parse auxiliary devices from the device tree.
>
> Make it easier for other drivers to parse these from the device tree
> as well by adding a shared helper function to soc-core.c.
>
> snd_soc_of_parse_aux_devs() is pretty much a copy of
> meson_card_add_aux_devices() from meson-card-utils.c
> with two minor changes:
>
>   - Make property name configurable as parameter
>   - Change dev_err() message slightly for consistency with other
>     error messages in soc-core.c
>
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>

When you send multiple patches like that, you should a cover-letter
describing the overall purpose of the patchset, then the patches

If you look around on the mailing list this cover is usually starting
with the subject "[PATCH 0/X]"

Apart from this, the change looks good to me

Reviewed-by: Jerome Brunet <jbrunet@baylibre.com>

> ---
> I have another patch set that I will submit separately which makes
> use of this function to parse aux devs from the device tree within
> qcom_snd_parse_of(). This is preparation for that patch set.
> ---
>  include/sound/soc.h  |  1 +
>  sound/soc/soc-core.c | 31 +++++++++++++++++++++++++++++++
>  2 files changed, 32 insertions(+)
>
> diff --git a/include/sound/soc.h b/include/sound/soc.h
> index 5e3919ffb00c..a0918d159fd3 100644
> --- a/include/sound/soc.h
> +++ b/include/sound/soc.h
> @@ -1331,6 +1331,7 @@ void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card,
>  
>  int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
>  				   const char *propname);
> +int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname);
>  unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
>  				     const char *prefix,
>  				     struct device_node **bitclkmaster,
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index 2fe1b2ec7c8f..bf46f410c8c6 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -2827,6 +2827,37 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
>  }
>  EXPORT_SYMBOL_GPL(snd_soc_of_parse_audio_routing);
>  
> +int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname)
> +{
> +	struct device_node *node = card->dev->of_node;
> +	struct snd_soc_aux_dev *aux;
> +	int num, i;
> +
> +	num = of_count_phandle_with_args(node, propname, NULL);
> +	if (num == -ENOENT) {
> +		return 0;
> +	} else if (num < 0) {
> +		dev_err(card->dev, "ASOC: Property '%s' could not be read: %d\n",
> +			propname, num);
> +		return num;
> +	}
> +
> +	aux = devm_kcalloc(card->dev, num, sizeof(*aux), GFP_KERNEL);
> +	if (!aux)
> +		return -ENOMEM;
> +	card->aux_dev = aux;
> +	card->num_aux_devs = num;
> +
> +	for_each_card_pre_auxs(card, i, aux) {
> +		aux->dlc.of_node = of_parse_phandle(node, propname, i);
> +		if (!aux->dlc.of_node)
> +			return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(snd_soc_of_parse_aux_devs);
> +
>  unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
>  				     const char *prefix,
>  				     struct device_node **bitclkmaster,


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH 1/3] ASoC: core: Add common helper to parse aux devs from device tree
  2020-08-03  9:39 ` [PATCH 1/3] ASoC: core: Add common helper to parse aux devs from device tree Jerome Brunet
@ 2020-08-03 10:35   ` Stephan Gerhold
  0 siblings, 0 replies; 5+ messages in thread
From: Stephan Gerhold @ 2020-08-03 10:35 UTC (permalink / raw)
  To: Jerome Brunet
  Cc: alsa-devel, Kuninori Morimoto, Kevin Hilman, Liam Girdwood,
	Mark Brown, linux-amlogic

On Mon, Aug 03, 2020 at 11:39:44AM +0200, Jerome Brunet wrote:
> When you send multiple patches like that, you should a cover-letter
> describing the overall purpose of the patchset, then the patches
> 
> If you look around on the mailing list this cover is usually starting
> with the subject "[PATCH 0/X]"
> 
> Apart from this, the change looks good to me
> 
> Reviewed-by: Jerome Brunet <jbrunet@baylibre.com>
> 

Thanks! I usually do that but I thought in this case the first patch is
descriptive enough for the whole series. I would have just repeated the
same in the cover letter.

Stephan

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-01 10:02 [PATCH 1/3] ASoC: core: Add common helper to parse aux devs from device tree Stephan Gerhold
2020-08-01 10:02 ` [PATCH 2/3] ASoC: simple-card: Use snd_soc_of_parse_aux_devs() Stephan Gerhold
2020-08-01 10:02 ` [PATCH 3/3] ASoC: meson: " Stephan Gerhold
2020-08-03  9:39 ` [PATCH 1/3] ASoC: core: Add common helper to parse aux devs from device tree Jerome Brunet
2020-08-03 10:35   ` Stephan Gerhold

Linux-Amlogic Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-amlogic/0 linux-amlogic/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-amlogic linux-amlogic/ https://lore.kernel.org/linux-amlogic \
		linux-amlogic@lists.infradead.org
	public-inbox-index linux-amlogic

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-amlogic


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git