Commit 64c02a9d authored by Geoffrey D. Bennett's avatar Geoffrey D. Bennett Committed by Takashi Iwai

ALSA: usb-audio: scarlett2: Fix union usage in mixer control callbacks

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: default avatarGeoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/20210620164647.GA9226@m.b4.vuSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent c5d8e008
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment