From 3b892467786410f26dffc2c7bccd3ea445604037 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 15 Nov 2007 16:17:24 +0100 Subject: [ALSA] Check value range in ctl callbacks Check the value ranges in ctl put callbacks properly (in the rest drivers). Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela --- sound/sparc/amd7930.c | 2 +- sound/sparc/dbri.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'sound/sparc') diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index 07962a35f241..b1d431587158 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -859,7 +859,7 @@ static int snd_amd7930_put_volume(struct snd_kcontrol *kctl, struct snd_ctl_elem spin_lock_irqsave(&amd->lock, flags); if (*swval != ucontrol->value.integer.value[0]) { - *swval = ucontrol->value.integer.value[0]; + *swval = ucontrol->value.integer.value[0] & 0xff; __amd7930_update_map(amd); change = 1; } else diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index 376b98691c96..af1bf4bf9459 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -2279,9 +2279,20 @@ static int snd_cs4215_put_volume(struct snd_kcontrol *kcontrol, struct snd_dbri *dbri = snd_kcontrol_chip(kcontrol); struct dbri_streaminfo *info = &dbri->stream_info[kcontrol->private_value]; + unsigned int vol[2]; int changed = 0; - if (info->left_gain != ucontrol->value.integer.value[0]) { + vol[0] = ucontrol->value.integer.value[0]; + vol[1] = ucontrol->value.integer.value[1]; + if (kcontrol->private_value == DBRI_PLAY) { + if (vol[0] > DBRI_MAX_VOLUME || vol[1] > DBRI_MAX_VOLUME) + return -EINVAL; + } else { + if (vol[0] > DBRI_MAX_GAIN || vol[1] > DBRI_MAX_GAIN) + return -EINVAL; + } + + if (info->left_gain != info->left_gain = ucontrol->value.integer.value[0]; changed = 1; } -- cgit v1.2.2 From 4581aa36fc8273579f6b7979adc4f4e666460a8d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 20 Nov 2007 18:31:22 +0100 Subject: [ALSA] dbri - Fix broken change for value range checks The last patch for value range checks included a broken merge result. Now fixed properly. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela --- sound/sparc/dbri.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sound/sparc') diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index af1bf4bf9459..fc683174f2c7 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -2292,12 +2292,12 @@ static int snd_cs4215_put_volume(struct snd_kcontrol *kcontrol, return -EINVAL; } - if (info->left_gain != - info->left_gain = ucontrol->value.integer.value[0]; + if (info->left_gain != vol[0]) { + info->left_gain = vol[0]; changed = 1; } - if (info->right_gain != ucontrol->value.integer.value[1]) { - info->right_gain = ucontrol->value.integer.value[1]; + if (info->right_gain != vol[1]) { + info->right_gain = vol[1]; changed = 1; } if (changed) { -- cgit v1.2.2 From 9004acc70e8c49c50c4c7b652f906f1e0ed5709d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 8 Jan 2008 18:13:27 +0100 Subject: [ALSA] Remove sound/driver.h This header file exists only for some hacks to adapt alsa-driver tree. It's useless for building in the kernel. Let's move a few lines in it to sound/core.h and remove it. With this patch, sound/driver.h isn't removed but has just a single compile warning to include it. This should be really killed in future. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela --- sound/sparc/amd7930.c | 1 - sound/sparc/cs4231.c | 1 - sound/sparc/dbri.c | 1 - 3 files changed, 3 deletions(-) (limited to 'sound/sparc') diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index b1d431587158..0c63e0585b15 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -36,7 +36,6 @@ #include #include -#include #include #include #include diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index f8c7a120ccbb..1c4797be72ee 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -19,7 +19,6 @@ #include -#include #include #include #include diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index fc683174f2c7..3d00e0797b11 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -53,7 +53,6 @@ * other DBRI low-level stuff */ -#include #include #include #include -- cgit v1.2.2