summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 762cfd7..3df9d9b 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;
OpenPOWER on IntegriCloud