kern/122182: [PATCH] style(9) changes to src/sys/dev/speaker/spkr.[c, h]

Niclas Zeising niclas.zeising at gmail.com
Fri Mar 28 01:40:01 PDT 2008


>Number:         122182
>Category:       kern
>Synopsis:       [PATCH] style(9) changes to src/sys/dev/speaker/spkr.[c,h]
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar 28 08:40:00 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Niclas Zeising
>Release:        8.0-CURRENT
>Organization:
>Environment:
N/A
>Description:
Some style(9) updates to src/sys/dev/speaker/spkr.[c,h] to make it more in line with our style. That will probably make it a good starting point for aspiring kernel hackers. There is still some things left to do, such as removing register keywords and switch to ansi C function declarations, but that requres more testing. The changes have been verified not to change anything by using md5 on the speaker.kld and speaker.ko before and after the changes.

Regards!
Niclas Zeising
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

Index: src/sys/dev/speaker/speaker.h
===================================================================
RCS file: /home/ncvs/src/sys/dev/speaker/speaker.h,v
retrieving revision 1.8
diff -u -d -r1.8 speaker.h
--- src/sys/dev/speaker/speaker.h	11 Nov 2005 09:57:30 -0000	1.8
+++ src/sys/dev/speaker/speaker.h	28 Mar 2008 08:23:25 -0000
@@ -12,13 +12,13 @@
 
 #include <sys/ioccom.h>
 
-#define SPKRTONE        _IOW('S', 1, tone_t)    /* emit tone */
-#define SPKRTUNE        _IO('S', 2)             /* emit tone sequence*/
+#define SPKRTONE _IOW('S', 1, tone_t) /* emit tone */
+#define SPKRTUNE _IO('S', 2) /* emit tone sequence*/
 
 typedef struct
 {
-    int	frequency;	/* in hertz */
-    int duration;	/* in 1/100ths of a second */
+	int frequency; /* in hertz */
+	int duration; /* in 1/100ths of a second */
 } tone_t;
 
 /*
Index: src/sys/dev/speaker/spkr.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/speaker/spkr.c,v
retrieving revision 1.75
diff -u -d -r1.75 spkr.c
--- src/sys/dev/speaker/spkr.c	26 Mar 2008 21:33:41 -0000	1.75
+++ src/sys/dev/speaker/spkr.c	28 Mar 2008 08:23:25 -0000
@@ -20,19 +20,19 @@
 #include <machine/clock.h>
 #include <dev/speaker/speaker.h>
 
-static	d_open_t	spkropen;
-static	d_close_t	spkrclose;
-static	d_write_t	spkrwrite;
-static	d_ioctl_t	spkrioctl;
+static d_open_t spkropen;
+static d_close_t spkrclose;
+static d_write_t spkrwrite;
+static d_ioctl_t spkrioctl;
 
 static struct cdevsw spkr_cdevsw = {
-	.d_version =	D_VERSION,
-	.d_flags =	D_NEEDGIANT,
-	.d_open =	spkropen,
-	.d_close =	spkrclose,
-	.d_write =	spkrwrite,
-	.d_ioctl =	spkrioctl,
-	.d_name =	"spkr",
+	.d_version = D_VERSION,
+	.d_flags = D_NEEDGIANT,
+	.d_open = spkropen,
+	.d_close = spkrclose,
+	.d_write = spkrwrite,
+	.d_ioctl = spkrioctl,
+	.d_name = "spkr",
 };
 
 static MALLOC_DEFINE(M_SPKR, "spkr", "Speaker buffer");
@@ -64,59 +64,59 @@
 tone(thz, centisecs)
 	unsigned int thz, centisecs;
 {
-    int sps, timo;
+	int sps, timo;
 
-    if (thz <= 0)
-	return;
+	if (thz <= 0)
+		return;
 
 #ifdef DEBUG
-    (void) printf("tone: thz=%d centisecs=%d\n", thz, centisecs);
-#endif /* DEBUG */
+	(void) printf("tone: thz=%d centisecs=%d\n", thz, centisecs);
+#endif
 
