ASoC: Remove DAPM restriction on mixer control name lengths
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 28 Oct 2008 13:02:31 +0000 (13:02 +0000)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 30 Oct 2008 14:34:03 +0000 (14:34 +0000)
As well as ensuring that UI-relevant parts of control names don't get
truncated in the DAPM code this avoids conflicts in long control names
that differ only at the end of a long string.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/soc-dapm.c

index b51d82285be4aae8a4b08e0e1f5d7a63281a4233..407092c226f9c070749987115d5f92ad6c517916 100644 (file)
@@ -289,7 +289,7 @@ static int dapm_new_mixer(struct snd_soc_codec *codec,
        struct snd_soc_dapm_widget *w)
 {
        int i, ret = 0;
-       char name[32];
+       size_t name_len;
        struct snd_soc_dapm_path *path;
 
        /* add kcontrol */
@@ -303,11 +303,16 @@ static int dapm_new_mixer(struct snd_soc_codec *codec,
                                continue;
 
                        /* add dapm control with long name */
-                       snprintf(name, 32, "%s %s", w->name, w->kcontrols[i].name);
-                       path->long_name = kstrdup (name, GFP_KERNEL);
+                       name_len = 2 + strlen(w->name)
+                               + strlen(w->kcontrols[i].name);
+                       path->long_name = kmalloc(name_len, GFP_KERNEL);
                        if (path->long_name == NULL)
                                return -ENOMEM;
 
+                       snprintf(path->long_name, name_len, "%s %s",
+                                w->name, w->kcontrols[i].name);
+                       path->long_name[name_len - 1] = '\0';
+
                        path->kcontrol = snd_soc_cnew(&w->kcontrols[i], w,
                                path->long_name);
                        ret = snd_ctl_add(codec->card, path->kcontrol);