mirror of
https://github.com/Fishwaldo/build.git
synced 2025-07-23 13:29:33 +00:00
* Move Meson64 to 5.6.y * Move Meson64 U-boot to 2020.04 Tested on Odroid C2 * Merge, replace and update patches from Khadas branch
73 lines
2.3 KiB
Diff
73 lines
2.3 KiB
Diff
From 012945ce90302cd41203fab68ab6d31399e774a9 Mon Sep 17 00:00:00 2001
|
|
From: Jerome Brunet <jbrunet@baylibre.com>
|
|
Date: Fri, 14 Feb 2020 14:47:04 +0100
|
|
Subject: [PATCH 012/101] FROMGIT: 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 <jbrunet@baylibre.com>
|
|
Link: https://lore.kernel.org/r/20200214134704.342501-1-jbrunet@baylibre.com
|
|
Signed-off-by: Mark Brown <broonie@kernel.org>
|
|
---
|
|
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,
|
|
INIT_LIST_HEAD(&component->card_list);
|
|
mutex_init(&component->io_mutex);
|
|
|
|
- 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;
|
|
--
|
|
2.17.1
|
|
|