From: Kuninori Morimoto Date: Wed, 4 Jun 2025 02:06:57 +0000 (+0000) Subject: ASoC: soc-core: save ID if param was set in fmt_single_name() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=6ada7351af0c4e295739adfa2c4b780c037b3d27;p=users%2Fjedix%2Flinux-maple.git 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 Link: https://patch.msgid.link/878qm8uunz.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 67bebc339148b..ecea2dddbe9a9 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -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; }