aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2020-04-13 16:22:15 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2020-04-13 16:22:15 +0000
commita308210e1f9d32547d0321edcbad25837b172eca (patch)
treeed084691b1790fa46a50c78ea78aec7ddac51abd
parent7d70098a7c78be9bff255912b87f79a37dfc23e8 (diff)
downloadsrc-a308210e1f9d32547d0321edcbad25837b172eca.tar.gz
src-a308210e1f9d32547d0321edcbad25837b172eca.zip
MFC r359321:
Factor out USB audio mixer value range check. Sponsored by: Mellanox Technologies
Notes
Notes: svn path=/stable/10/; revision=359872
-rw-r--r--sys/dev/sound/usb/uaudio.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c
index 90bfec36897c..c81b18ce33cc 100644
--- a/sys/dev/sound/usb/uaudio.c
+++ b/sys/dev/sound/usb/uaudio.c
@@ -5380,25 +5380,19 @@ uaudio_mixer_bsd2value(struct uaudio_mixer_node *mc, int val)
{
if (mc->type == MIX_ON_OFF) {
val = (val != 0);
- } else if (mc->type == MIX_SELECTOR) {
- if ((val < mc->minval) ||
- (val > mc->maxval)) {
- val = mc->minval;
- }
- } else {
+ } else if (mc->type != MIX_SELECTOR) {
/* compute actual volume */
val = (val * mc->mul) / 100;
/* add lower offset */
val = val + mc->minval;
-
- /* make sure we don't write a value out of range */
- if (val > mc->maxval)
- val = mc->maxval;
- else if (val < mc->minval)
- val = mc->minval;
}
+ /* make sure we don't write a value out of range */
+ if (val > mc->maxval)
+ val = mc->maxval;
+ else if (val < mc->minval)
+ val = mc->minval;
DPRINTFN(6, "type=0x%03x val=%d min=%d max=%d val=%d\n",
mc->type, val, mc->minval, mc->maxval, val);