Skip to contentSkip to conversation

ASoC: Fix long name of control for dapm_switch

PATCH In review Joonyoung Shim 2 participants 4 messages Mar 4, 2009 – Mar 6, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: Fix long name of control for dapm_switch

The length of long control name doesn't include the length of widget name at present when widget->id is snd_soc_dapm_switch, so the long control name of dapm_switch is shortened.
To avoid this problem, the long control name only for dapm_mixer_named_ctl must have simply the kcontrol name.

---
 sound/soc/soc-dapm.c |   21 +++++++++------------
 1 files changed, 9 insertions(+), 12 deletions(-)
sound/soc/soc-dapm.c +9 -12
index 4b8dbbf..7a1fed1 100644
@@ -331,26 +331,23 @@ static int dapm_new_mixer(struct snd_soc_codec *codec,
                         * for dapm_mixer_named_ctl this is simply the
                         * kcontrol name.
                         */
-                       name_len = strlen(w->kcontrols[i].name) + 1;
-                       if (w->id == snd_soc_dapm_mixer)
-                               name_len += 1 + strlen(w->name);
+                       if (w->id == snd_soc_dapm_mixer_named_ctl)
+                               name_len = strlen(w->kcontrols[i].name) + 1;
+                       else
+                               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;
 
-                       switch (w->id) {
-                       case snd_soc_dapm_mixer:
-                       default:
-                               snprintf(path->long_name, name_len, "%s %s",
-                                        w->name, w->kcontrols[i].name);
-                       break;
-                       case snd_soc_dapm_mixer_named_ctl:
+                       if (w->id == snd_soc_dapm_mixer_named_ctl)
                                snprintf(path->long_name, name_len, "%s",
                                         w->kcontrols[i].name);
-                       break;
-                       }
+                       else
+                               snprintf(path->long_name, name_len, "%s %s",
+                                        w->name, w->kcontrols[i].name);
 
                        path->long_name[name_len - 1] = '\0';
 
Signature · 5 lines
1.5.6.3


-- 
- Joonyoung Shim
#1 lore raw
Quoted 5 lines · Joonyoung Shim

The length of long control name doesn't include the length of widget name at present when widget->id is snd_soc_dapm_switch, so the long control name of dapm_switch is shortened.
To avoid this problem, the long control name only for dapm_mixer_named_ctl must have simply the kcontrol name.

This is a good catch - thanks!

Unfortunately your patch doesn't apply against the current topic/asoc branch of Takashi's repository, I've implemented a slightly different version of it.

sound/soc/soc-dapm.c static int dapm_new_mixer(struct snd_soc_codec *codec, · line 338

Quoted 8 lines
sound/soc/soc-dapm.c +5 -3
-                       name_len = strlen(w->kcontrols[i].name) + 1;
-                       if (w->id == snd_soc_dapm_mixer)
-                               name_len += 1 + strlen(w->name);
+                       if (w->id == snd_soc_dapm_mixer_named_ctl)
+                               name_len = strlen(w->kcontrols[i].name) + 1;
+                       else
+                               name_len = 2 + strlen(w->name)
+                                       + strlen(w->kcontrols[i].name);

Here I just changed the test to != named_ctl.

sound/soc/soc-dapm.c static int dapm_new_mixer(struct snd_soc_codec *codec, · line 345

Quoted 4 lines
sound/soc/soc-dapm.c +0 -3
-                       switch (w->id) {
-                       case snd_soc_dapm_mixer:
-                       default:

Your chanegs here appear to only flip to an if/else from a switch statement? Please mention things like this in your commit logs (or split them into separate patches) - it makes your changes easier to review.

#2 lore raw
Quoted 13 lines

Unfortunately your patch doesn't apply against the current topic/asoc branch of Takashi's repository, I've implemented a slightly different version of it.

Quoted 8 lines

-                       name_len = strlen(w->kcontrols[i].name) + 1;
-                       if (w->id == snd_soc_dapm_mixer)
-                               name_len += 1 + strlen(w->name);
+                       if (w->id == snd_soc_dapm_mixer_named_ctl)
+                               name_len = strlen(w->kcontrols[i].name) + 1;
+                       else
+                               name_len = 2 + strlen(w->name)
+                                       + strlen(w->kcontrols[i].name);

Quoted 1 line

Here I just changed the test to != named_ctl.

ok, i will resend the patch.

Quoted 10 lines
Quoted 5 lines

-                       switch (w->id) {
-                       case snd_soc_dapm_mixer:
-                       default:

Your chanegs here appear to only flip to an if/else from a switch statement?  Please mention things like this in your commit logs (or split them into separate patches) - it makes your changes easier to review.

I think that a switch statement is used unnecessarily because this part has only to check whether w->id is named_ctl.
ok, i will send them into splited patches.
Thanks.

Signature · 1 line
- Joonyoung Shim
#3 lore raw
Quoted 13 lines

ok, i will resend the patch.

Quoted 10 lines
Quoted 5 lines

-                       switch (w->id) {
-                       case snd_soc_dapm_mixer:
-                       default:

Your chanegs here appear to only flip to an if/else from a switch statement?  Please mention things like this in your commit logs (or split them into separate patches) - it makes your changes easier to review.

Quoted 4 lines

I think that a switch statement is used unnecessarily because this part has only to check whether w->id is named_ctl.
ok, i will send them into splited patches.
Thanks.

I found your commit at for-2.6.30 branch of your repository. Thanks for your fixes.

Signature · 1 line
- Joonyoung Shim