ASoC: core: remove artificial component and DAI name constraint
Current fmt_single_name code limits maximum name of a DAI or component to 32 bytes. On some systems corresponding device names might be longer than that (e.g. 17300000.remoteproc:glink-edge:apr:apr-service@8:routing). This will result in duplicate DAI/component names. Rewrite fmt_single_name() to remove such length limitations. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Link: https://lore.kernel.org/r/20200827205100.1479331-1-dmitry.baryshkov@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
4b15c49719
commit
45dd9943fc
1 changed files with 16 additions and 19 deletions
|
@ -44,8 +44,6 @@
|
||||||
#define CREATE_TRACE_POINTS
|
#define CREATE_TRACE_POINTS
|
||||||
#include <trace/events/asoc.h>
|
#include <trace/events/asoc.h>
|
||||||
|
|
||||||
#define NAME_SIZE 32
|
|
||||||
|
|
||||||
static DEFINE_MUTEX(client_mutex);
|
static DEFINE_MUTEX(client_mutex);
|
||||||
static LIST_HEAD(component_list);
|
static LIST_HEAD(component_list);
|
||||||
static LIST_HEAD(unbind_card_list);
|
static LIST_HEAD(unbind_card_list);
|
||||||
|
@ -2231,13 +2229,14 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_card);
|
||||||
*/
|
*/
|
||||||
static char *fmt_single_name(struct device *dev, int *id)
|
static char *fmt_single_name(struct device *dev, int *id)
|
||||||
{
|
{
|
||||||
char *found, name[NAME_SIZE];
|
const char *devname = dev_name(dev);
|
||||||
|
char *found, *name;
|
||||||
int id1, id2;
|
int id1, id2;
|
||||||
|
|
||||||
if (dev_name(dev) == NULL)
|
if (devname == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
strlcpy(name, dev_name(dev), NAME_SIZE);
|
name = devm_kstrdup(dev, devname, GFP_KERNEL);
|
||||||
|
|
||||||
/* are we a "%s.%d" name (platform and SPI components) */
|
/* are we a "%s.%d" name (platform and SPI components) */
|
||||||
found = strstr(name, dev->driver->name);
|
found = strstr(name, dev->driver->name);
|
||||||
|
@ -2250,23 +2249,21 @@ static char *fmt_single_name(struct device *dev, int *id)
|
||||||
found[strlen(dev->driver->name)] = '\0';
|
found[strlen(dev->driver->name)] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
/* I2C component devices are named "bus-addr" */
|
/* I2C component devices are named "bus-addr" */
|
||||||
if (sscanf(name, "%x-%x", &id1, &id2) == 2) {
|
} else if (sscanf(name, "%x-%x", &id1, &id2) == 2) {
|
||||||
char tmp[NAME_SIZE];
|
|
||||||
|
|
||||||
/* create unique ID number from I2C addr and bus */
|
/* create unique ID number from I2C addr and bus */
|
||||||
*id = ((id1 & 0xffff) << 16) + id2;
|
*id = ((id1 & 0xffff) << 16) + id2;
|
||||||
|
|
||||||
|
devm_kfree(dev, name);
|
||||||
|
|
||||||
/* sanitize component name for DAI link creation */
|
/* sanitize component name for DAI link creation */
|
||||||
snprintf(tmp, NAME_SIZE, "%s.%s", dev->driver->name,
|
name = devm_kasprintf(dev, GFP_KERNEL, "%s.%s", dev->driver->name, devname);
|
||||||
name);
|
} else {
|
||||||
strlcpy(name, tmp, NAME_SIZE);
|
|
||||||
} else
|
|
||||||
*id = 0;
|
*id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return devm_kstrdup(dev, name, GFP_KERNEL);
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue