svn commit: r187683 - head/sys/dev/speaker

Ed Schouten ed at FreeBSD.org
Sun Jan 25 01:21:00 PST 2009


Author: ed
Date: Sun Jan 25 09:20:59 2009
New Revision: 187683
URL: http://svn.freebsd.org/changeset/base/187683

Log:
  Remove unneeded checks of device unit number from speaker(4).
  
  Calls on the cdev can only be made on existing devices. This means we
  don't have to check the value of dev2unit().

Modified:
  head/sys/dev/speaker/spkr.c

Modified: head/sys/dev/speaker/spkr.c
==============================================================================
--- head/sys/dev/speaker/spkr.c	Sun Jan 25 09:17:16 2009	(r187682)
+++ head/sys/dev/speaker/spkr.c	Sun Jan 25 09:20:59 2009	(r187683)
@@ -419,9 +419,7 @@ spkropen(dev, flags, fmt, td)
 	(void) printf("spkropen: entering with dev = %s\n", devtoname(dev));
 #endif /* DEBUG */
 
-	if (dev2unit(dev) != 0)
-		return(ENXIO);
-	else if (spkr_active)
+	if (spkr_active)
 		return(EBUSY);
 	else {
 #ifdef DEBUG
@@ -444,9 +442,8 @@ spkrwrite(dev, uio, ioflag)
 	printf("spkrwrite: entering with dev = %s, count = %d\n",
 		devtoname(dev), uio->uio_resid);
 #endif /* DEBUG */
-	if (dev2unit(dev) != 0)
-		return(ENXIO);
-	else if (uio->uio_resid > (DEV_BSIZE - 1))     /* prevent system crashes */
+
+	if (uio->uio_resid > (DEV_BSIZE - 1))     /* prevent system crashes */
 		return(E2BIG);	
 	else {
 		unsigned n;
@@ -475,15 +472,11 @@ spkrclose(dev, flags, fmt, td)
 	(void) printf("spkrclose: entering with dev = %s\n", devtoname(dev));
 #endif /* DEBUG */
 
-	if (dev2unit(dev) != 0)
-		return(ENXIO);
-	else {
-		wakeup(&endtone);
-		wakeup(&endrest);
-		free(spkr_inbuf, M_SPKR);
-		spkr_active = FALSE;
-		return(0);
-	}
+	wakeup(&endtone);
+	wakeup(&endrest);
+	free(spkr_inbuf, M_SPKR);
+	spkr_active = FALSE;
+	return(0);
 }
 
 static int
@@ -499,9 +492,7 @@ spkrioctl(dev, cmd, cmdarg, flags, td)
     		devtoname(dev), cmd);
 #endif /* DEBUG */
 
-	if (dev2unit(dev) != 0)
-		return(ENXIO);
-	else if (cmd == SPKRTONE) {
+	if (cmd == SPKRTONE) {
 		tone_t	*tp = (tone_t *)cmdarg;
 
 		if (tp->frequency == 0)


More information about the svn-src-all mailing list