mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
ASoC: soc-core: save ID if param was set in fmt_single_name()
fmt_single_name() requests "ind *id" and not allow NULL for it. But sometimes we don't need it. Allow NULL. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://patch.msgid.link/878qm8uunz.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
committed by
Mark Brown
parent
8167f4f425
commit
6ada7351af
@@ -2604,6 +2604,7 @@ static char *fmt_single_name(struct device *dev, int *id)
|
||||
const char *devname = dev_name(dev);
|
||||
char *found, *name;
|
||||
unsigned int id1, id2;
|
||||
int __id;
|
||||
|
||||
if (devname == NULL)
|
||||
return NULL;
|
||||
@@ -2616,10 +2617,10 @@ static char *fmt_single_name(struct device *dev, int *id)
|
||||
found = strstr(name, dev->driver->name);
|
||||
if (found) {
|
||||
/* get ID */
|
||||
if (sscanf(&found[strlen(dev->driver->name)], ".%d", id) == 1) {
|
||||
if (sscanf(&found[strlen(dev->driver->name)], ".%d", &__id) == 1) {
|
||||
|
||||
/* discard ID from name if ID == -1 */
|
||||
if (*id == -1)
|
||||
if (__id == -1)
|
||||
found[strlen(dev->driver->name)] = '\0';
|
||||
}
|
||||
|
||||
@@ -2627,16 +2628,19 @@ static char *fmt_single_name(struct device *dev, int *id)
|
||||
} else if (sscanf(name, "%x-%x", &id1, &id2) == 2) {
|
||||
|
||||
/* 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 */
|
||||
name = devm_kasprintf(dev, GFP_KERNEL, "%s.%s", dev->driver->name, devname);
|
||||
} else {
|
||||
*id = 0;
|
||||
__id = 0;
|
||||
}
|
||||
|
||||
if (id)
|
||||
*id = __id;
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user