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)
{
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;