From: "Geoffrey D. Bennett" <g@b4.vu>
To: alsa-devel@alsa-project.org, Takashi Iwai <tiwai@suse.de>
Cc: Hin-Tak Leung <htl10@users.sourceforge.net>,
Vladimir Sadovnikov <sadko4u@gmail.com>
Subject: [PATCH 12/14] ALSA: usb-audio: scarlett2: Fix union usage in mixer control callbacks
Date: Mon, 21 Jun 2021 02:16:47 +0930 [thread overview]
Message-ID: <20210620164647.GA9226@m.b4.vu> (raw)
Fix mixer control callbacks to use the correct members of the struct
snd_ctl_elem_value. The use of value.integer and value.enumerated were
swapped in a few places.
Update scarlett2_mux_src_enum_ctl_put() to use min() instead of
clamp() as value.enumerated.item is unsigned.
Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
---
sound/usb/mixer_scarlett_gen2.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c
index fe142b7ddb32..49c4662531a3 100644
--- a/sound/usb/mixer_scarlett_gen2.c
+++ b/sound/usb/mixer_scarlett_gen2.c
@@ -1270,7 +1270,7 @@ static int scarlett2_sw_hw_enum_ctl_put(struct snd_kcontrol *kctl,
mutex_lock(&private->data_mutex);
oval = private->vol_sw_hw_switch[index];
- val = !!ucontrol->value.integer.value[0];
+ val = !!ucontrol->value.enumerated.item[0];
if (oval == val)
goto unlock;
@@ -1356,7 +1356,7 @@ static int scarlett2_level_enum_ctl_put(struct snd_kcontrol *kctl,
mutex_lock(&private->data_mutex);
oval = private->level_switch[index];
- val = !!ucontrol->value.integer.value[0];
+ val = !!ucontrol->value.enumerated.item[0];
if (oval == val)
goto unlock;
@@ -1390,7 +1390,7 @@ static int scarlett2_pad_ctl_get(struct snd_kcontrol *kctl,
struct usb_mixer_elem_info *elem = kctl->private_data;
struct scarlett2_data *private = elem->head.mixer->private_data;
- ucontrol->value.enumerated.item[0] =
+ ucontrol->value.integer.value[0] =
private->pad_switch[elem->control];
return 0;
}
@@ -1448,7 +1448,7 @@ static int scarlett2_dim_mute_ctl_get(struct snd_kcontrol *kctl,
scarlett2_update_volumes(mixer);
mutex_unlock(&private->data_mutex);
- ucontrol->value.enumerated.item[0] = private->dim_mute[elem->control];
+ ucontrol->value.integer.value[0] = private->dim_mute[elem->control];
return 0;
}
@@ -1748,8 +1748,8 @@ static int scarlett2_mux_src_enum_ctl_put(struct snd_kcontrol *kctl,
mutex_lock(&private->data_mutex);
oval = private->mux[index];
- val = clamp(ucontrol->value.integer.value[0],
- 0L, private->num_mux_srcs - 1L);
+ val = min(ucontrol->value.enumerated.item[0],
+ private->num_mux_srcs - 1U);
if (oval == val)
goto unlock;
--
2.31.1
reply other threads:[~2021-06-20 16:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210620164647.GA9226@m.b4.vu \
--to=g@b4.vu \
--cc=alsa-devel@alsa-project.org \
--cc=htl10@users.sourceforge.net \
--cc=sadko4u@gmail.com \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox