X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Foss%2Fsequencer.c;h=6815c30e0bc1be68fd9589040b167499b5b2cde5;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=04f334edf4b9e7a1e8306f961bb4e0ab00b599b4;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/sound/oss/sequencer.c b/sound/oss/sequencer.c index 04f334edf..6815c30e0 100644 --- a/sound/oss/sequencer.c +++ b/sound/oss/sequencer.c @@ -28,7 +28,7 @@ static int pending_timer = -1; /* For timer change operation */ extern unsigned long seq_time; static int obsolete_api_used; -static spinlock_t lock=SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(lock); /* * Local counts for number of synth and MIDI devices. These are initialized @@ -82,7 +82,7 @@ static void seq_reset(void); #error Too many synthesizer devices enabled. #endif -int sequencer_read(int dev, struct file *file, char *buf, int count) +int sequencer_read(int dev, struct file *file, char __user *buf, int count) { int c = count, p = 0; int ev_len; @@ -207,7 +207,7 @@ void seq_input_event(unsigned char *event_rec, int len) seq_copy_to_input(event_rec, len); } -int sequencer_write(int dev, struct file *file, const char *buf, int count) +int sequencer_write(int dev, struct file *file, const char __user *buf, int count) { unsigned char event_rec[EV_SZ], ev_code; int p = 0, c, ev_size; @@ -709,11 +709,11 @@ static void seq_local_event(unsigned char *event_rec) static void seq_sysex_message(unsigned char *event_rec) { - int dev = event_rec[1]; + unsigned int dev = event_rec[1]; int i, l = 0; unsigned char *buf = &event_rec[2]; - if ((int) dev > max_synthdev) + if (dev > max_synthdev) return; if (!(synth_open_mask & (1 << dev))) return; @@ -1091,7 +1091,7 @@ int sequencer_open(int dev, struct file *file) return 0; } -void seq_drain_midi_queues(void) +static void seq_drain_midi_queues(void) { int i, n; @@ -1320,13 +1320,14 @@ static void seq_panic(void) */ } -int sequencer_ioctl(int dev, struct file *file, unsigned int cmd, caddr_t arg) +int sequencer_ioctl(int dev, struct file *file, unsigned int cmd, void __user *arg) { int midi_dev, orig_dev, val, err; int mode = translate_mode(file); struct synth_info inf; struct seq_event_rec event_rec; unsigned long flags; + int __user *p = arg; orig_dev = dev = dev >> 4; @@ -1346,7 +1347,7 @@ int sequencer_ioctl(int dev, struct file *file, unsigned int cmd, caddr_t arg) case SNDCTL_TMR_SELECT: if (seq_mode != SEQ_2) return -EINVAL; - if (get_user(pending_timer, (int *)arg)) + if (get_user(pending_timer, p)) return -EFAULT; if (pending_timer < 0 || pending_timer >= num_sound_timers || sound_timer_devs[pending_timer] == NULL) { @@ -1372,7 +1373,7 @@ int sequencer_ioctl(int dev, struct file *file, unsigned int cmd, caddr_t arg) return 0; case SNDCTL_SEQ_TESTMIDI: - if (__get_user(midi_dev, (int *)arg)) + if (__get_user(midi_dev, p)) return -EFAULT; if (midi_dev < 0 || midi_dev >= max_mididev || !midi_devs[midi_dev]) return -ENXIO; @@ -1409,7 +1410,7 @@ int sequencer_ioctl(int dev, struct file *file, unsigned int cmd, caddr_t arg) if (seq_mode == SEQ_2) return tmr->ioctl(tmr_no, cmd, arg); - if (get_user(val, (int *)arg)) + if (get_user(val, p)) return -EFAULT; if (val != 0) return -EINVAL; @@ -1419,7 +1420,7 @@ int sequencer_ioctl(int dev, struct file *file, unsigned int cmd, caddr_t arg) case SNDCTL_SEQ_RESETSAMPLES: case SNDCTL_SYNTH_REMOVESAMPLE: case SNDCTL_SYNTH_CONTROL: - if (get_user(dev, (int *)arg)) + if (get_user(dev, p)) return -EFAULT; if (dev < 0 || dev >= num_synths || synth_devs[dev] == NULL) return -ENXIO; @@ -1436,7 +1437,7 @@ int sequencer_ioctl(int dev, struct file *file, unsigned int cmd, caddr_t arg) break; case SNDCTL_SYNTH_MEMAVL: - if (get_user(dev, (int *)arg)) + if (get_user(dev, p)) return -EFAULT; if (dev < 0 || dev >= num_synths || synth_devs[dev] == NULL) return -ENXIO; @@ -1446,7 +1447,7 @@ int sequencer_ioctl(int dev, struct file *file, unsigned int cmd, caddr_t arg) break; case SNDCTL_FM_4OP_ENABLE: - if (get_user(dev, (int *)arg)) + if (get_user(dev, p)) return -EFAULT; if (dev < 0 || dev >= num_synths || synth_devs[dev] == NULL) return -ENXIO; @@ -1456,7 +1457,7 @@ int sequencer_ioctl(int dev, struct file *file, unsigned int cmd, caddr_t arg) return 0; case SNDCTL_SYNTH_INFO: - if (get_user(dev, (int *)(&(((struct synth_info *)arg)->device)))) + if (get_user(dev, &((struct synth_info __user *)arg)->device)) return -EFAULT; if (dev < 0 || dev >= max_synthdev) return -ENXIO; @@ -1466,7 +1467,7 @@ int sequencer_ioctl(int dev, struct file *file, unsigned int cmd, caddr_t arg) /* Like SYNTH_INFO but returns ID in the name field */ case SNDCTL_SYNTH_ID: - if (get_user(dev, (int *)(&(((struct synth_info *)arg)->device)))) + if (get_user(dev, &((struct synth_info __user *)arg)->device)) return -EFAULT; if (dev < 0 || dev >= max_synthdev) return -ENXIO; @@ -1486,7 +1487,7 @@ int sequencer_ioctl(int dev, struct file *file, unsigned int cmd, caddr_t arg) return 0; case SNDCTL_MIDI_INFO: - if (get_user(dev, (int *)(&(((struct midi_info *)arg)->device)))) + if (get_user(dev, &((struct midi_info __user *)arg)->device)) return -EFAULT; if (dev < 0 || dev >= max_mididev || !midi_devs[dev]) return -ENXIO; @@ -1494,7 +1495,7 @@ int sequencer_ioctl(int dev, struct file *file, unsigned int cmd, caddr_t arg) return copy_to_user(arg, &midi_devs[dev]->info, sizeof(struct midi_info))?-EFAULT:0; case SNDCTL_SEQ_THRESHOLD: - if (get_user(val, (int *)arg)) + if (get_user(val, p)) return -EFAULT; if (val < 1) val = 1; @@ -1504,7 +1505,7 @@ int sequencer_ioctl(int dev, struct file *file, unsigned int cmd, caddr_t arg) return 0; case SNDCTL_MIDI_PRETIME: - if (get_user(val, (int *)arg)) + if (get_user(val, p)) return -EFAULT; if (val < 0) val = 0; @@ -1523,7 +1524,7 @@ int sequencer_ioctl(int dev, struct file *file, unsigned int cmd, caddr_t arg) return -EINVAL; return synth_devs[0]->ioctl(0, cmd, arg); } - return put_user(val, (int *)arg); + return put_user(val, p); } /* No kernel lock - we're using the global irq lock here */ @@ -1670,14 +1671,7 @@ void sequencer_init(void) void sequencer_unload(void) { - if(queue) - { - vfree(queue); - queue=NULL; - } - if(iqueue) - { - vfree(iqueue); - iqueue=NULL; - } + vfree(queue); + vfree(iqueue); + queue = iqueue = NULL; }