svn commit: r191054 - head/sys/dev/joy

Ed Schouten ed at FreeBSD.org
Tue Apr 14 11:23:10 UTC 2009


Author: ed
Date: Tue Apr 14 11:23:09 2009
New Revision: 191054
URL: http://svn.freebsd.org/changeset/base/191054

Log:
  Use si_drv1 to store joy(4)'s softc.
  
  There are still some calls to dev2unit() left, but I guess we should
  take care of those another time.

Modified:
  head/sys/dev/joy/joy.c

Modified: head/sys/dev/joy/joy.c
==============================================================================
--- head/sys/dev/joy/joy.c	Tue Apr 14 10:55:20 2009	(r191053)
+++ head/sys/dev/joy/joy.c	Tue Apr 14 11:23:09 2009	(r191054)
@@ -55,14 +55,10 @@ __FBSDID("$FreeBSD$");
  */
 
 #define joypart(d) (dev2unit(d)&1)
-#define UNIT(d) ((dev2unit(d)>>1)&3)
 #ifndef JOY_TIMEOUT
 #define JOY_TIMEOUT   2000 /* 2 milliseconds */
 #endif
 
-#define JOY_SOFTC(unit) (struct joy_softc *) \
-        devclass_get_softc(joy_devclass,(unit))
-
 static	d_open_t	joyopen;
 static	d_close_t	joyclose;
 static	d_read_t	joyread;
@@ -111,6 +107,7 @@ joy_attach(device_t dev)
 	joy->port = rman_get_bushandle(joy->res);
 	joy->timeout[0] = joy->timeout[1] = 0;
 	joy->d = make_dev(&joy_cdevsw, unit, 0, 0, 0600, "joy%d", unit);
+	joy->d->si_drv1 = joy;
 	return (0);
 }
 
@@ -131,7 +128,7 @@ static int
 joyopen(struct cdev *dev, int flags, int fmt, struct thread *td)
 {
 	int i = joypart (dev);
-	struct joy_softc *joy = JOY_SOFTC(UNIT(dev));
+	struct joy_softc *joy = dev->si_drv1;
 
 	if (joy->timeout[i])
 		return (EBUSY);
@@ -144,7 +141,7 @@ static int
 joyclose(struct cdev *dev, int flags, int fmt, struct thread *td)
 {
 	int i = joypart (dev);
-	struct joy_softc *joy = JOY_SOFTC(UNIT(dev));
+	struct joy_softc *joy = dev->si_drv1;
 
 	joy->timeout[i] = 0;
 	return (0);
@@ -153,7 +150,7 @@ joyclose(struct cdev *dev, int flags, in
 static int
 joyread(struct cdev *dev, struct uio *uio, int flag)
 {
-	struct joy_softc *joy = JOY_SOFTC(UNIT(dev));
+	struct joy_softc *joy = dev->si_drv1;
 	bus_space_handle_t port = joy->port;
 	bus_space_tag_t bt = joy->bt;
 	struct timespec t, start, end;
@@ -217,7 +214,7 @@ joyread(struct cdev *dev, struct uio *ui
 static int
 joyioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
 {
-	struct joy_softc *joy = JOY_SOFTC(UNIT(dev));
+	struct joy_softc *joy = dev->si_drv1;
 	int i = joypart (dev);
 	int x;
 


More information about the svn-src-head mailing list