Skip to content

Commit 94dfe71

Browse files
charleskeepaxbroonie
authored andcommitted
ASoC: ops: Remove some unnecessary local variables
Remove some local variables that aren't adding much in terms of clarity or space saving. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://patch.msgid.link/20250319175123.3835849-3-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 1e3cd64 commit 94dfe71

File tree

1 file changed

+17
-25
lines changed

1 file changed

+17
-25
lines changed

sound/soc/soc-ops.c

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -664,9 +664,6 @@ int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
664664
unsigned int regwshift = component->val_bytes * BITS_PER_BYTE;
665665
unsigned int regwmask = GENMASK(regwshift - 1, 0);
666666
unsigned long mask = GENMASK(mc->nbits - 1, 0);
667-
unsigned int invert = mc->invert;
668-
long min = mc->min;
669-
long max = mc->max;
670667
long val = 0;
671668
unsigned int i;
672669

@@ -676,10 +673,10 @@ int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
676673
val |= (regval & regwmask) << (regwshift * (regcount - i - 1));
677674
}
678675
val &= mask;
679-
if (min < 0 && val > max)
676+
if (mc->min < 0 && val > mc->max)
680677
val |= ~mask;
681-
if (invert)
682-
val = max - val;
678+
if (mc->invert)
679+
val = mc->max - val;
683680
ucontrol->value.integer.value[0] = val;
684681

685682
return 0;
@@ -711,16 +708,14 @@ int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
711708
unsigned int regwshift = component->val_bytes * BITS_PER_BYTE;
712709
unsigned int regwmask = GENMASK(regwshift - 1, 0);
713710
unsigned long mask = GENMASK(mc->nbits - 1, 0);
714-
unsigned int invert = mc->invert;
715-
long max = mc->max;
716711
long val = ucontrol->value.integer.value[0];
717712
int ret = 0;
718713
unsigned int i;
719714

720715
if (val < mc->min || val > mc->max)
721716
return -EINVAL;
722-
if (invert)
723-
val = max - val;
717+
if (mc->invert)
718+
val = mc->max - val;
724719
val &= mask;
725720
for (i = 0; i < regcount; i++) {
726721
unsigned int regval = (val >> (regwshift * (regcount - i - 1))) &
@@ -755,17 +750,16 @@ int snd_soc_get_strobe(struct snd_kcontrol *kcontrol,
755750
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
756751
struct soc_mixer_control *mc =
757752
(struct soc_mixer_control *)kcontrol->private_value;
758-
unsigned int reg = mc->reg;
759-
unsigned int shift = mc->shift;
760-
unsigned int mask = BIT(shift);
761753
unsigned int invert = mc->invert != 0;
754+
unsigned int mask = BIT(mc->shift);
762755
unsigned int val;
763756

764-
val = snd_soc_component_read(component, reg);
757+
val = snd_soc_component_read(component, mc->reg);
765758
val &= mask;
766759

767-
if (shift != 0 && val != 0)
768-
val = val >> shift;
760+
if (mc->shift != 0 && val != 0)
761+
val = val >> mc->shift;
762+
769763
ucontrol->value.enumerated.item[0] = val ^ invert;
770764

771765
return 0;
@@ -788,19 +782,17 @@ int snd_soc_put_strobe(struct snd_kcontrol *kcontrol,
788782
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
789783
struct soc_mixer_control *mc =
790784
(struct soc_mixer_control *)kcontrol->private_value;
791-
unsigned int reg = mc->reg;
792-
unsigned int shift = mc->shift;
793-
unsigned int mask = BIT(shift);
794-
unsigned int invert = mc->invert != 0;
795785
unsigned int strobe = ucontrol->value.enumerated.item[0] != 0;
786+
unsigned int invert = mc->invert != 0;
787+
unsigned int mask = BIT(mc->shift);
796788
unsigned int val1 = (strobe ^ invert) ? mask : 0;
797789
unsigned int val2 = (strobe ^ invert) ? 0 : mask;
798-
int err;
790+
int ret;
799791

800-
err = snd_soc_component_update_bits(component, reg, mask, val1);
801-
if (err < 0)
802-
return err;
792+
ret = snd_soc_component_update_bits(component, mc->reg, mask, val1);
793+
if (ret < 0)
794+
return ret;
803795

804-
return snd_soc_component_update_bits(component, reg, mask, val2);
796+
return snd_soc_component_update_bits(component, mc->reg, mask, val2);
805797
}
806798
EXPORT_SYMBOL_GPL(snd_soc_put_strobe);

0 commit comments

Comments
 (0)