* [PATCH] ASoC: core: Optionaly add the component driver name to the component name
@ 2020-09-10 20:03 Dafna Hirschfeld
2020-09-11 10:14 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Dafna Hirschfeld @ 2020-09-10 20:03 UTC (permalink / raw)
To: linux-kernel, alsa-devel, broonie
Cc: tiwai, enric.balletbo, kernel, dafna3, lgirdwood, perex,
linux-mediatek, ranjani.sridharan, matthias.bgg,
dmitry.baryshkov, Dafna Hirschfeld
The ASoC platform driver for Mediatek MT8173 registers
several components with identical name. This cause an
error:
"Directory '11220000.audio-controller' with parent 'mtk-rt5650' already present!"
when adding debugfs directory for those components.
To fix this, the function 'fmt_single_name' can receive the name
of the component driver and concatenate it to the name of the debugfs
directory for the component.
Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
---
sound/soc/soc-core.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 74df22486e30..f470e713b030 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2227,7 +2227,7 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_card);
* Simplify DAI link configuration by removing ".-1" from device names
* and sanitizing names.
*/
-static char *fmt_single_name(struct device *dev, int *id)
+static char *fmt_single_name(struct device *dev, int *id, const char *component_driver_name)
{
const char *devname = dev_name(dev);
char *found, *name;
@@ -2263,6 +2263,12 @@ static char *fmt_single_name(struct device *dev, int *id)
*id = 0;
}
+ if (component_driver_name) {
+ char *tmp = name;
+
+ name = devm_kasprintf(dev, GFP_KERNEL, "%s-%s", name, component_driver_name);
+ devm_kfree(dev, tmp);
+ }
return name;
}
@@ -2327,7 +2333,7 @@ struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
*/
if (legacy_dai_naming &&
(dai_drv->id == 0 || dai_drv->name == NULL)) {
- dai->name = fmt_single_name(dev, &dai->id);
+ dai->name = fmt_single_name(dev, &dai->id, NULL);
} else {
dai->name = fmt_multiple_name(dev, dai_drv);
if (dai_drv->id)
@@ -2460,7 +2466,7 @@ 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 = fmt_single_name(dev, &component->id, driver->name);
if (!component->name) {
dev_err(dev, "ASoC: Failed to allocate name\n");
return -ENOMEM;
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ASoC: core: Optionaly add the component driver name to the component name
2020-09-10 20:03 [PATCH] ASoC: core: Optionaly add the component driver name to the component name Dafna Hirschfeld
@ 2020-09-11 10:14 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2020-09-11 10:14 UTC (permalink / raw)
To: Dafna Hirschfeld
Cc: linux-kernel, alsa-devel, tiwai, enric.balletbo, kernel, dafna3,
lgirdwood, perex, linux-mediatek, ranjani.sridharan,
matthias.bgg, dmitry.baryshkov
[-- Attachment #1: Type: text/plain, Size: 282 bytes --]
On Thu, Sep 10, 2020 at 10:03:08PM +0200, Dafna Hirschfeld wrote:
> The ASoC platform driver for Mediatek MT8173 registers
> several components with identical name. This cause an
Why is one driver registering multiple components for a single
underlying device in the first place?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-09-11 10:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-10 20:03 [PATCH] ASoC: core: Optionaly add the component driver name to the component name Dafna Hirschfeld
2020-09-11 10:14 ` Mark Brown
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).