aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/joy
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2009-04-14 11:23:09 +0000
committerEd Schouten <ed@FreeBSD.org>2009-04-14 11:23:09 +0000
commit9ef0e425f37b55f355a818274dabc12f6252e4d4 (patch)
treecc23728ae2cfdd40581a09bd582cd223bc38da87 /sys/dev/joy
parent9a338160ba635db13fe4201b3caf7c195f431273 (diff)
Notes
Diffstat (limited to 'sys/dev/joy')
-rw-r--r--sys/dev/joy/joy.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/sys/dev/joy/joy.c b/sys/dev/joy/joy.c
index 762cfd7a0266..3df9d9be479a 100644
--- a/sys/dev/joy/joy.c
+++ b/sys/dev/joy/joy.c
@@ -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, int fmt, struct thread *td)
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 *uio, int flag)
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;