summaryrefslogtreecommitdiff
path: root/devel/libusb
diff options
context:
space:
mode:
authorveego <veego@pkgsrc.org>2002-03-03 15:20:10 +0000
committerveego <veego@pkgsrc.org>2002-03-03 15:20:10 +0000
commitc33c399381e13ceb14d13283da8ed1726adf78da (patch)
treefa86f46bcd50c30733f3349858303b131ca7f84c /devel/libusb
parent83dc6e50bf7f362a8600b1f0b404bad9492159ef (diff)
downloadpkgsrc-c33c399381e13ceb14d13283da8ed1726adf78da.tar.gz
Patch from sourceforge (revision 1.12 of bsd.c):
Patch from seagull at aracnet.com: Some time ago, I identified a problem with libusb under FreeBSD. The issue is that the current implementation of bsd.c assumes that a particular endpoint is unidirectional. If you write, for example, to endpoint 2, you can't later on read from that same endpoint and visa-versa. Although USB pipes are unidrectional, they can be "stacked" on the same endpoint. Endpoint 2, for example, has two pipes: 0x02 and 0x82, with the high bit representing the transfer direction of the pipe. Since the BSD USB stack does not let you open two descriptors for the same endpoint, and it does not let you close and reopen an endpoint in the middle of a "session", I had originally proposed that the endpoint always be opened O_RDWR so that bidirectional communication would be supported. However, it was later pointed out that a device which really did only have a unidrectional pipe on an endpoint would fail on ENXIO if you tried to open it O_RDWR, so I went back to the drawing board and came up with a patch for bsd.c which should solve the issue for both cases. What it does is first attempt to open the endpoint O_RDWR. If that fails on ENXIO, then it attempts to open the pipe in the direction appropriate for the operation that you were committing.
Diffstat (limited to 'devel/libusb')
-rw-r--r--devel/libusb/patches/patch-ad32
1 files changed, 32 insertions, 0 deletions
diff --git a/devel/libusb/patches/patch-ad b/devel/libusb/patches/patch-ad
new file mode 100644
index 00000000000..af34c2fa8e0
--- /dev/null
+++ b/devel/libusb/patches/patch-ad
@@ -0,0 +1,32 @@
+$NetBSD: patch-ad,v 1.1 2002/03/03 15:20:10 veego Exp $
+
+===================================================================
+RCS file: /cvsroot/libusb/libusb/bsd.c,v
+retrieving revision 1.11
+retrieving revision 1.12
+diff -u -r1.11 -r1.12
+--- bsd.c 2002/02/05 20:43:38 1.11
++++ bsd.c 2002/02/16 18:56:51 1.12
+@@ -3,7 +3,7 @@
+ *
+ * Derived from Linux version by Richard Tobin.
+ *
+- * $Id: patch-ad,v 1.1 2002/03/03 15:20:10 veego Exp $
++ * $Id: patch-ad,v 1.1 2002/03/03 15:20:10 veego Exp $
+ * $Name: $
+ *
+ * This library is covered by the LGPL, read LICENSE for details.
+@@ -182,7 +182,12 @@
+ #else
+ snprintf(buf, sizeof(buf) - 1, "%s.%02d", dev->device->filename, ep);
+ #endif
+- fd = open(buf, mode);
++ /* Try to open it O_RDWR first for those devices which have in and out
++ * endpoints with the same address (eg 0x02 and 0x82)
++ */
++ fd = open(buf, O_RDWR);
++ if (fd < 0 && errno == ENXIO)
++ fd = open(buf, mode);
+ if (fd < 0)
+ USB_ERROR_STR(fd, "can't open %s for bulk read: %s\n",
+ buf, strerror(errno));