diff options
author | Takashi Iwai <tiwai@suse.de> | 2014-02-18 02:11:42 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-02-19 20:42:53 -0500 |
commit | 9a8d38db030f016bee45b927af02d9b46398ed46 (patch) | |
tree | 3f0e1d8e3d42778880caf5ac6f4bfef6e96dc5c0 /sound/soc/codecs/twl4030.c | |
parent | 38dbfb59d1175ef458d006556061adeaa8751b72 (diff) |
ASoC: Rename soc_enum.max field with items
The name "max" in struct soc_enum is rather confusing since it
actually takes the number of items. With "max", one might try to
assign (nitems - 1) value.
Rename the field to a more appropriate one, "items", which is also
used in struct snd_ctl_elem_info, too.
This patch also rewrites some code like "if (x > e->nitems - 1)" with
"if (x >= e->nitems)". Not only the latter improves the readability,
it also fixes a potential bug when e->items is zero.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/codecs/twl4030.c')
-rw-r--r-- | sound/soc/codecs/twl4030.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 00665ada23e2..1eb13d586309 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c | |||
@@ -975,13 +975,13 @@ static int snd_soc_put_twl4030_opmode_enum_double(struct snd_kcontrol *kcontrol, | |||
975 | return -EBUSY; | 975 | return -EBUSY; |
976 | } | 976 | } |
977 | 977 | ||
978 | if (ucontrol->value.enumerated.item[0] > e->max - 1) | 978 | if (ucontrol->value.enumerated.item[0] >= e->items) |
979 | return -EINVAL; | 979 | return -EINVAL; |
980 | 980 | ||
981 | val = ucontrol->value.enumerated.item[0] << e->shift_l; | 981 | val = ucontrol->value.enumerated.item[0] << e->shift_l; |
982 | mask = e->mask << e->shift_l; | 982 | mask = e->mask << e->shift_l; |
983 | if (e->shift_l != e->shift_r) { | 983 | if (e->shift_l != e->shift_r) { |
984 | if (ucontrol->value.enumerated.item[1] > e->max - 1) | 984 | if (ucontrol->value.enumerated.item[1] >= e->items) |
985 | return -EINVAL; | 985 | return -EINVAL; |
986 | val |= ucontrol->value.enumerated.item[1] << e->shift_r; | 986 | val |= ucontrol->value.enumerated.item[1] << e->shift_r; |
987 | mask |= e->mask << e->shift_r; | 987 | mask |= e->mask << e->shift_r; |