git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git]
/
sound
/
oss
/
mpu401.c
diff --git
a/sound/oss/mpu401.c
b/sound/oss/mpu401.c
index
0059ee0
..
2796c0e
100644
(file)
--- a/
sound/oss/mpu401.c
+++ b/
sound/oss/mpu401.c
@@
-1,5
+1,5
@@
/*
/*
- * sound/mpu401.c
+ * sound/
oss/
mpu401.c
*
* The low level driver for Roland MPU-401 compatible Midi cards.
*/
*
* The low level driver for Roland MPU-401 compatible Midi cards.
*/
@@
-432,19
+432,10
@@
static void mpu401_input_loop(struct mpu_config *devc)
devc->m_busy = 0;
}
devc->m_busy = 0;
}
-
int intchk_mpu401(
void *dev_id)
+
static irqreturn_t mpuintr(int irq,
void *dev_id)
{
struct mpu_config *devc;
{
struct mpu_config *devc;
- int dev = (int) dev_id;
-
- devc = &dev_conf[dev];
- return input_avail(devc);
-}
-
-irqreturn_t mpuintr(int irq, void *dev_id, struct pt_regs *dummy)
-{
- struct mpu_config *devc;
- int dev = (int) dev_id;
+ int dev = (int)(unsigned long) dev_id;
int handled = 0;
devc = &dev_conf[dev];
int handled = 0;
devc = &dev_conf[dev];
@@
-728,7
+719,7
@@
static int mpu401_end_read(int dev)
return 0;
}
return 0;
}
-static int mpu401_ioctl(int dev, unsigned cmd,
caddr_t
arg)
+static int mpu401_ioctl(int dev, unsigned cmd,
void __user *
arg)
{
struct mpu_config *devc;
mpu_command_rec rec;
{
struct mpu_config *devc;
mpu_command_rec rec;
@@
-742,7
+733,7
@@
static int mpu401_ioctl(int dev, unsigned cmd, caddr_t arg)
printk(KERN_WARNING "mpu401: Intelligent mode not supported by the HW\n");
return -EINVAL;
}
printk(KERN_WARNING "mpu401: Intelligent mode not supported by the HW\n");
return -EINVAL;
}
- if (get_user(val, (int *)arg))
+ if (get_user(val, (int
__user
*)arg))
return -EFAULT;
set_uart_mode(dev, devc, !val);
return 0;
return -EFAULT;
set_uart_mode(dev, devc, !val);
return 0;
@@
-772,8
+763,7
@@
static int mpu401_buffer_status(int dev)
*/
}
*/
}
-static int mpu_synth_ioctl(int dev,
- unsigned int cmd, caddr_t arg)
+static int mpu_synth_ioctl(int dev, unsigned int cmd, void __user *arg)
{
int midi_dev;
struct mpu_config *devc;
{
int midi_dev;
struct mpu_config *devc;
@@
-789,8
+779,7
@@
static int mpu_synth_ioctl(int dev,
{
case SNDCTL_SYNTH_INFO:
{
case SNDCTL_SYNTH_INFO:
- if (copy_to_user((&((char *) arg)[0]),
- (char *) &mpu_synth_info[midi_dev],
+ if (copy_to_user(arg, &mpu_synth_info[midi_dev],
sizeof(struct synth_info)))
return -EFAULT;
return 0;
sizeof(struct synth_info)))
return -EFAULT;
return 0;
@@
-1028,25
+1017,19
@@
int attach_mpu401(struct address_info *hw_config, struct module *owner)
spin_unlock_irqrestore(&devc->lock,flags);
}
spin_unlock_irqrestore(&devc->lock,flags);
}
- if (!request_region(hw_config->io_base, 2, "mpu401"))
- {
- ret = -ENOMEM;
- goto out_irq;
- }
-
if (devc->version != 0)
if (mpu_cmd(m, 0xC5, 0) >= 0) /* Set timebase OK */
if (mpu_cmd(m, 0xE0, 120) >= 0) /* Set tempo OK */
devc->capabilities |= MPU_CAP_INTLG; /* Supports intelligent mode */
if (devc->version != 0)
if (mpu_cmd(m, 0xC5, 0) >= 0) /* Set timebase OK */
if (mpu_cmd(m, 0xE0, 120) >= 0) /* Set tempo OK */
devc->capabilities |= MPU_CAP_INTLG; /* Supports intelligent mode */
- mpu401_synth_operations[m] =
(struct synth_operations *)
kmalloc(sizeof(struct synth_operations), GFP_KERNEL);
+ mpu401_synth_operations[m] = kmalloc(sizeof(struct synth_operations), GFP_KERNEL);
if (mpu401_synth_operations[m] == NULL)
{
printk(KERN_ERR "mpu401: Can't allocate memory\n");
ret = -ENOMEM;
if (mpu401_synth_operations[m] == NULL)
{
printk(KERN_ERR "mpu401: Can't allocate memory\n");
ret = -ENOMEM;
- goto out_
resource
;
+ goto out_
irq
;
}
if (!(devc->capabilities & MPU_CAP_INTLG)) /* No intelligent mode */
{
}
if (!(devc->capabilities & MPU_CAP_INTLG)) /* No intelligent mode */
{
@@
-1128,13
+1111,12
@@
int attach_mpu401(struct address_info *hw_config, struct module *owner)
return 0;
return 0;
-out_resource:
- release_region(hw_config->io_base, 2);
out_irq:
free_irq(devc->irq, (void *)m);
out_mididev:
sound_unload_mididev(m);
out_err:
out_irq:
free_irq(devc->irq, (void *)m);
out_mididev:
sound_unload_mididev(m);
out_err:
+ release_region(hw_config->io_base, 2);
return ret;
}
return ret;
}
@@
-1209,16
+1191,11
@@
static void set_uart_mode(int dev, struct mpu_config *devc, int arg)
}
}
-int probe_mpu401(struct address_info *hw_config)
+int probe_mpu401(struct address_info *hw_config
, struct resource *ports
)
{
int ok = 0;
struct mpu_config tmp_devc;
{
int ok = 0;
struct mpu_config tmp_devc;
- if (check_region(hw_config->io_base, 2))
- {
- printk(KERN_ERR "mpu401: I/O port %x already in use\n\n", hw_config->io_base);
- return 0;
- }
tmp_devc.base = hw_config->io_base;
tmp_devc.irq = hw_config->irq;
tmp_devc.initialized = 0;
tmp_devc.base = hw_config->io_base;
tmp_devc.irq = hw_config->irq;
tmp_devc.initialized = 0;
@@
-1254,8
+1231,7
@@
void unload_mpu401(struct address_info *hw_config)
p=mpu401_synth_operations[n];
sound_unload_mididev(n);
sound_unload_timerdev(hw_config->slots[2]);
p=mpu401_synth_operations[n];
sound_unload_mididev(n);
sound_unload_timerdev(hw_config->slots[2]);
- if(p)
- kfree(p);
+ kfree(p);
}
}
}
}
@@
-1508,17
+1484,19
@@
static unsigned long mpu_timer_get_time(int dev)
return curr_ticks;
}
return curr_ticks;
}
-static int mpu_timer_ioctl(int dev, unsigned int command,
caddr_t
arg)
+static int mpu_timer_ioctl(int dev, unsigned int command,
void __user *
arg)
{
int midi_dev = sound_timer_devs[dev]->devlink;
{
int midi_dev = sound_timer_devs[dev]->devlink;
+ int __user *p = (int __user *)arg;
switch (command)
{
case SNDCTL_TMR_SOURCE:
{
int parm;
switch (command)
{
case SNDCTL_TMR_SOURCE:
{
int parm;
-
- parm = *(int *) arg;
+
+ if (get_user(parm, p))
+ return -EFAULT;
parm &= timer_caps;
if (parm != 0)
parm &= timer_caps;
if (parm != 0)
@@
-1530,7
+1508,9
@@
static int mpu_timer_ioctl(int dev, unsigned int command, caddr_t arg)
else if (timer_mode & TMR_MODE_SMPTE)
mpu_cmd(midi_dev, 0x3d, 0); /* Use SMPTE sync */
}
else if (timer_mode & TMR_MODE_SMPTE)
mpu_cmd(midi_dev, 0x3d, 0); /* Use SMPTE sync */
}
- return (*(int *) arg = timer_mode);
+ if (put_user(timer_mode, p))
+ return -EFAULT;
+ return timer_mode;
}
break;
}
break;
@@
-1554,11
+1534,13
@@
static int mpu_timer_ioctl(int dev, unsigned int command, caddr_t arg)
case SNDCTL_TMR_TIMEBASE:
{
int val;
case SNDCTL_TMR_TIMEBASE:
{
int val;
-
-
val = *(int *) arg
;
+ if (get_user(val, p))
+
return -EFAULT
;
if (val)
set_timebase(midi_dev, val);
if (val)
set_timebase(midi_dev, val);
- return (*(int *) arg = curr_timebase);
+ if (put_user(curr_timebase, p))
+ return -EFAULT;
+ return curr_timebase;
}
break;
}
break;
@@
-1567,7
+1549,8
@@
static int mpu_timer_ioctl(int dev, unsigned int command, caddr_t arg)
int val;
int ret;
int val;
int ret;
- val = *(int *) arg;
+ if (get_user(val, p))
+ return -EFAULT;
if (val)
{
if (val)
{
@@
-1582,26
+1565,35
@@
static int mpu_timer_ioctl(int dev, unsigned int command, caddr_t arg)
}
curr_tempo = val;
}
}
curr_tempo = val;
}
- return (*(int *) arg = curr_tempo);
+ if (put_user(curr_tempo, p))
+ return -EFAULT;
+ return curr_tempo;
}
break;
case SNDCTL_SEQ_CTRLRATE:
{
int val;
}
break;
case SNDCTL_SEQ_CTRLRATE:
{
int val;
+ if (get_user(val, p))
+ return -EFAULT;
- val = *(int *) arg;
if (val != 0) /* Can't change */
return -EINVAL;
if (val != 0) /* Can't change */
return -EINVAL;
- return (*(int *) arg = ((curr_tempo * curr_timebase) + 30) / 60);
+ val = ((curr_tempo * curr_timebase) + 30)/60;
+ if (put_user(val, p))
+ return -EFAULT;
+ return val;
}
break;
case SNDCTL_SEQ_GETTIME:
}
break;
case SNDCTL_SEQ_GETTIME:
- return (*(int *) arg = curr_ticks);
+ if (put_user(curr_ticks, p))
+ return -EFAULT;
+ return curr_ticks;
case SNDCTL_TMR_METRONOME:
case SNDCTL_TMR_METRONOME:
- metronome_mode = *(int *) arg;
+ if (get_user(metronome_mode, p))
+ return -EFAULT;
setup_metronome(midi_dev);
return 0;
setup_metronome(midi_dev);
return 0;
@@
-1760,16
+1752,14
@@
static int mpu_timer_init(int midi_dev)
EXPORT_SYMBOL(probe_mpu401);
EXPORT_SYMBOL(attach_mpu401);
EXPORT_SYMBOL(unload_mpu401);
EXPORT_SYMBOL(probe_mpu401);
EXPORT_SYMBOL(attach_mpu401);
EXPORT_SYMBOL(unload_mpu401);
-EXPORT_SYMBOL(intchk_mpu401);
-EXPORT_SYMBOL(mpuintr);
static struct address_info cfg;
static int io = -1;
static int irq = -1;
static struct address_info cfg;
static int io = -1;
static int irq = -1;
-
MODULE_PARM(irq, "i"
);
-
MODULE_PARM(io, "i"
);
+
module_param(irq, int, 0
);
+
module_param(io, int, 0
);
static int __init init_mpu401(void)
{
static int __init init_mpu401(void)
{
@@
-1777,10
+1767,16
@@
static int __init init_mpu401(void)
/* Can be loaded either for module use or to provide functions
to others */
if (io != -1 && irq != -1) {
/* Can be loaded either for module use or to provide functions
to others */
if (io != -1 && irq != -1) {
+ struct resource *ports;
cfg.irq = irq;
cfg.io_base = io;
cfg.irq = irq;
cfg.io_base = io;
- if (probe_mpu401(&cfg) == 0)
+ ports = request_region(io, 2, "mpu401");
+ if (!ports)
+ return -EBUSY;
+ if (probe_mpu401(&cfg, ports) == 0) {
+ release_region(io, 2);
return -ENODEV;
return -ENODEV;
+ }
if ((ret = attach_mpu401(&cfg, THIS_MODULE)))
return ret;
}
if ((ret = attach_mpu401(&cfg, THIS_MODULE)))
return ret;
}