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

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

diff -u --recursive --new-file v2.1.76/linux/drivers/sound/sound_timer.c linux/drivers/sound/sound_timer.c
@@ -1,5 +1,3 @@
-
-
 /*
  * sound/sound_timer.c
  */
@@ -10,6 +8,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>
 
 
@@ -187,86 +188,72 @@
 	return curr_ticks;
 }
 
-static int
-timer_ioctl(int dev,
-	    unsigned int cmd, caddr_t arg)
+static int timer_ioctl(int dev, unsigned int cmd, caddr_t arg)
 {
-	int             val;
-
-	switch (cmd)
-	  {
-	  case SNDCTL_TMR_SOURCE:
-		  return (*(int *) arg = TMR_INTERNAL);
-		  break;
+	int val;
 
-	  case SNDCTL_TMR_START:
-		  tmr_reset();
-		  tmr_running = 1;
-		  return 0;
-		  break;
-
-	  case SNDCTL_TMR_STOP:
-		  tmr_running = 0;
-		  return 0;
-		  break;
-
-	  case SNDCTL_TMR_CONTINUE:
-		  tmr_running = 1;
-		  return 0;
-		  break;
-
-	  case SNDCTL_TMR_TIMEBASE:
-		  val = *(int *) arg;
-
-		  if (val)
-		    {
-			    if (val < 1)
-				    val = 1;
-			    if (val > 1000)
-				    val = 1000;
-			    curr_timebase = val;
-		    }
-		  return (*(int *) arg = curr_timebase);
-		  break;
-
-	  case SNDCTL_TMR_TEMPO:
-		  val = *(int *) arg;
-
-		  if (val)
-		    {
-			    if (val < 8)
-				    val = 8;
-			    if (val > 250)
-				    val = 250;
-			    tmr_offs = tmr_ctr;
-			    ticks_offs += tmr2ticks(tmr_ctr);
-			    tmr_ctr = 0;
-			    curr_tempo = val;
-			    reprogram_timer();
-		    }
-		  return (*(int *) arg = curr_tempo);
-		  break;
-
-	  case SNDCTL_SEQ_CTRLRATE:
-		  val = *(int *) arg;
-
-		  if (val != 0)	/* Can't change */
-			  return -EINVAL;
-
-		  return (*(int *) arg = ((curr_tempo * curr_timebase) + 30) / 60);
-		  break;
-
-	  case SNDCTL_SEQ_GETTIME:
-		  return (*(int *) arg = curr_ticks);
-		  break;
-
-	  case SNDCTL_TMR_METRONOME:
-		  /* NOP */
-		  break;
+	switch (cmd) {
+	case SNDCTL_TMR_SOURCE:
+		return __put_user(TMR_INTERNAL, (int *)arg);
+
+	case SNDCTL_TMR_START:
+		tmr_reset();
+		tmr_running = 1;
+		return 0;
+		
+	case SNDCTL_TMR_STOP:
+		tmr_running = 0;
+		return 0;
 
-	  default:;
-	  }
+	case SNDCTL_TMR_CONTINUE:
+		tmr_running = 1;
+		return 0;
 
+	case SNDCTL_TMR_TIMEBASE:
+		if (__get_user(val, (int *)arg))
+			return -EFAULT;
+		if (val) {
+			if (val < 1)
+				val = 1;
+			if (val > 1000)
+				val = 1000;
+			curr_timebase = val;
+		}
+		return __put_user(curr_timebase, (int *)arg);
+
+	case SNDCTL_TMR_TEMPO:
+		if (__get_user(val, (int *)arg))
+			return -EFAULT;
+		if (val) {
+			if (val < 8)
+				val = 8;
+			if (val > 250)
+				val = 250;
+			tmr_offs = tmr_ctr;
+			ticks_offs += tmr2ticks(tmr_ctr);
+			tmr_ctr = 0;
+			curr_tempo = val;
+			reprogram_timer();
+		}
+		return __put_user(curr_tempo, (int *)arg);
+
+	case SNDCTL_SEQ_CTRLRATE:
+		if (__get_user(val, (int *)arg))
+			return -EFAULT;
+		if (val != 0)	/* Can't change */
+			return -EINVAL;
+		val = ((curr_tempo * curr_timebase) + 30) / 60;
+		return __put_user(val, (int *)arg);
+		
+	case SNDCTL_SEQ_GETTIME:
+		return __put_user(curr_ticks, (int *)arg);
+		
+	case SNDCTL_TMR_METRONOME:
+		/* NOP */
+		break;
+		
+	default:;
+	}
 	return -EINVAL;
 }
 

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