diff options
author | Takashi Iwai <tiwai@suse.de> | 2007-11-15 10:14:12 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-01-31 11:29:25 -0500 |
commit | d4079ac49a08e36d6839a9ceb26aec8c24c9ed82 (patch) | |
tree | 91ebc493375fd4e7fa84c3a6ab67a885121b1c81 /sound/ppc/daca.c | |
parent | d05ab185b770de96399766be6bcb5769ab99bc09 (diff) |
[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.c | 17 |
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, | |||
115 | return -ENODEV; | 115 | return -ENODEV; |
116 | change = mix->deemphasis != ucontrol->value.integer.value[0]; | 116 | change = mix->deemphasis != ucontrol->value.integer.value[0]; |
117 | if (change) { | 117 | if (change) { |
118 | mix->deemphasis = ucontrol->value.integer.value[0]; | 118 | mix->deemphasis = !!ucontrol->value.integer.value[0]; |
119 | daca_set_volume(mix); | 119 | daca_set_volume(mix); |
120 | } | 120 | } |
121 | return change; | 121 | return change; |
@@ -149,15 +149,20 @@ static int daca_put_volume(struct snd_kcontrol *kcontrol, | |||
149 | { | 149 | { |
150 | struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); | 150 | struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); |
151 | struct pmac_daca *mix; | 151 | struct pmac_daca *mix; |
152 | unsigned int vol[2]; | ||
152 | int change; | 153 | int change; |
153 | 154 | ||
154 | if (! (mix = chip->mixer_data)) | 155 | if (! (mix = chip->mixer_data)) |
155 | return -ENODEV; | 156 | return -ENODEV; |
156 | change = mix->left_vol != ucontrol->value.integer.value[0] || | 157 | vol[0] = ucontrol->value.integer.value[0]; |
157 | mix->right_vol != ucontrol->value.integer.value[1]; | 158 | vol[1] = ucontrol->value.integer.value[1]; |
159 | if (vol[0] > DACA_VOL_MAX || vol[1] > DACA_VOL_MAX) | ||
160 | return -EINVAL; | ||
161 | change = mix->left_vol != vol[0] || | ||
162 | mix->right_vol != vol[1]; | ||
158 | if (change) { | 163 | if (change) { |
159 | mix->left_vol = ucontrol->value.integer.value[0]; | 164 | mix->left_vol = vol[0]; |
160 | mix->right_vol = ucontrol->value.integer.value[1]; | 165 | mix->right_vol = vol[1]; |
161 | daca_set_volume(mix); | 166 | daca_set_volume(mix); |
162 | } | 167 | } |
163 | return change; | 168 | return change; |
@@ -188,7 +193,7 @@ static int daca_put_amp(struct snd_kcontrol *kcontrol, | |||
188 | return -ENODEV; | 193 | return -ENODEV; |
189 | change = mix->amp_on != ucontrol->value.integer.value[0]; | 194 | change = mix->amp_on != ucontrol->value.integer.value[0]; |
190 | if (change) { | 195 | if (change) { |
191 | mix->amp_on = ucontrol->value.integer.value[0]; | 196 | mix->amp_on = !!ucontrol->value.integer.value[0]; |
192 | i2c_smbus_write_byte_data(mix->i2c.client, DACA_REG_GCFG, | 197 | i2c_smbus_write_byte_data(mix->i2c.client, DACA_REG_GCFG, |
193 | mix->amp_on ? 0x05 : 0x04); | 198 | mix->amp_on ? 0x05 : 0x04); |
194 | } | 199 | } |