Subject: USB_SET_TIMEOUT and UE_INTERRUPT/ISOCHRONOUS
To: None <tech-kern@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-kern
Date: 05/24/2006 00:06:14
--dc+cDN39EJAMEtIO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi,
I've run into an issue while trying to get the newhidups driver from ups-nut.
This driver (or rather, because of the way this driver uses libusb) will
try a UE_INTERRUPT read, but expect it to abort after the time set previously
by USB_SET_TIMEOUT. With a netbsd-3 kernel (I didn't check current),
UE_INTERRUPT and UE_ISOCHRONOUS reads never timeout. The attached patch
fix this, and allows newhidups to talk to the UPS. Does it make sense ?

-- 
Manuel Bouyer <bouyer@antioche.eu.org>
     NetBSD: 26 ans d'experience feront toujours la difference
--

--dc+cDN39EJAMEtIO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff

Index: ugen.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/ugen.c,v
retrieving revision 1.71
diff -u -r1.71 ugen.c
--- ugen.c	2 Mar 2005 11:37:27 -0000	1.71
+++ ugen.c	23 May 2006 22:00:55 -0000
@@ -556,7 +556,8 @@
 			}
 			sce->state |= UGEN_ASLP;
 			DPRINTFN(5, ("ugenread: sleep on %p\n", sce));
-			error = tsleep(sce, PZERO | PCATCH, "ugenri", 0);
+			error = tsleep(sce, PZERO | PCATCH, "ugenri", 
+			    mstohz(sce->timeout));
 			DPRINTFN(5, ("ugenread: woke, error=%d\n", error));
 			if (sc->sc_dying)
 				error = EIO;
@@ -620,7 +621,8 @@
 			}
 			sce->state |= UGEN_ASLP;
 			DPRINTFN(5, ("ugenread: sleep on %p\n", sce));
-			error = tsleep(sce, PZERO | PCATCH, "ugenri", 0);
+			error = tsleep(sce, PZERO | PCATCH, "ugenri", 
+			    mstohz(sce->timeout));
 			DPRINTFN(5, ("ugenread: woke, error=%d\n", error));
 			if (sc->sc_dying)
 				error = EIO;

--dc+cDN39EJAMEtIO--