Skip to content

Commit

Permalink
media: em28xx: calculate left volume level correctly
Browse files Browse the repository at this point in the history
The calculation of the left volume looks suspect, the value of
0x1f - ((val << 8) & 0x1f) is always 0x1f. The debug prior to the
assignment of value[1] prints the left volume setting using the
calculation 0x1f - (val >> 8) & 0x1f which looks correct to me.
Fix the left volume by using the correct expression as used in
the debug.

Detected by CoverityScan, CID#146140 ("Wrong operator used")

Fixes: 850d24a ("[media] em28xx-alsa: add mixer support for AC97 volume controls")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
  • Loading branch information
Colin Ian King authored and Mauro Carvalho Chehab committed Aug 26, 2017
1 parent bd9f8f7 commit 801e365
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/media/usb/em28xx/em28xx-audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ static int em28xx_vol_get(struct snd_kcontrol *kcontrol,
val, (int)kcontrol->private_value);

value->value.integer.value[0] = 0x1f - (val & 0x1f);
value->value.integer.value[1] = 0x1f - ((val << 8) & 0x1f);
value->value.integer.value[1] = 0x1f - ((val >> 8) & 0x1f);

return 0;
}
Expand Down

0 comments on commit 801e365

Please sign in to comment.