Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 Jan 2009 09:20:59 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r187683 - head/sys/dev/speaker
Message-ID:  <200901250920.n0P9Kxco011925@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901250920.n0P9Kxco011925>