From 07c0605ab8ee1d858a12347a7df2bf7417c35120 Mon Sep 17 00:00:00 2001 From: jylefort Date: Wed, 9 Nov 2005 20:26:00 +0000 Subject: [PATCH] Unbreak second joystick (joy1) support. PR: kern/46734 Submitted by: Richard Airlie Approved by: netchild --- sys/dev/joy/joy.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/dev/joy/joy.c b/sys/dev/joy/joy.c index 0568febed341..472985b62681 100644 --- a/sys/dev/joy/joy.c +++ b/sys/dev/joy/joy.c @@ -104,13 +104,13 @@ joy_attach(device_t dev) joy->rid = 0; joy->res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &joy->rid, - RF_ACTIVE); + RF_ACTIVE|RF_SHAREABLE); if (joy->res == NULL) return ENXIO; joy->bt = rman_get_bustag(joy->res); joy->port = rman_get_bushandle(joy->res); joy->timeout[0] = joy->timeout[1] = 0; - joy->d = make_dev(&joy_cdevsw, 0, 0, 0, 0600, "joy%d", unit); + joy->d = make_dev(&joy_cdevsw, unit, 0, 0, 0600, "joy%d", unit); return (0); } @@ -167,6 +167,12 @@ joyread(struct cdev *dev, struct uio *uio, int flag) #else disable_intr (); #endif + nanotime(&t); + end.tv_sec = 0; + end.tv_nsec = joy->timeout[joypart(dev)] * 1000; + timespecadd(&end, &t); + for (; timespeccmp(&t, &end, <) && (bus_space_read_1(bt, port, 0) & 0x0f); nanotime(&t)) + ; /* nothing */ bus_space_write_1 (bt, port, 0, 0xff); nanotime(&start); end.tv_sec = 0;