summaryrefslogtreecommitdiff
path: root/sound/ppc/daca.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2007-11-15 18:14:12 +0300
committerJaroslav Kysela <perex@perex.cz>2008-01-31 19:29:25 +0300
commitd4079ac49a08e36d6839a9ceb26aec8c24c9ed82 (patch)
tree91ebc493375fd4e7fa84c3a6ab67a885121b1c81 /sound/ppc/daca.c
parentd05ab185b770de96399766be6bcb5769ab99bc09 (diff)
downloadlinux-d4079ac49a08e36d6839a9ceb26aec8c24c9ed82.tar.xz
[ALSA] powermac - Check value range in ctl callbacks
Check the value ranges in ctl put callbacks properly in snd-powermac driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/ppc/daca.c')
-rw-r--r--sound/ppc/daca.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/sound/ppc/daca.c b/sound/ppc/daca.c
index c5a1f0be6a4d..0c8145792d54 100644
--- a/sound/ppc/daca.c
+++ b/sound/ppc/daca.c
@@ -115,7 +115,7 @@ static int daca_put_deemphasis(struct snd_kcontrol *kcontrol,
return -ENODEV;
change = mix->deemphasis != ucontrol->value.integer.value[0];
if (change) {
- mix->deemphasis = ucontrol->value.integer.value[0];
+ mix->deemphasis = !!ucontrol->value.integer.value[0];
daca_set_volume(mix);
}
return change;
@@ -149,15 +149,20 @@ static int daca_put_volume(struct snd_kcontrol *kcontrol,
{
struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
struct pmac_daca *mix;
+ unsigned int vol[2];
int change;
if (! (mix = chip->mixer_data))
return -ENODEV;
- change = mix->left_vol != ucontrol->value.integer.value[0] ||
- mix->right_vol != ucontrol->value.integer.value[1];
+ vol[0] = ucontrol->value.integer.value[0];
+ vol[1] = ucontrol->value.integer.value[1];
+ if (vol[0] > DACA_VOL_MAX || vol[1] > DACA_VOL_MAX)
+ return -EINVAL;
+ change = mix->left_vol != vol[0] ||
+ mix->right_vol != vol[1];
if (change) {
- mix->left_vol = ucontrol->value.integer.value[0];
- mix->right_vol = ucontrol->value.integer.value[1];
+ mix->left_vol = vol[0];
+ mix->right_vol = vol[1];
daca_set_volume(mix);
}
return change;
@@ -188,7 +193,7 @@ static int daca_put_amp(struct snd_kcontrol *kcontrol,
return -ENODEV;
change = mix->amp_on != ucontrol->value.integer.value[0];
if (change) {
- mix->amp_on = ucontrol->value.integer.value[0];
+ mix->amp_on = !!ucontrol->value.integer.value[0];
i2c_smbus_write_byte_data(mix->i2c.client, DACA_REG_GCFG,
mix->amp_on ? 0x05 : 0x04);
}