Skip to contentSkip to conversation

staging: greybus: Remove redundant variable 'mask'

PATCH In review Colin Ian King 3 participants 3 messages Feb 29, 2024

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

PATCH 1/1 staging: greybus: Remove redundant variable 'mask'

The variable mask is being assigned and bit-set but it is never being used apart from this. The variable is redundant and can be removed.

Cleans up clang scan build warning:
drivers/staging/greybus/audio_topology.c:764:15: warning: variable 'mask' set but not used [-Wunused-but-set-variable]

---
 drivers/staging/greybus/audio_topology.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/staging/greybus/audio_topology.c +0 -3
index 08e6a807c132..5dc4721105d4 100644
@@ -761,7 +761,6 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol,
 {
 	int ret, wi, ctl_id;
 	unsigned int val, mux, change;
-	unsigned int mask;
 	struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
 	struct snd_soc_dapm_widget *widget = wlist->widgets[0];
 	struct gb_audio_ctl_elem_value gbvalue;
@@ -802,7 +801,6 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol,
 
 	mux = ucontrol->value.enumerated.item[0];
 	val = mux << e->shift_l;
-	mask = e->mask << e->shift_l;
 
 	if (le32_to_cpu(gbvalue.value.enumerated_item[0]) !=
 	    ucontrol->value.enumerated.item[0]) {
@@ -815,7 +813,6 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol,
 		if (ucontrol->value.enumerated.item[1] > e->items - 1)
 			return -EINVAL;
 		val |= ucontrol->value.enumerated.item[1] << e->shift_r;
-		mask |= e->mask << e->shift_r;
 		if (le32_to_cpu(gbvalue.value.enumerated_item[1]) !=
 		    ucontrol->value.enumerated.item[1]) {
 			change = 1;
Signature · 1 line
2.39.2
#1 lore raw
Quoted 9 lines · Colin Ian King

The variable mask is being assigned and bit-set but it is never being used apart from this. The variable is redundant and can be removed.

Cleans up clang scan build warning:
drivers/staging/greybus/audio_topology.c:764:15: warning: variable 'mask' set but not used [-Wunused-but-set-variable]

This is a reasonable change, but I don't know this code that well and would like to hear from Vaibhav (if possible) or someone else whether they think the mask value *should* have been used in this spot. It doesn't look like it to me, but I'd like you to get a second opinion...

-Alex

Quoted 32 lines
---
  drivers/staging/greybus/audio_topology.c | 3 ---
  1 file changed, 3 deletions(-)
drivers/staging/greybus/audio_topology.c +0 -3
index 08e6a807c132..5dc4721105d4 100644
@@ -761,7 +761,6 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol,
  {
  	int ret, wi, ctl_id;
  	unsigned int val, mux, change;
-	unsigned int mask;
  	struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
  	struct snd_soc_dapm_widget *widget = wlist->widgets[0];
  	struct gb_audio_ctl_elem_value gbvalue;
@@ -802,7 +801,6 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol,
 
  	mux = ucontrol->value.enumerated.item[0];
  	val = mux << e->shift_l;
-	mask = e->mask << e->shift_l;
 
  	if (le32_to_cpu(gbvalue.value.enumerated_item[0]) !=
  	    ucontrol->value.enumerated.item[0]) {
@@ -815,7 +813,6 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol,
  		if (ucontrol->value.enumerated.item[1] > e->items - 1)
  			return -EINVAL;
  		val |= ucontrol->value.enumerated.item[1] << e->shift_r;
-		mask |= e->mask << e->shift_r;
  		if (le32_to_cpu(gbvalue.value.enumerated_item[1]) !=
  		    ucontrol->value.enumerated.item[1]) {
  			change = 1;
maintainer Acked-by
#2 lore raw
Quoted 11 lines · Alex Elder
Quoted 9 lines · Colin Ian King

The variable mask is being assigned and bit-set but it is never being used apart from this. The variable is redundant and can be removed.

Cleans up clang scan build warning:
drivers/staging/greybus/audio_topology.c:764:15: warning: variable 'mask' set but not used [-Wunused-but-set-variable]

Thanks Colin for sharing this patch.

Quoted 7 lines

This is a reasonable change, but I don't know this code that well and would like to hear from Vaibhav (if possible) or someone else whether they think the mask value *should* have been used in this spot. It doesn't look like it to me, but I'd like you to get a second opinion...

The original intent was use the mask field while maintaining regmap entries. However, I could not push changes on "maintain regmap" during ARA days :( Anyways, for now it makes sense to drop the unused mask variable.

Quoted 25 lines

-Alex

Quoted 22 lines
---
  drivers/staging/greybus/audio_topology.c | 3 ---
  1 file changed, 3 deletions(-)
drivers/staging/greybus/audio_topology.c +0 -2
index 08e6a807c132..5dc4721105d4 100644
@@ -761,7 +761,6 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol,
  {
      int ret, wi, ctl_id;
      unsigned int val, mux, change;
-     unsigned int mask;
      struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
      struct snd_soc_dapm_widget *widget = wlist->widgets[0];
      struct gb_audio_ctl_elem_value gbvalue;
@@ -802,7 +801,6 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol,
 
      mux = ucontrol->value.enumerated.item[0];
      val = mux << e->shift_l;
-     mask = e->mask << e->shift_l;
 
Quoted 11 lines

drivers/staging/greybus/audio_topology.c static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol, · line 818

Quoted 10 lines
drivers/staging/greybus/audio_topology.c +0 -1
      if (le32_to_cpu(gbvalue.value.enumerated_item[0]) !=
          ucontrol->value.enumerated.item[0]) {
@@ -815,7 +813,6 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol,
              if (ucontrol->value.enumerated.item[1] > e->items - 1)
                      return -EINVAL;
              val |= ucontrol->value.enumerated.item[1] << e->shift_r;
-             mask |= e->mask << e->shift_r;
              if (le32_to_cpu(gbvalue.value.enumerated_item[1]) !=
                  ucontrol->value.enumerated.item[1]) {
                      change = 1;