Alsa-Devel Archive on
 help / color / Atom feed
From: Mark Brown <>
To: Jerome Brunet <>
Cc:, Mark Brown <>,
	Liam Girdwood <>,
Subject: [alsa-devel] Applied "ASoC: core: ensure component names are unique" to the asoc tree
Date: Fri, 14 Feb 2020 20:56:38 +0000
Message-ID: <> (raw)
In-Reply-To: <>

The patch

   ASoC: core: ensure component names are unique

has been applied to the asoc tree at 

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.


From b2354e4009a773c00054b964d937e1b81cb92078 Mon Sep 17 00:00:00 2001
From: Jerome Brunet <>
Date: Fri, 14 Feb 2020 14:47:04 +0100
Subject: [PATCH] ASoC: core: ensure component names are unique

Make sure each ASoC component is registered with a unique name.
The component is derived from the device name. If a device registers more
than one component, the component names will be the same.

This usually brings up a warning about the debugfs directory creation of
the component since directory already exists.

In such case, start numbering the component of the device so the names
don't collide anymore.

Signed-off-by: Jerome Brunet <>
Signed-off-by: Mark Brown <>
 sound/soc/soc-core.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 03b87427faa7..6a58a8f6e3c4 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2446,6 +2446,33 @@ static int snd_soc_register_dais(struct snd_soc_component *component,
 	return ret;
+static char *snd_soc_component_unique_name(struct device *dev,
+					   struct snd_soc_component *component)
+	struct snd_soc_component *pos;
+	int count = 0;
+	char *name, *unique;
+	name = fmt_single_name(dev, &component->id);
+	if (!name)
+		return name;
+	/* Count the number of components registred by the device */
+	for_each_component(pos) {
+		if (dev == pos->dev)
+			count++;
+	}
+	/* Keep naming as it is for the 1st component */
+	if (!count)
+		return name;
+	unique = devm_kasprintf(dev, GFP_KERNEL, "%s-%d", name, count);
+	devm_kfree(dev, name);
+	return unique;
 static int snd_soc_component_initialize(struct snd_soc_component *component,
 	const struct snd_soc_component_driver *driver, struct device *dev)
@@ -2454,7 +2481,7 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
-	component->name = fmt_single_name(dev, &component->id);
+	component->name = snd_soc_component_unique_name(dev, component);
 	if (!component->name) {
 		dev_err(dev, "ASoC: Failed to allocate name\n");
 		return -ENOMEM;

Alsa-devel mailing list

  reply index

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-14 13:47 [alsa-devel] [PATCH RFC] ASoC: core: ensure component names are unique Jerome Brunet
2020-02-14 20:56 ` Mark Brown [this message]
     [not found]   ` <>
2020-02-17 12:13     ` [alsa-devel] Applied "ASoC: core: ensure component names are unique" to the asoc tree Marek Szyprowski
2020-02-17 13:18       ` Jerome Brunet
2020-02-17 14:36         ` Marek Szyprowski
2020-02-17 17:23           ` Stefan Wahren
2020-02-17 18:06           ` [RFT/DONTMERGE] ASoC: devm_snd_soc_register_component fixup Jerome Brunet
2020-02-18  6:47             ` Marek Szyprowski
2020-02-18  9:32               ` Jerome Brunet
2020-02-17 13:22       ` [alsa-devel] Applied "ASoC: core: ensure component names are unique" to the asoc tree Peter Ujfalusi
2020-02-18 18:55   ` Jerome Brunet
2020-02-18 19:03     ` Mark Brown

Reply instructions:

You may reply publically 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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Alsa-Devel Archive on

Archives are clonable:
	git clone --mirror alsa-devel/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 alsa-devel alsa-devel/ \
	public-inbox-index alsa-devel

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone