Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus
[sfrench/cifs-2.6.git] / sound / ppc / burgundy.c
index e02263fe44dcdc88d1dbdf8e4e1f9c72731894fa..1a545ac0de04ee7634cee72db9f0e35cc7608a7f 100644 (file)
@@ -19,7 +19,6 @@
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
 
-#include <sound/driver.h>
 #include <asm/io.h>
 #include <linux/init.h>
 #include <linux/slab.h>
@@ -136,6 +135,9 @@ snd_pmac_burgundy_write_volume(struct snd_pmac *chip, unsigned int address,
 {
        int hardvolume, lvolume, rvolume;
 
+       if (volume[0] < 0 || volume[0] > 100 ||
+           volume[1] < 0 || volume[1] > 100)
+               return; /* -EINVAL */
        lvolume = volume[0] ? volume[0] + BURGUNDY_VOLUME_OFFSET : 0;
        rvolume = volume[1] ? volume[1] + BURGUNDY_VOLUME_OFFSET : 0;
 
@@ -301,14 +303,14 @@ static int snd_pmac_burgundy_put_volume_out(struct snd_kcontrol *kcontrol,
        struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
        unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff);
        int stereo = (kcontrol->private_value >> 24) & 1;
-       int oval, val;
+       unsigned int oval, val;
 
        oval = ~snd_pmac_burgundy_rcb(chip, addr) & 0xff;
-       val = ucontrol->value.integer.value[0];
+       val = ucontrol->value.integer.value[0] & 15;
        if (stereo)
-               val |= ucontrol->value.integer.value[1] << 4;
+               val |= (ucontrol->value.integer.value[1] & 15) << 4;
        else
-               val |= ucontrol->value.integer.value[0] << 4;
+               val |= val << 4;
        val = ~val & 0xff;
        snd_pmac_burgundy_wcb(chip, addr, val);
        return val != oval;