Skip to content

Commit 45dd994

Browse files
Dmitry Baryshkovbroonie
authored andcommitted
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>
1 parent 4b15c49 commit 45dd994

1 file changed

Lines changed: 15 additions & 18 deletions

File tree

‎sound/soc/soc-core.c‎

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
#define CREATE_TRACE_POINTS
4545
#include <trace/events/asoc.h>
4646

47-
#define NAME_SIZE 32
48-
4947
static DEFINE_MUTEX(client_mutex);
5048
static LIST_HEAD(component_list);
5149
static LIST_HEAD(unbind_card_list);
@@ -2231,13 +2229,14 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_card);
22312229
*/
22322230
static char *fmt_single_name(struct device *dev, int *id)
22332231
{
2234-
char *found, name[NAME_SIZE];
2232+
const char *devname = dev_name(dev);
2233+
char *found, *name;
22352234
int id1, id2;
22362235

2237-
if (dev_name(dev) == NULL)
2236+
if (devname == NULL)
22382237
return NULL;
22392238

2240-
strlcpy(name, dev_name(dev), NAME_SIZE);
2239+
name = devm_kstrdup(dev, devname, GFP_KERNEL);
22412240

22422241
/* are we a "%s.%d" name (platform and SPI components) */
22432242
found = strstr(name, dev->driver->name);
@@ -2250,23 +2249,21 @@ static char *fmt_single_name(struct device *dev, int *id)
22502249
found[strlen(dev->driver->name)] = '\0';
22512250
}
22522251

2253-
} else {
2254-
/* I2C component devices are named "bus-addr" */
2255-
if (sscanf(name, "%x-%x", &id1, &id2) == 2) {
2256-
char tmp[NAME_SIZE];
2252+
/* I2C component devices are named "bus-addr" */
2253+
} else if (sscanf(name, "%x-%x", &id1, &id2) == 2) {
22572254

2258-
/* create unique ID number from I2C addr and bus */
2259-
*id = ((id1 & 0xffff) << 16) + id2;
2255+
/* create unique ID number from I2C addr and bus */
2256+
*id = ((id1 & 0xffff) << 16) + id2;
22602257

2261-
/* sanitize component name for DAI link creation */
2262-
snprintf(tmp, NAME_SIZE, "%s.%s", dev->driver->name,
2263-
name);
2264-
strlcpy(name, tmp, NAME_SIZE);
2265-
} else
2266-
*id = 0;
2258+
devm_kfree(dev, name);
2259+
2260+
/* sanitize component name for DAI link creation */
2261+
name = devm_kasprintf(dev, GFP_KERNEL, "%s.%s", dev->driver->name, devname);
2262+
} else {
2263+
*id = 0;
22672264
}
22682265

2269-
return devm_kstrdup(dev, name, GFP_KERNEL);
2266+
return name;
22702267
}
22712268

22722269
/*

0 commit comments

Comments
 (0)