diff options
author | Takashi Iwai <tiwai@suse.de> | 2007-11-15 09:58:13 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-01-31 11:29:24 -0500 |
commit | 4e98d6a7ce934b19bffb309f2522b22384355fef (patch) | |
tree | 8613aee414a855314663de2575f2bee284c8430c /sound/pci/rme96.c | |
parent | ab2dac2bdcf562dd616bd1fadddf5078ae7c3d83 (diff) |
[ALSA] pci - check value range in ctl callbacks
Check the value ranges in ctl put callbacks properly in the rest of
PCI drivers.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/rme96.c')
-rw-r--r-- | sound/pci/rme96.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index 0b3c532c4014..aff05bd15b77 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c | |||
@@ -2195,22 +2195,25 @@ snd_rme96_dac_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu | |||
2195 | { | 2195 | { |
2196 | struct rme96 *rme96 = snd_kcontrol_chip(kcontrol); | 2196 | struct rme96 *rme96 = snd_kcontrol_chip(kcontrol); |
2197 | int change = 0; | 2197 | int change = 0; |
2198 | unsigned int vol, maxvol; | ||
2198 | 2199 | ||
2199 | if (!RME96_HAS_ANALOG_OUT(rme96)) { | 2200 | |
2201 | if (!RME96_HAS_ANALOG_OUT(rme96)) | ||
2200 | return -EINVAL; | 2202 | return -EINVAL; |
2201 | } | 2203 | maxvol = RME96_185X_MAX_OUT(rme96); |
2202 | spin_lock_irq(&rme96->lock); | 2204 | spin_lock_irq(&rme96->lock); |
2203 | if (u->value.integer.value[0] != rme96->vol[0]) { | 2205 | vol = u->value.integer.value[0]; |
2204 | rme96->vol[0] = u->value.integer.value[0]; | 2206 | if (vol != rme96->vol[0] && vol <= maxvol) { |
2205 | change = 1; | 2207 | rme96->vol[0] = vol; |
2206 | } | 2208 | change = 1; |
2207 | if (u->value.integer.value[1] != rme96->vol[1]) { | 2209 | } |
2208 | rme96->vol[1] = u->value.integer.value[1]; | 2210 | vol = u->value.integer.value[1]; |
2209 | change = 1; | 2211 | if (vol != rme96->vol[1] && vol <= maxvol) { |
2210 | } | 2212 | rme96->vol[1] = vol; |
2211 | if (change) { | 2213 | change = 1; |
2212 | snd_rme96_apply_dac_volume(rme96); | ||
2213 | } | 2214 | } |
2215 | if (change) | ||
2216 | snd_rme96_apply_dac_volume(rme96); | ||
2214 | spin_unlock_irq(&rme96->lock); | 2217 | spin_unlock_irq(&rme96->lock); |
2215 | 2218 | ||
2216 | return change; | 2219 | return change; |