diff mbox series

[1/3] ASoC: core: Add common helper to parse aux devs from device tree

Message ID 20200801100257.22658-1-stephan@gerhold.net (mailing list archive)
State Not Applicable
Headers show
Series [1/3] ASoC: core: Add common helper to parse aux devs from device tree | expand

Commit Message

Stephan Gerhold Aug. 1, 2020, 10:02 a.m. UTC
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(+)

Comments

Jerome Brunet Aug. 3, 2020, 9:39 a.m. UTC | #1
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,
Stephan Gerhold Aug. 3, 2020, 10:35 a.m. UTC | #2
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
Mark Brown Aug. 18, 2020, 4:53 p.m. UTC | #3
On Sat, 1 Aug 2020 12:02:55 +0200, Stephan Gerhold 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:
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/3] ASoC: core: Add common helper to parse aux devs from device tree
      commit: 1ae0965dc21698ba41638c95b5478779f3c4a9e4
[2/3] ASoC: simple-card: Use snd_soc_of_parse_aux_devs()
      commit: d9ffff696c5b468ba5a4ddb2cbc05c9e4dd4b2d1
[3/3] ASoC: meson: Use snd_soc_of_parse_aux_devs()
      commit: 6bc37d32f630363b68059e3fa854383e6abf171e

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
diff mbox series

Patch

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,