diff options
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r-- | sound/soc/soc-core.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index e5b0713e6f3c..9a6daf997319 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -2413,16 +2413,14 @@ int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol, | |||
2413 | { | 2413 | { |
2414 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 2414 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
2415 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; | 2415 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
2416 | unsigned int val, bitmask; | 2416 | unsigned int val; |
2417 | 2417 | ||
2418 | for (bitmask = 1; bitmask < e->max; bitmask <<= 1) | ||
2419 | ; | ||
2420 | val = snd_soc_read(codec, e->reg); | 2418 | val = snd_soc_read(codec, e->reg); |
2421 | ucontrol->value.enumerated.item[0] | 2419 | ucontrol->value.enumerated.item[0] |
2422 | = (val >> e->shift_l) & (bitmask - 1); | 2420 | = (val >> e->shift_l) & e->mask; |
2423 | if (e->shift_l != e->shift_r) | 2421 | if (e->shift_l != e->shift_r) |
2424 | ucontrol->value.enumerated.item[1] = | 2422 | ucontrol->value.enumerated.item[1] = |
2425 | (val >> e->shift_r) & (bitmask - 1); | 2423 | (val >> e->shift_r) & e->mask; |
2426 | 2424 | ||
2427 | return 0; | 2425 | return 0; |
2428 | } | 2426 | } |
@@ -2443,19 +2441,17 @@ int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol, | |||
2443 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 2441 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
2444 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; | 2442 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
2445 | unsigned int val; | 2443 | unsigned int val; |
2446 | unsigned int mask, bitmask; | 2444 | unsigned int mask; |
2447 | 2445 | ||
2448 | for (bitmask = 1; bitmask < e->max; bitmask <<= 1) | ||
2449 | ; | ||
2450 | if (ucontrol->value.enumerated.item[0] > e->max - 1) | 2446 | if (ucontrol->value.enumerated.item[0] > e->max - 1) |
2451 | return -EINVAL; | 2447 | return -EINVAL; |
2452 | val = ucontrol->value.enumerated.item[0] << e->shift_l; | 2448 | val = ucontrol->value.enumerated.item[0] << e->shift_l; |
2453 | mask = (bitmask - 1) << e->shift_l; | 2449 | mask = e->mask << e->shift_l; |
2454 | if (e->shift_l != e->shift_r) { | 2450 | if (e->shift_l != e->shift_r) { |
2455 | if (ucontrol->value.enumerated.item[1] > e->max - 1) | 2451 | if (ucontrol->value.enumerated.item[1] > e->max - 1) |
2456 | return -EINVAL; | 2452 | return -EINVAL; |
2457 | val |= ucontrol->value.enumerated.item[1] << e->shift_r; | 2453 | val |= ucontrol->value.enumerated.item[1] << e->shift_r; |
2458 | mask |= (bitmask - 1) << e->shift_r; | 2454 | mask |= e->mask << e->shift_r; |
2459 | } | 2455 | } |
2460 | 2456 | ||
2461 | return snd_soc_update_bits_locked(codec, e->reg, mask, val); | 2457 | return snd_soc_update_bits_locked(codec, e->reg, mask, val); |