-    /* set timer to generate clicks at given frequency in Hertz */
-    sps = splclock();
+	/* set timer to generate clicks at given frequency in Hertz */
+	sps = splclock();
 
-    if (timer_spkr_acquire()) {
-	/* enter list of waiting procs ??? */
+	if (timer_spkr_acquire()) {
+		/* enter list of waiting procs ??? */
+		splx(sps);
+		return;
+	}
 	splx(sps);
-	return;
-    }
-    splx(sps);
-    disable_intr();
-    timer_spkr_setfreq(thz);
-    enable_intr();
+	disable_intr();
+	timer_spkr_setfreq(thz);
+	enable_intr();
 
-    /*
-     * Set timeout to endtone function, then give up the timeslice.
-     * This is so other processes can execute while the tone is being
-     * emitted.
-     */
-    timo = centisecs * hz / 100;
-    if (timo > 0)
-	tsleep(&endtone, SPKRPRI | PCATCH, "spkrtn", timo);
-    sps = splclock();
-    timer_spkr_release();
-    splx(sps);
+	/*
+	 * Set timeout to endtone function, then give up the timeslice.
+	 * This is so other processes can execute while the tone is being
+	 * emitted.
+	 */
+	timo = centisecs * hz / 100;
+	if (timo > 0)
+		tsleep(&endtone, SPKRPRI | PCATCH, "spkrtn", timo);
+	sps = splclock();
+	timer_spkr_release();
+	splx(sps);
 }
 
 /* rest for given number of centisecs */
 static void
 rest(centisecs)
-	int	centisecs;
+	int centisecs;
 {
-    int timo;
+	int timo;
 
-    /*
-     * Set timeout to endrest function, then give up the timeslice.
-     * This is so other processes can execute while the rest is being
-     * waited out.
-     */
+	/*
+	 * Set timeout to endrest function, then give up the timeslice.
+	 * This is so other processes can execute while the rest is being
+	 * waited out.
+	 */
 #ifdef DEBUG
-    (void) printf("rest: %d\n", centisecs);
-#endif /* DEBUG */
-    timo = centisecs * hz / 100;
-    if (timo > 0)
-	tsleep(&endrest, SPKRPRI | PCATCH, "spkrrs", timo);
+	(void) printf("rest: %d\n", centisecs);
+#endif
+	timo = centisecs * hz / 100;
+	if (timo > 0)
+		tsleep(&endrest, SPKRPRI | PCATCH, "spkrrs", timo);
 }
 
 /**************** PLAY STRING INTERPRETER BEGINS HERE **********************
@@ -128,11 +128,11 @@
  * except possibly at physical block boundaries.
  */
 
-typedef int	bool;
-#define TRUE	1
-#define FALSE	0
+typedef int bool;
+#define TRUE 1
+#define FALSE 0
 
-#define dtoi(c)		((c) - '0')
+#define	dtoi(c) ((c) - '0')
 
 static int octave;	/* currently selected octave */
 static int whole;	/* whole-note time at current tempo, in ticks */
@@ -165,9 +165,9 @@
 /*
  * This is the American Standard A440 Equal-Tempered scale with frequencies
  * rounded to nearest integer. Thank Goddess for the good ol' CRC Handbook...
- * our octave 0 is standard octave 2.
+ * Our octave 0 is standard octave 2.
  */
