patch-2.1.77 linux/drivers/sound/midibuf.c

Next file: linux/drivers/sound/mpu401.c
Previous file: linux/drivers/sound/midi_synth.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.76/linux/drivers/sound/midibuf.c linux/drivers/sound/midibuf.c
@@ -10,6 +10,9 @@
  * 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>
 
 #define MIDIBUF_C
@@ -451,39 +454,33 @@
 	return c;
 }
 
-int
-MIDIbuf_ioctl(int dev, struct fileinfo *file,
-	      unsigned int cmd, caddr_t arg)
+int MIDIbuf_ioctl(int dev, struct fileinfo *file,
+		  unsigned int cmd, caddr_t arg)
 {
-	int             val;
+	int val;
 
 	dev = dev >> 4;
-
-	if (((cmd >> 8) & 0xff) == 'C')
-	  {
+	if (((cmd >> 8) & 0xff) == 'C') {
 		  if (midi_devs[dev]->coproc)	/* Coprocessor ioctl */
 			  return midi_devs[dev]->coproc->ioctl(midi_devs[dev]->coproc->devc, cmd, arg, 0);
-		  else
-			  printk("/dev/midi%d: No coprocessor for this device\n", dev);
-
+		  printk("/dev/midi%d: No coprocessor for this device\n", dev);
 		  return -ENXIO;
 	} else
-		switch (cmd)
-		  {
-
-		  case SNDCTL_MIDI_PRETIME:
-			  val = *(int *) arg;
-			  if (val < 0)
-				  val = 0;
-
-			  val = (HZ * val) / 10;
-			  parms[dev].prech_timeout = val;
-			  return (*(int *) arg = val);
-			  break;
-
-		  default:
-			  return midi_devs[dev]->ioctl(dev, cmd, arg);
-		  }
+		switch (cmd) {
+		case SNDCTL_MIDI_PRETIME:
+			if (__get_user(val, (int *)arg))
+				return -EFAULT;
+			if (val < 0)
+				val = 0;
+			val = (HZ * val) / 10;
+			parms[dev].prech_timeout = val;
+			return __put_user(val, (int *)arg);
+			
+		default:
+			if (!midi_devs[dev]->ioctl)
+				return -EINVAL;
+			return midi_devs[dev]->ioctl(dev, cmd, arg);
+		}
 }
 
 int

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov