]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ASoC: soc-core: save ID if param was set in fmt_single_name()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Wed, 4 Jun 2025 02:06:57 +0000 (02:06 +0000)
committerMark Brown <broonie@kernel.org>
Sun, 8 Jun 2025 22:31:02 +0000 (23:31 +0100)
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>
sound/soc/soc-core.c

index 67bebc339148b1c1b0573d6454e6e2953cd7ae46..ecea2dddbe9a9bbb61d31d61d904ba6694685776 100644 (file)
@@ -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;
 }