diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1998-03-17 22:05:47 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 1998-03-17 22:05:47 +0000 |
commit | 27cfca1ec98e91261b1a5355d10a8996464b63af (patch) | |
tree | 8e895a53e372fa682b4c0a585b9377d67ed70d0e /drivers/sound/ics2101.c | |
parent | 6a76fb7214c477ccf6582bd79c5b4ccc4f9c41b1 (diff) |
Look Ma' what I found on my harddisk ...
o New faster syscalls for 2.1.x, too
o Upgrade to 2.1.89.
Don't try to run this. It's flaky as hell. But feel free to debug ...
Diffstat (limited to 'drivers/sound/ics2101.c')
-rw-r--r-- | drivers/sound/ics2101.c | 158 |
1 files changed, 85 insertions, 73 deletions
diff --git a/drivers/sound/ics2101.c b/drivers/sound/ics2101.c index 3c47f5a50..35b82ac2c 100644 --- a/drivers/sound/ics2101.c +++ b/drivers/sound/ics2101.c @@ -10,11 +10,14 @@ * Version 2 (June 1991). See the "COPYING" file distributed with this software * for more info. */ +/* + * Thomas Sailer : ioctl code reworked (vmalloc/vfree removed) + */ #include <linux/config.h> #include "sound_config.h" -#if defined(CONFIG_GUSHW) || defined(MODULE) +#if defined(CONFIG_GUS) || defined(MODULE) #include <linux/ultrasound.h> #include "gus_hw.h" @@ -115,79 +118,89 @@ static int set_volumes(int dev, int vol) static int ics2101_mixer_ioctl(int dev, unsigned int cmd, caddr_t arg) { - if (((cmd >> 8) & 0xff) == 'M') - { - if (_SIOC_DIR(cmd) & _SIOC_WRITE) - { - int val; - - val = *(int *) arg; - - switch (cmd & 0xff) - { - case SOUND_MIXER_RECSRC: - return gus_default_mixer_ioctl(dev, cmd, arg); - - case SOUND_MIXER_MIC: - return (*(int *) arg = set_volumes(DEV_MIC, val)); - - case SOUND_MIXER_CD: - return (*(int *) arg = set_volumes(DEV_CD, val)); - - case SOUND_MIXER_LINE: - return (*(int *) arg = set_volumes(DEV_LINE, val)); - - case SOUND_MIXER_SYNTH: - return (*(int *) arg = set_volumes(DEV_GF1, val)); - - case SOUND_MIXER_VOLUME: - return (*(int *) arg = set_volumes(DEV_VOL, val)); - - default: - return -EINVAL; + int val; + + if (((cmd >> 8) & 0xff) == 'M') { + if (_SIOC_DIR(cmd) & _SIOC_WRITE) { + + if (get_user(val, (int *)arg)) + return -EFAULT; + switch (cmd & 0xff) { + case SOUND_MIXER_RECSRC: + return gus_default_mixer_ioctl(dev, cmd, arg); + + case SOUND_MIXER_MIC: + val = set_volumes(DEV_MIC, val); + break; + + case SOUND_MIXER_CD: + val = set_volumes(DEV_CD, val); + break; + + case SOUND_MIXER_LINE: + val = set_volumes(DEV_LINE, val); + break; + + case SOUND_MIXER_SYNTH: + val = set_volumes(DEV_GF1, val); + break; + + case SOUND_MIXER_VOLUME: + val = set_volumes(DEV_VOL, val); + break; + + default: + return -EINVAL; } - } - else - { - switch (cmd & 0xff) /* - * Return parameters - */ - { - - case SOUND_MIXER_RECSRC: - return gus_default_mixer_ioctl(dev, cmd, arg); - - case SOUND_MIXER_DEVMASK: - return (*(int *) arg = MIX_DEVS); - - case SOUND_MIXER_STEREODEVS: - return (*(int *) arg = SOUND_MASK_LINE | SOUND_MASK_CD | SOUND_MASK_SYNTH | SOUND_MASK_VOLUME | SOUND_MASK_MIC); - - case SOUND_MIXER_RECMASK: - return (*(int *) arg = SOUND_MASK_MIC | SOUND_MASK_LINE); - - case SOUND_MIXER_CAPS: - return (*(int *) arg = 0); - break; - - case SOUND_MIXER_MIC: - return (*(int *) arg = volumes[DEV_MIC]); - - case SOUND_MIXER_LINE: - return (*(int *) arg = volumes[DEV_LINE]); - - case SOUND_MIXER_CD: - return (*(int *) arg = volumes[DEV_CD]); - - case SOUND_MIXER_VOLUME: - return (*(int *) arg = volumes[DEV_VOL]); - - case SOUND_MIXER_SYNTH: - return (*(int *) arg = volumes[DEV_GF1]); - - default: - return -EINVAL; + return put_user(val, (int *)arg); + } else { + switch (cmd & 0xff) { + /* + * Return parameters + */ + case SOUND_MIXER_RECSRC: + return gus_default_mixer_ioctl(dev, cmd, arg); + + case SOUND_MIXER_DEVMASK: + val = MIX_DEVS; + break; + + case SOUND_MIXER_STEREODEVS: + val = SOUND_MASK_LINE | SOUND_MASK_CD | SOUND_MASK_SYNTH | SOUND_MASK_VOLUME | SOUND_MASK_MIC; + break; + + case SOUND_MIXER_RECMASK: + val = SOUND_MASK_MIC | SOUND_MASK_LINE; + break; + + case SOUND_MIXER_CAPS: + val = 0; + break; + + case SOUND_MIXER_MIC: + val = volumes[DEV_MIC]; + break; + + case SOUND_MIXER_LINE: + val = volumes[DEV_LINE]; + break; + + case SOUND_MIXER_CD: + val = volumes[DEV_CD]; + break; + + case SOUND_MIXER_VOLUME: + val = volumes[DEV_VOL]; + break; + + case SOUND_MIXER_SYNTH: + val = volumes[DEV_GF1]; + break; + + default: + return -EINVAL; } + return put_user(val, (int *)arg); } } return -EINVAL; @@ -208,7 +221,6 @@ ics2101_mixer_init(void) if ((n = sound_alloc_mixerdev()) != -1) { - n = num_mixers; mixer_devs[n] = &ics2101_mixer_operations; /* |