-#define OCTAVE_NOTES	12	/* semitones per octave */
+#define OCTAVE_NOTES 12	/* semitones per octave */
 static int pitchtab[] =
 {
 /*        C     C#    D     D#    E     F     F#    G     G#    A     A#    B*/
@@ -183,241 +183,238 @@
 static void
 playinit()
 {
-    octave = DFLT_OCTAVE;
-    whole = (100 * SECS_PER_MIN * WHOLE_NOTE) / DFLT_TEMPO;
-    fill = NORMAL;
-    value = DFLT_VALUE;
-    octtrack = FALSE;
-    octprefix = TRUE;	/* act as though there was an initial O(n) */
+
+	octave = DFLT_OCTAVE;
+	whole = (100 * SECS_PER_MIN * WHOLE_NOTE) / DFLT_TEMPO;
+	fill = NORMAL;
+	value = DFLT_VALUE;
+	octtrack = FALSE;
+	octprefix = TRUE;	/* act as though there was an initial O(n) */
 }
 
 /* play tone of proper duration for current rhythm signature */
 static void
 playtone(pitch, value, sustain)
-	int	pitch, value, sustain;
+	int pitch, value, sustain;
 {
-    register int	sound, silence, snum = 1, sdenom = 1;
+	register int sound, silence, snum = 1, sdenom = 1;
 
-    /* this weirdness avoids floating-point arithmetic */
-    for (; sustain; sustain--)
-    {
-	/* See the BUGS section in the man page for discussion */
-	snum *= NUM_MULT;
-	sdenom *= DENOM_MULT;
-    }
+	/* this weirdness avoids floating-point arithmetic */
+	for (; sustain; sustain--) {
+		/* See the BUGS section in the man page for discussion */
+		snum *= NUM_MULT;
+		sdenom *= DENOM_MULT;
+	}
 
-    if (value == 0 || sdenom == 0)
-	return;
+	if (value == 0 || sdenom == 0)
+		return;
 
-    if (pitch == -1)
-	rest(whole * snum / (value * sdenom));
-    else
-    {
-	sound = (whole * snum) / (value * sdenom)
-		- (whole * (FILLTIME - fill)) / (value * FILLTIME);
-	silence = whole * (FILLTIME-fill) * snum / (FILLTIME * value * sdenom);
+	if (pitch == -1)
+		rest(whole * snum / (value * sdenom));
+	else {
+		sound = (whole * snum) / (value * sdenom) -
+		    (whole * (FILLTIME - fill)) / (value * FILLTIME);
+		silence = whole * (FILLTIME-fill) * snum /
+		    (FILLTIME * value * sdenom);
 
 #ifdef DEBUG
-	(void) printf("playtone: pitch %d for %d ticks, rest for %d ticks\n",
-			pitch, sound, silence);
-#endif /* DEBUG */
+		(void) printf("playtone: pitch %d for %d ticks, rest for %d ",
+		   "ticks\n", pitch, sound, silence);
+#endif
 
-	tone(pitchtab[pitch], sound);
-	if (fill != LEGATO)
-	    rest(silence);
-    }
+		tone(pitchtab[pitch], sound);
+		if (fill != LEGATO)
+			rest(silence);
+	}
 }
 
 /* interpret and play an item from a notation string */
 static void
 playstring(cp, slen)
-	char	*cp;
-	size_t	slen;
+	char *cp;
+	size_t slen;
 {
-    int		pitch, oldfill, lastpitch = OCTAVE_NOTES * DFLT_OCTAVE;
+    int pitch, oldfill, lastpitch;
+    lastpitch = OCTAVE_NOTES * DFLT_OCTAVE;
 
-#define GETNUM(cp, v)	for(v=0; isdigit(cp[1]) && slen > 0; ) \
-				{v = v * 10 + (*++cp - '0'); slen--;}
-    for (; slen--; cp++)
-    {
-	int		sustain, timeval, tempo;
-	register char	c = toupper(*cp);
+#define GETNUM(cp, v) for(v=0; isdigit(cp[1]) && slen > 0; )		       \
+	{v = v * 10 + (*++cp - '0'); slen--;}
+	for (; slen--; cp++) {
+		int sustain, timeval, tempo;
+		register char c = toupper(*cp);
 
 #ifdef DEBUG
-	(void) printf("playstring: %c (%x)\n", c, c);
-#endif /* DEBUG */
-
-	switch (c)
-	{
-	case 'A':  case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
-
-	    /* compute pitch */
-	    pitch = notetab[c - 'A'] + octave * OCTAVE_NOTES;
-
-	    /* this may be followed by an accidental sign */
-	    if (cp[1] == '#' || cp[1] == '+')
-	    {
-		++pitch;
-		++cp;
-		slen--;
-	    }
-	    else if (cp[1] == '-')
-	    {
-		--pitch;
-		++cp;
-		slen--;
-	    }
-
-	    /*
-	     * If octave-tracking mode is on, and there has been no octave-
-	     * setting prefix, find the version of the current letter note
-	     * closest to the last regardless of octave.
-	     */
-	    if (octtrack && !octprefix)
-	    {
-		if (abs(pitch-lastpitch) > abs(pitch+OCTAVE_NOTES-lastpitch))
-		{
-		    ++octave;
-		    pitch += OCTAVE_NOTES;
-		}
+		(void) printf("playstring: %c (%x)\n", c, c);
+#endif
 
-		if (abs(pitch-lastpitch) > abs((pitch-OCTAVE_NOTES)-lastpitch))
-		{
-		    --octave;
-		    pitch -= OCTAVE_NOTES;
-		}
-	    }
-	    octprefix = FALSE;
-	    lastpitch = pitch;
+		switch (c) {
+			case 'A':
+			case 'B':
+			case 'C':
+			case 'D':
+			case 'E':
+			case 'F':
+			case 'G':
+				/* compute pitch */
+				pitch = notetab[c - 'A'] + octave *
+				    OCTAVE_NOTES;
 
-	    /* ...which may in turn be followed by an override time value */
-	    GETNUM(cp, timeval);
-	    if (timeval <= 0 || timeval > MIN_VALUE)
-		timeval = value;
+				/* this may be followed by an accidental sign */
+				if (cp[1] == '#' || cp[1] == '+') {
+					++pitch;
+					++cp;
+					slen--;
+				} else if (cp[1] == '-') {
+					--pitch;
+					++cp;
+					slen--;
+				}
 
-	    /* ...and/or sustain dots */
-	    for (sustain = 0; cp[1] == '.'; cp++)
-	    {
-		slen--;
-		sustain++;
-	    }
+				/*
+				 * If octave-tracking mode is on, and there has
+				 * been no octave-setting prefix, find the
+				 * version of the current letter note closest
+				 * to the last regardless of octave.
+				 *
+				 */
+				if (octtrack && !octprefix) {
+					if (abs(pitch - lastpitch) >
+					    abs(pitch + OCTAVE_NOTES -
+					    lastpitch)) {
+						++octave;
+						pitch += OCTAVE_NOTES;
+					}
 
-	    /* ...and/or a slur mark */
-	    oldfill = fill;
-	    if (cp[1] == '_')
-	    {
-		fill = LEGATO;
-		++cp;
-		slen--;
-	    }
+					if (abs(pitch - lastpitch) >
+					    abs((pitch - OCTAVE_NOTES) -
+					    lastpitch)) {
+						--octave;
+						pitch -= OCTAVE_NOTES;
+					}
+				}
+				octprefix = FALSE;
+				lastpitch = pitch;
+				/* 
+				 * ...which may in turn be followed by an
+				 * override time value
+				 */
+				GETNUM(cp, timeval);
+				if (timeval <= 0 || timeval > MIN_VALUE)
+					timeval = value;
 
-	    /* time to emit the actual tone */
-	    playtone(pitch, timeval, sustain);
+				/* ...and/or sustain dots */
+				for (sustain = 0; cp[1] == '.'; cp++) {
+					slen--;
+					sustain++;
+				}
 
-	    fill = oldfill;
-	    break;
+				/* ...and/or a slur mark */
+				oldfill = fill;
+				if (cp[1] == '_') {
+					fill = LEGATO;
+					++cp;
+					slen--;
+				}
+				
+				/* time to emit the actual tone */
+				playtone(pitch, timeval, sustain);
 
-	case 'O':
-	    if (cp[1] == 'N' || cp[1] == 'n')
-	    {
-		octprefix = octtrack = FALSE;
-		++cp;
-		slen--;
-	    }
-	    else if (cp[1] == 'L' || cp[1] == 'l')
-	    {
-		octtrack = TRUE;
-		++cp;
-		slen--;
-	    }
-	    else
-	    {
-		GETNUM(cp, octave);
-		if (octave >= sizeof(pitchtab) / sizeof(pitchtab[0]) / OCTAVE_NOTES)
-		    octave = DFLT_OCTAVE;
-		octprefix = TRUE;
-	    }
-	    break;
+				fill = oldfill;
+				break;
+			case 'O':
+				if (cp[1] == 'N' || cp[1] == 'n') {
+					octprefix = octtrack = FALSE;
+					++cp;
+					slen--;
+				} else if (cp[1] == 'L' || cp[1] == 'l') {
+					octtrack = TRUE;
+					++cp;
+					slen--;
+				} else {
+					GETNUM(cp, octave);
+					if (octave >= sizeof(pitchtab) /
+					    sizeof(pitchtab[0]) / OCTAVE_NOTES)
+						octave = DFLT_OCTAVE;
+					octprefix = TRUE;
+				}
+				break;
 
-	case '>':
-	    if (octave < sizeof(pitchtab) / sizeof(pitchtab[0]) / OCTAVE_NOTES - 1)
-		octave++;
-	    octprefix = TRUE;
-	    break;
+			case '>':
+				if (octave < sizeof(pitchtab) /
+				    sizeof(pitchtab[0]) / OCTAVE_NOTES - 1)
+					octave++;
+				octprefix = TRUE;
+				break;
 
-	case '<':
-	    if (octave > 0)
-		octave--;
-	    octprefix = TRUE;
-	    break;
+			case '<':
+				if (octave > 0)
+					octave--;
+				octprefix = TRUE;
+				break;
 
-	case 'N':
-	    GETNUM(cp, pitch);
-	    for (sustain = 0; cp[1] == '.'; cp++)
-	    {
-		slen--;
-		sustain++;
-	    }
-	    oldfill = fill;
-	    if (cp[1] == '_')
-	    {
-		fill = LEGATO;
-		++cp;
-		slen--;
-	    }
-	    playtone(pitch - 1, value, sustain);
-	    fill = oldfill;
-	    break;
+			case 'N':
+				GETNUM(cp, pitch);
+				for (sustain = 0; cp[1] == '.'; cp++) {
+					slen--;
+					sustain++;
+				}
+				oldfill = fill;
+				if (cp[1] == '_') {
+					fill = LEGATO;
+					++cp;
+					slen--;
+				}
+				playtone(pitch - 1, value, sustain);
+				fill = oldfill;
+				break;
 
-	case 'L':
-	    GETNUM(cp, value);
-	    if (value <= 0 || value > MIN_VALUE)
-		value = DFLT_VALUE;
-	    break;
+			case 'L':
+				GETNUM(cp, value);
+				if (value <= 0 || value > MIN_VALUE)
+					value = DFLT_VALUE;
+				break;
 
-	case 'P':
-	case '~':
-	    /* this may be followed by an override time value */
-	    GETNUM(cp, timeval);
-	    if (timeval <= 0 || timeval > MIN_VALUE)
-		timeval = value;
-	    for (sustain = 0; cp[1] == '.'; cp++)
-	    {
-		slen--;
-		sustain++;
-	    }
-	    playtone(-1, timeval, sustain);
-	    break;
+			case 'P':
+			case '~':
+				/* 
+				 * This may be followed by an override time
+				 * value.
+				 */
+				GETNUM(cp, timeval);
+				if (timeval <= 0 || timeval > MIN_VALUE)
+					timeval = value;
+				for (sustain = 0; cp[1] == '.'; cp++) {
+					slen--;
+					sustain++;
+				}
+				playtone(-1, timeval, sustain);
+				break;
 
-	case 'T':
-	    GETNUM(cp, tempo);
-	    if (tempo < MIN_TEMPO || tempo > MAX_TEMPO)
-		tempo = DFLT_TEMPO;
-	    whole = (100 * SECS_PER_MIN * WHOLE_NOTE) / tempo;
-	    break;
+			case 'T':
+				GETNUM(cp, tempo);
+				if (tempo < MIN_TEMPO || tempo > MAX_TEMPO)
+					tempo = DFLT_TEMPO;
+				whole = (100 * SECS_PER_MIN * WHOLE_NOTE) /
+				    tempo;
+				break;
 
-	case 'M':
-	    if (cp[1] == 'N' || cp[1] == 'n')
-	    {
-		fill = NORMAL;
-		++cp;
-		slen--;
-	    }
-	    else if (cp[1] == 'L' || cp[1] == 'l')
-	    {
-		fill = LEGATO;
-		++cp;
-		slen--;
-	    }
-	    else if (cp[1] == 'S' || cp[1] == 's')
-	    {
-		fill = STACCATO;
-		++cp;
-		slen--;
-	    }
-	    break;
+			case 'M':
+				if (cp[1] == 'N' || cp[1] == 'n') {
+					fill = NORMAL;
+					++cp;
+					slen--;
+				} else if (cp[1] == 'L' || cp[1] == 'l') {
+					fill = LEGATO;
+					++cp;
+					slen--;
+				} else if (cp[1] == 'S' || cp[1] == 's') {
+					fill = STACCATO;
+					++cp;
+					slen--;
+				}
+				break;
+		}
 	}
-    }
 }
 
 /******************* UNIX DRIVER HOOKS BEGIN HERE **************************
@@ -432,130 +429,121 @@
 static int
 spkropen(dev, flags, fmt, td)
 	struct cdev *dev;
-	int		flags;
-	int		fmt;
-	struct thread	*td;
+	int flags, fmt;
+	struct thread *td;
 {
 #ifdef DEBUG
-    (void) printf("spkropen: entering with dev = %s\n", devtoname(dev));
-#endif /* DEBUG */
+	(void) printf("spkropen: entering with dev = %s\n", devtoname(dev));
+#endif
 
-    if (minor(dev) != 0)
-	return(ENXIO);
-    else if (spkr_active)
-	return(EBUSY);
-    else
-    {
+	if (minor(dev) != 0)
+		return(ENXIO);
+	else if (spkr_active)
+		return(EBUSY);
+	else {
 #ifdef DEBUG
-	(void) printf("spkropen: about to perform play initialization\n");
-#endif /* DEBUG */
-	playinit();
-	spkr_inbuf = malloc(DEV_BSIZE, M_SPKR, M_WAITOK);
-	spkr_active = TRUE;
-	return(0);
-    }
+		(void) printf("spkropen: about to perform play initialization\n");
+#endif
+		playinit();
+		spkr_inbuf = malloc(DEV_BSIZE, M_SPKR, M_WAITOK);
+		spkr_active = TRUE;
+		return(0);
+	}
 }
 
 static int
 spkrwrite(dev, uio, ioflag)
 	struct cdev *dev;
-	struct uio	*uio;
-	int		ioflag;
+	struct uio *uio;
+	int ioflag;
 {
 #ifdef DEBUG
-    printf("spkrwrite: entering with dev = %s, count = %d\n",
-		devtoname(dev), uio->uio_resid);
-#endif /* DEBUG */
+	printf("spkrwrite: entering with dev = %s, count = %d\n",
+	    devtoname(dev), uio->uio_resid);
+#endif
 
-    if (minor(dev) != 0)
-	return(ENXIO);
-    else if (uio->uio_resid > (DEV_BSIZE - 1))     /* prevent system crashes */
-	return(E2BIG);
-    else
-    {
-	unsigned n;
-	char *cp;
-	int error;
+	if (minor(dev) != 0)
+		return(ENXIO);
+	else if (uio->uio_resid > (DEV_BSIZE - 1)) /* prevent system crashes */
+		return(E2BIG);
+	else {
+		unsigned n;
+		char *cp;
+		int error;
 
-	n = uio->uio_resid;
-	cp = spkr_inbuf;
-	error = uiomove(cp, n, uio);
-	if (!error) {
-		cp[n] = '\0';
-		playstring(cp, n);
+		n = uio->uio_resid;
+		cp = spkr_inbuf;
+		error = uiomove(cp, n, uio);
+		if (!error) {
+			cp[n] = '\0';
+			playstring(cp, n);
+		}
+		return(error);
 	}
-	return(error);
-    }
 }
 
 static int
 spkrclose(dev, flags, fmt, td)
 	struct cdev *dev;
-	int		flags;
-	int		fmt;
-	struct thread	*td;
+	int flags, fmt;
+	struct thread *td;
 {
 #ifdef DEBUG
-    (void) printf("spkrclose: entering with dev = %s\n", devtoname(dev));
-#endif /* DEBUG */
+	(void) printf("spkrclose: entering with dev = %s\n", devtoname(dev));
+#endif
 
-    if (minor(dev) != 0)
-	return(ENXIO);
-    else
-    {
-	wakeup(&endtone);
-	wakeup(&endrest);
-	free(spkr_inbuf, M_SPKR);
-	spkr_active = FALSE;
-	return(0);
-    }
+	if (minor(dev) != 0)
+		return(ENXIO);
+	else {
+		wakeup(&endtone);
+		wakeup(&endrest);
+		free(spkr_inbuf, M_SPKR);
+		spkr_active = FALSE;
+		return(0);
+	}
 }
 
 static int
 spkrioctl(dev, cmd, cmdarg, flags, td)
 	struct cdev *dev;
-	unsigned long	cmd;
-	caddr_t		cmdarg;
-	int		flags;
-	struct thread	*td;
+	unsigned long cmd;
+	caddr_t cmdarg;
+	int flags;
+	struct thread *td;
 {
 #ifdef DEBUG
-    (void) printf("spkrioctl: entering with dev = %s, cmd = %lx\n",
-    	devtoname(dev), cmd);
-#endif /* DEBUG */
-
-    if (minor(dev) != 0)
-	return(ENXIO);
-    else if (cmd == SPKRTONE)
-    {
-	tone_t	*tp = (tone_t *)cmdarg;
+	(void) printf("spkrioctl: entering with dev = %s, cmd = %lx\n",
+	    devtoname(dev), cmd);
+#endif
 
-	if (tp->frequency == 0)
-	    rest(tp->duration);
-	else
-	    tone(tp->frequency, tp->duration);
-	return 0;
-    }
-    else if (cmd == SPKRTUNE)
-    {
-	tone_t  *tp = (tone_t *)(*(caddr_t *)cmdarg);
-	tone_t ttp;
-	int error;
+	if (minor(dev) != 0)
+		return(ENXIO);
+	else if (cmd == SPKRTONE) {
+		tone_t *tp = (tone_t *)cmdarg;
 
-	for (; ; tp++) {
-	    error = copyin(tp, &ttp, sizeof(tone_t));
-	    if (error)
-		    return(error);
-	    if (ttp.duration == 0)
-		    break;
-	    if (ttp.frequency == 0)
-		 rest(ttp.duration);
-	    else
-		 tone(ttp.frequency, ttp.duration);
+		if (tp->frequency == 0)
+			rest(tp->duration);
+		else
+			tone(tp->frequency, tp->duration);
+		return 0;
+	} else if (cmd == SPKRTUNE) {
+		tone_t *tp = (tone_t *)(*(caddr_t *)cmdarg);
+		tone_t ttp;
+		int error;
+		for (; ; tp++) {
+			error = copyin(tp, &ttp, sizeof(tone_t));
+			if (error)
+				return(error);
+			if (ttp.duration == 0)
+				break;
+			if (ttp.frequency == 0)
+				rest(ttp.duration);
+			else
+				tone(ttp.frequency, ttp.duration);
+		}
+		return(0);
 	}
-	return(0);
-    }
-    return(EINVAL);
+	return(EINVAL);
 }
 
 static struct cdev *speaker_dev;


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list