head 1.11; access; symbols pkgsrc-2026Q1:1.11.0.66 pkgsrc-2026Q1-base:1.11 pkgsrc-2025Q4:1.11.0.64 pkgsrc-2025Q4-base:1.11 pkgsrc-2025Q3:1.11.0.62 pkgsrc-2025Q3-base:1.11 pkgsrc-2025Q2:1.11.0.60 pkgsrc-2025Q2-base:1.11 pkgsrc-2025Q1:1.11.0.58 pkgsrc-2025Q1-base:1.11 pkgsrc-2024Q4:1.11.0.56 pkgsrc-2024Q4-base:1.11 pkgsrc-2024Q3:1.11.0.54 pkgsrc-2024Q3-base:1.11 pkgsrc-2024Q2:1.11.0.52 pkgsrc-2024Q2-base:1.11 pkgsrc-2024Q1:1.11.0.50 pkgsrc-2024Q1-base:1.11 pkgsrc-2023Q4:1.11.0.48 pkgsrc-2023Q4-base:1.11 pkgsrc-2023Q3:1.11.0.46 pkgsrc-2023Q3-base:1.11 pkgsrc-2023Q2:1.11.0.44 pkgsrc-2023Q2-base:1.11 pkgsrc-2023Q1:1.11.0.42 pkgsrc-2023Q1-base:1.11 pkgsrc-2022Q4:1.11.0.40 pkgsrc-2022Q4-base:1.11 pkgsrc-2022Q3:1.11.0.38 pkgsrc-2022Q3-base:1.11 pkgsrc-2022Q2:1.11.0.36 pkgsrc-2022Q2-base:1.11 pkgsrc-2022Q1:1.11.0.34 pkgsrc-2022Q1-base:1.11 pkgsrc-2021Q4:1.11.0.32 pkgsrc-2021Q4-base:1.11 pkgsrc-2021Q3:1.11.0.30 pkgsrc-2021Q3-base:1.11 pkgsrc-2021Q2:1.11.0.28 pkgsrc-2021Q2-base:1.11 pkgsrc-2021Q1:1.11.0.26 pkgsrc-2021Q1-base:1.11 pkgsrc-2020Q4:1.11.0.24 pkgsrc-2020Q4-base:1.11 pkgsrc-2020Q3:1.11.0.22 pkgsrc-2020Q3-base:1.11 pkgsrc-2020Q2:1.11.0.20 pkgsrc-2020Q2-base:1.11 pkgsrc-2020Q1:1.11.0.16 pkgsrc-2020Q1-base:1.11 pkgsrc-2019Q4:1.11.0.18 pkgsrc-2019Q4-base:1.11 pkgsrc-2019Q3:1.11.0.14 pkgsrc-2019Q3-base:1.11 pkgsrc-2019Q2:1.11.0.12 pkgsrc-2019Q2-base:1.11 pkgsrc-2019Q1:1.11.0.10 pkgsrc-2019Q1-base:1.11 pkgsrc-2018Q4:1.11.0.8 pkgsrc-2018Q4-base:1.11 pkgsrc-2018Q3:1.11.0.6 pkgsrc-2018Q3-base:1.11 pkgsrc-2018Q2:1.11.0.4 pkgsrc-2018Q2-base:1.11 pkgsrc-2018Q1:1.11.0.2 pkgsrc-2018Q1-base:1.11 pkgsrc-2017Q4:1.10.0.20 pkgsrc-2017Q4-base:1.10 pkgsrc-2017Q3:1.10.0.18 pkgsrc-2017Q3-base:1.10 pkgsrc-2017Q2:1.10.0.14 pkgsrc-2017Q2-base:1.10 pkgsrc-2017Q1:1.10.0.12 pkgsrc-2017Q1-base:1.10 pkgsrc-2016Q4:1.10.0.10 pkgsrc-2016Q4-base:1.10 pkgsrc-2016Q3:1.10.0.8 pkgsrc-2016Q3-base:1.10 pkgsrc-2016Q2:1.10.0.6 pkgsrc-2016Q2-base:1.10 pkgsrc-2016Q1:1.10.0.4 pkgsrc-2016Q1-base:1.10 pkgsrc-2015Q4:1.10.0.2 pkgsrc-2015Q4-base:1.10 pkgsrc-2015Q3:1.9.0.68 pkgsrc-2015Q3-base:1.9 pkgsrc-2015Q2:1.9.0.66 pkgsrc-2015Q2-base:1.9 pkgsrc-2015Q1:1.9.0.64 pkgsrc-2015Q1-base:1.9 pkgsrc-2014Q4:1.9.0.62 pkgsrc-2014Q4-base:1.9 pkgsrc-2014Q3:1.9.0.60 pkgsrc-2014Q3-base:1.9 pkgsrc-2014Q2:1.9.0.58 pkgsrc-2014Q2-base:1.9 pkgsrc-2014Q1:1.9.0.56 pkgsrc-2014Q1-base:1.9 pkgsrc-2013Q4:1.9.0.54 pkgsrc-2013Q4-base:1.9 pkgsrc-2013Q3:1.9.0.52 pkgsrc-2013Q3-base:1.9 pkgsrc-2013Q2:1.9.0.50 pkgsrc-2013Q2-base:1.9 pkgsrc-2013Q1:1.9.0.48 pkgsrc-2013Q1-base:1.9 pkgsrc-2012Q4:1.9.0.46 pkgsrc-2012Q4-base:1.9 pkgsrc-2012Q3:1.9.0.44 pkgsrc-2012Q3-base:1.9 pkgsrc-2012Q2:1.9.0.42 pkgsrc-2012Q2-base:1.9 pkgsrc-2012Q1:1.9.0.40 pkgsrc-2012Q1-base:1.9 pkgsrc-2011Q4:1.9.0.38 pkgsrc-2011Q4-base:1.9 pkgsrc-2011Q3:1.9.0.36 pkgsrc-2011Q3-base:1.9 pkgsrc-2011Q2:1.9.0.34 pkgsrc-2011Q2-base:1.9 pkgsrc-2011Q1:1.9.0.32 pkgsrc-2011Q1-base:1.9 pkgsrc-2010Q4:1.9.0.30 pkgsrc-2010Q4-base:1.9 pkgsrc-2010Q3:1.9.0.28 pkgsrc-2010Q3-base:1.9 pkgsrc-2010Q2:1.9.0.26 pkgsrc-2010Q2-base:1.9 pkgsrc-2010Q1:1.9.0.24 pkgsrc-2010Q1-base:1.9 pkgsrc-2009Q4:1.9.0.22 pkgsrc-2009Q4-base:1.9 pkgsrc-2009Q3:1.9.0.20 pkgsrc-2009Q3-base:1.9 pkgsrc-2009Q2:1.9.0.18 pkgsrc-2009Q2-base:1.9 pkgsrc-2009Q1:1.9.0.16 pkgsrc-2009Q1-base:1.9 pkgsrc-2008Q4:1.9.0.14 pkgsrc-2008Q4-base:1.9 pkgsrc-2008Q3:1.9.0.12 pkgsrc-2008Q3-base:1.9 cube-native-xorg:1.9.0.10 cube-native-xorg-base:1.9 pkgsrc-2008Q2:1.9.0.8 pkgsrc-2008Q2-base:1.9 cwrapper:1.9.0.6 pkgsrc-2008Q1:1.9.0.4 pkgsrc-2008Q1-base:1.9 pkgsrc-2007Q4:1.9.0.2 pkgsrc-2007Q4-base:1.9 pkgsrc-2007Q3:1.8.0.12 pkgsrc-2007Q3-base:1.8 pkgsrc-2007Q2:1.8.0.10 pkgsrc-2007Q2-base:1.8 pkgsrc-2007Q1:1.8.0.8 pkgsrc-2007Q1-base:1.8 pkgsrc-2006Q4:1.8.0.6 pkgsrc-2006Q4-base:1.8 pkgsrc-2006Q3:1.8.0.4 pkgsrc-2006Q3-base:1.8 pkgsrc-2006Q2:1.8.0.2 pkgsrc-2006Q2-base:1.8 pkgsrc-2006Q1:1.7.0.2 pkgsrc-2006Q1-base:1.7 pkgsrc-2005Q4:1.6.0.4 pkgsrc-2005Q4-base:1.6 pkgsrc-2005Q3:1.6.0.2 pkgsrc-2005Q3-base:1.6 pkgsrc-2005Q2:1.5.0.4 pkgsrc-2005Q2-base:1.5 pkgsrc-2005Q1:1.5.0.2 pkgsrc-2005Q1-base:1.5 pkgsrc-2004Q4:1.4.0.4 pkgsrc-2004Q4-base:1.4 pkgsrc-2004Q3:1.4.0.2 pkgsrc-2004Q3-base:1.4 pkgsrc-2004Q2:1.3.0.6 pkgsrc-2004Q2-base:1.3 pkgsrc-2004Q1:1.3.0.4 pkgsrc-2004Q1-base:1.3 pkgsrc-2003Q4:1.3.0.2 pkgsrc-2003Q4-base:1.3 netbsd-1-6:1.2.0.8 netbsd-1-6-RELEASE-base:1.2 pkgviews:1.2.0.4 pkgviews-base:1.2 buildlink2:1.2.0.2 buildlink2-base:1.3 netbsd-1-5-PATCH003:1.2; locks; strict; comment @# @; 1.11 date 2018.02.19.17.59.23; author mrg; state Exp; branches; next 1.10; commitid CLAqgNELEcsSQurA; 1.10 date 2015.10.25.10.18.34; author wiz; state Exp; branches; next 1.9; commitid A73GGi4ZA4QAytGy; 1.9 date 2007.10.11.18.25.19; author drochner; state Exp; branches; next 1.8; 1.8 date 2006.05.26.10.06.13; author joerg; state Exp; branches; next 1.7; 1.7 date 2006.03.11.08.34.13; author adam; state Exp; branches; next 1.6; 1.6 date 2005.08.22.17.15.23; author reed; state Exp; branches; next 1.5; 1.5 date 2005.02.14.09.50.18; author adam; state Exp; branches; next 1.4; 1.4 date 2004.06.23.08.42.57; author mycroft; state Exp; branches; next 1.3; 1.3 date 2002.08.19.19.07.22; author mycroft; state dead; branches; next 1.2; 1.2 date 2002.03.03.15.22.28; author veego; state Exp; branches 1.2.2.1; next 1.1; 1.1 date 2002.03.03.15.20.10; author veego; state Exp; branches; next ; 1.2.2.1 date 2002.08.22.11.10.48; author jlam; state dead; branches; next ; desc @@ 1.11 log @eat EAGAIN messages and simply retry. this fixes libusb / ups-nut-usb from flooding my syslog with multiple messages per second. bump pkg version. @ text @$NetBSD: patch-ad,v 1.10 2015/10/25 10:18:34 wiz Exp $ Fix build on some platforms. Eat EAGAIN returns. --- bsd.c.orig 2006-03-03 18:52:46.000000000 -0800 +++ bsd.c 2016-10-21 01:20:19.000000000 -0700 @@@@ -25,8 +25,8 @@@@ * for both read and write. */ -#if defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) -#define __FreeBSD_kernel__ __FreeBSD__ +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +#define FreeBSD_like_device_names 1 #endif #include @@@@ -39,14 +39,18 @@@@ #include #include +#if (__DragonFly__) +#include +#else #include +#endif #include "usbi.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif -#ifdef HAVE_OLD_DEV_USB_USB_H +#if defined(HAVE_OLD_DEV_USB_USB_H) && !defined(__DragonFly__) /* * It appears some of the BSD's (OpenBSD atleast) have switched over to a * new naming convention, so we setup some macro's for backward @@@@ -146,7 +150,7 @@@@ USB_ERROR(-ENOMEM); dev->impl_info = info; -#ifdef __FreeBSD_kernel__ +#ifdef FreeBSD_like_device_names snprintf(ctlpath, PATH_MAX, "%s", dev->device->filename); #else snprintf(ctlpath, PATH_MAX, "%s.00", dev->device->filename); @@@@ -259,7 +263,7 @@@@ ep = UE_GET_ADDR(ep); if (info->ep_fd[ep] < 0) { -#ifdef __FreeBSD_kernel__ +#ifdef FreeBSD_like_device_names snprintf(buf, sizeof(buf) - 1, "%s.%d", dev->device->filename, ep); #else snprintf(buf, sizeof(buf) - 1, "%s.%02d", dev->device->filename, ep); @@@@ -290,7 +294,7 @@@@ fd = ensure_ep_open(dev, ep, O_WRONLY); if (fd < 0) { if (usb_debug >= 2) { -#ifdef __FreeBSD_kernel__ +#ifdef FreeBSD_like_device_names fprintf (stderr, "usb_bulk_write: got negative open file descriptor for endpoint %d\n", UE_GET_ADDR(ep)); #else fprintf (stderr, "usb_bulk_write: got negative open file descriptor for endpoint %02d\n", UE_GET_ADDR(ep)); @@@@ -306,7 +310,7 @@@@ ret = write(fd, bytes, size); if (ret < 0) -#ifdef __FreeBSD_kernel__ +#ifdef FreeBSD_like_device_names USB_ERROR_STR(-errno, "error writing to bulk endpoint %s.%d: %s", dev->device->filename, UE_GET_ADDR(ep), strerror(errno)); #else @@@@ -328,7 +332,7 @@@@ fd = ensure_ep_open(dev, ep, O_RDONLY); if (fd < 0) { if (usb_debug >= 2) { -#ifdef __FreeBSD_kernel__ +#ifdef FreeBSD_like_device_names fprintf (stderr, "usb_bulk_read: got negative open file descriptor for endpoint %d\n", UE_GET_ADDR(ep)); #else fprintf (stderr, "usb_bulk_read: got negative open file descriptor for endpoint %02d\n", UE_GET_ADDR(ep)); @@@@ -347,7 +351,7 @@@@ ret = read(fd, bytes, size); if (ret < 0) -#ifdef __FreeBSD_kernel__ +#ifdef FreeBSD_like_device_names USB_ERROR_STR(-errno, "error reading from bulk endpoint %s.%d: %s", dev->device->filename, UE_GET_ADDR(ep), strerror(errno)); #else @@@@ -369,7 +373,7 @@@@ fd = ensure_ep_open(dev, ep, O_WRONLY); if (fd < 0) { if (usb_debug >= 2) { -#ifdef __FreeBSD_kernel__ +#ifdef FreeBSD_like_device_names fprintf (stderr, "usb_interrupt_write: got negative open file descriptor for endpoint %d\n", UE_GET_ADDR(ep)); #else fprintf (stderr, "usb_interrupt_write: got negative open file descriptor for endpoint %02d\n", UE_GET_ADDR(ep)); @@@@ -386,7 +390,7 @@@@ do { ret = write(fd, bytes+sent, size-sent); if (ret < 0) -#ifdef __FreeBSD_kernel__ +#ifdef FreeBSD_like_device_names USB_ERROR_STR(-errno, "error writing to interrupt endpoint %s.%d: %s", dev->device->filename, UE_GET_ADDR(ep), strerror(errno)); #else @@@@ -403,7 +407,7 @@@@ int usb_interrupt_read(usb_dev_handle *dev, int ep, char *bytes, int size, int timeout) { - int fd, ret, retrieved = 0, one = 1; + int fd, ret, retrieved = 0, one = 1, requested; /* Ensure the endpoint address is correct */ ep |= USB_ENDPOINT_IN; @@@@ -411,7 +415,7 @@@@ fd = ensure_ep_open(dev, ep, O_RDONLY); if (fd < 0) { if (usb_debug >= 2) { -#ifdef __FreeBSD_kernel__ +#ifdef FreeBSD_like_device_names fprintf (stderr, "usb_interrupt_read: got negative open file descriptor for endpoint %d\n", UE_GET_ADDR(ep)); #else fprintf (stderr, "usb_interrupt_read: got negative open file descriptor for endpoint %02d\n", UE_GET_ADDR(ep)); @@@@ -429,17 +433,21 @@@@ USB_ERROR_STR(-errno, "error setting short xfer: %s", strerror(errno)); do { - ret = read(fd, bytes+retrieved, size-retrieved); - if (ret < 0) -#ifdef __FreeBSD_kernel__ - USB_ERROR_STR(-errno, "error reading from interrupt endpoint %s.%d: %s", - dev->device->filename, UE_GET_ADDR(ep), strerror(errno)); -#else - USB_ERROR_STR(-errno, "error reading from interrupt endpoint %s.%02d: %s", - dev->device->filename, UE_GET_ADDR(ep), strerror(errno)); -#endif - retrieved += ret; - } while (ret > 0 && retrieved < size); + requested = size - retrieved; + ret = read(fd, bytes+retrieved, requested); + if (ret < 0) { + if (errno != EAGAIN) { +#ifdef FreeBSD_like_device_names + USB_ERROR_STR(-errno, "error reading from interrupt endpoint %s.%d: %s", + dev->device->filename, UE_GET_ADDR(ep), strerror(errno)); +#else + USB_ERROR_STR(-errno, "error reading from interrupt endpoint %s.%02d: %s", + dev->device->filename, UE_GET_ADDR(ep), strerror(errno)); +#endif + } + } else + retrieved += ret; + } while (ret > 0 && retrieved < size && ret != requested); return retrieved; } @@@@ -477,7 +485,7 @@@@ USB_ERROR_STR(-errno, "error sending control message: %s", strerror(errno)); - return UGETW(req.ucr_request.wLength); + return req.ucr_actlen; } int usb_os_find_busses(struct usb_bus **busses) @@@@ -548,7 +556,7 @@@@ /* best not to play with things we don't understand */ continue; -#ifdef __FreeBSD_kernel__ +#ifdef FreeBSD_like_device_names snprintf(buf, sizeof(buf) - 1, "/dev/%s", di.udi_devnames[0]); #else snprintf(buf, sizeof(buf) - 1, "/dev/%s.00", di.udi_devnames[0]); @@@@ -574,7 +582,7 @@@@ /* we need to report the device name as /dev/ugenx NOT /dev/ugenx.00 * This seemed easier than having 2 variables... */ -#if (__NetBSD__ || __OpenBSD__) +#if !defined(FreeBSD_like_device_names) snprintf(buf, sizeof(buf) - 1, "/dev/%s", di.udi_devnames[0]); #endif @ 1.10 log @Fix a long-standing bug in short reads. Reported by and patch from Dave Tyson in PR 50365. While here, fix return value for partial reads with errors. Bump PKGREVISION. @ text @d1 1 a1 1 $NetBSD: patch-ad,v 1.9 2007/10/11 18:25:19 drochner Exp $ d3 5 a7 2 --- bsd.c.orig 2006-03-04 02:52:46.000000000 +0000 +++ bsd.c d39 1 a39 1 @@@@ -146,7 +150,7 @@@@ int usb_os_open(usb_dev_handle *dev) d48 1 a48 1 @@@@ -259,7 +263,7 @@@@ static int ensure_ep_open(usb_dev_handle d57 1 a57 1 @@@@ -290,7 +294,7 @@@@ int usb_bulk_write(usb_dev_handle *dev, d66 1 a66 1 @@@@ -306,7 +310,7 @@@@ int usb_bulk_write(usb_dev_handle *dev, d75 1 a75 1 @@@@ -328,7 +332,7 @@@@ int usb_bulk_read(usb_dev_handle *dev, i d84 1 a84 1 @@@@ -347,7 +351,7 @@@@ int usb_bulk_read(usb_dev_handle *dev, i d93 1 a93 1 @@@@ -369,7 +373,7 @@@@ int usb_interrupt_write(usb_dev_handle * d102 1 a102 1 @@@@ -386,7 +390,7 @@@@ int usb_interrupt_write(usb_dev_handle * d111 1 a111 1 @@@@ -403,7 +407,7 @@@@ int usb_interrupt_write(usb_dev_handle * d120 1 a120 1 @@@@ -411,7 +415,7 @@@@ int usb_interrupt_read(usb_dev_handle *d d129 1 a129 1 @@@@ -429,17 +433,19 @@@@ int usb_interrupt_read(usb_dev_handle *d d134 10 d146 2 a147 2 if (ret < 0) -#ifdef __FreeBSD_kernel__ d149 8 a156 9 USB_ERROR_STR(-errno, "error reading from interrupt endpoint %s.%d: %s", dev->device->filename, UE_GET_ADDR(ep), strerror(errno)); #else USB_ERROR_STR(-errno, "error reading from interrupt endpoint %s.%02d: %s", dev->device->filename, UE_GET_ADDR(ep), strerror(errno)); #endif - retrieved += ret; - } while (ret > 0 && retrieved < size); + else d162 1 a162 1 @@@@ -477,7 +483,7 @@@@ int usb_control_msg(usb_dev_handle *dev, d171 1 a171 1 @@@@ -548,7 +554,7 @@@@ int usb_os_find_devices(struct usb_bus * d180 1 a180 1 @@@@ -574,7 +580,7 @@@@ int usb_os_find_devices(struct usb_bus * @ 1.9 log @Make usb_control_msg() return the number of bytes actually transferred rather than the requested transfer length (USBD_SHORT_XFER_OK is set, so this may happen). This is the documented behaviour, and it is appearently what the Linux version does. Bump PKGREVISION. From Erik Berls per PR pkg/37053. @ text @d1 1 a1 1 $NetBSD$ d3 1 a3 1 --- bsd.c.orig 2006-03-04 03:52:46.000000000 +0100 d126 1 a126 1 @@@@ -429,9 +433,10 @@@@ int usb_interrupt_read(usb_dev_handle *d d139 1 a139 1 @@@@ -439,7 +444,7 @@@@ int usb_interrupt_read(usb_dev_handle *d d142 1 a142 1 retrieved += ret; d144 3 a146 1 + } while (ret > 0 && retrieved < size && ret == requested); d150 1 a150 1 @@@@ -477,7 +482,7 @@@@ int usb_control_msg(usb_dev_handle *dev, d159 1 a159 1 @@@@ -548,7 +553,7 @@@@ int usb_os_find_devices(struct usb_bus * d168 1 a168 1 @@@@ -574,7 +579,7 @@@@ int usb_os_find_devices(struct usb_bus * @ 1.8 log @Fix path names to USB devices on DragonFly. Bump revision. Based on patch from Joe Talbott. @ text @d3 1 a3 1 --- bsd.c.orig 2006-03-04 02:52:46.000000000 +0000 d148 9 @ 1.7 log @Changes 0.1.12: Fix structure padding issues on some architectures Fix compile warnings with newer versions of gcc Fix memory leak when continuously rescanning for devices Check for device nodes in /dev/usb under Linux Fix compile problem with Darwin/Mac OS X port Add support for Darwin/Mac OS X 10.4 Fix error when transactions are aborted Requery endpoints when switching alternate settings Support more BSD based distributions Fix problem with short control messages in BSD port Various other minor fixes @ text @d3 1 a3 1 --- bsd.c.orig 2006-03-04 03:52:46.000000000 +0100 d5 11 d36 72 d117 10 a126 1 @@@@ -429,7 +433,8 @@@@ int usb_interrupt_read(usb_dev_handle *d d134 2 a135 1 #ifdef __FreeBSD_kernel__ d137 2 d148 18 @ 1.6 log @Add DragonFly support. (Okayed by drochner@@.) This needs testing under DragonFly. @ text @d3 3 a5 3 --- bsd.c.orig 2004-02-17 22:34:52.000000000 -0800 +++ bsd.c 2005-08-20 09:08:12.000000000 -0700 @@@@ -35,14 +35,18 @@@@ d25 1 a25 1 @@@@ -399,7 +403,7 @@@@ d34 1 a34 1 @@@@ -425,7 +429,8 @@@@ d42 1 a42 1 #if __FreeBSD__ d44 1 a44 1 @@@@ -435,7 +440,7 @@@@ @ 1.5 log @Changes 0.1.10: * Fix various compile warnings * Require newer autotools * Switch from QT to STL for C++ extensions * Linux: * Speed up small bulk and interrupt transfers to previous speeds * Fix case where bulk and interrupt transfers could block forever * Fix tree heirarchy building code (undocumented) @ text @d3 23 a25 3 --- bsd.c.orig 2004-02-18 06:34:52.000000000 +0000 +++ bsd.c @@@@ -399,7 +399,7 @@@@ int usb_interrupt_write(usb_dev_handle * d34 1 a34 1 @@@@ -425,7 +425,8 @@@@ int usb_interrupt_read(usb_dev_handle *d d44 1 a44 1 @@@@ -435,7 +436,7 @@@@ int usb_interrupt_read(usb_dev_handle *d @ 1.4 log @Make usb_bulk_read() terminate short transfers correctly. This mimics the Linux code, and is critical for making PTP work. @ text @d3 5 a7 5 --- bsd.c.orig 2004-01-27 22:36:40.000000000 +0000 +++ bsd.c 2004-06-23 08:40:16.000000000 +0000 @@@@ -320,7 +320,7 @@@@ int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size, int timeout) d14 1 a14 1 @@@@ -346,7 +346,8 @@@@ d23 2 a24 2 USB_ERROR_STR(-errno, "error reading from bulk endpoint %s.%d: %s", @@@@ -356,7 +357,7 @@@@ @ 1.3 log @Update to 0.1.6a. There is no documentation included on the changes, but a cursory inspection suggests that they are mostly build related, and some minor bug fixes to the platform-dependent code. @ text @d1 1 a1 1 $NetBSD: patch-ad,v 1.2 2002/03/03 15:22:28 veego Exp $ d3 23 a25 33 --- bsd.c.orig Thu Feb 7 07:43:25 2002 +++ bsd.c Sun Mar 3 14:59:58 2002 @@@@ -37,6 +37,16 @@@@ #include +#ifndef USB_STACK_VERSION +#define uai_interface_index interface_index +#define uai_alt_no alt_no +#define ucr_request request +#define ucr_data data +#define ucr_flags flags +#define udi_addr addr +#define udi_devnames devnames +#endif + #include "usbi.h" #ifdef HAVE_CONFIG_H #include "config.h" @@@@ -151,8 +161,8 @@@@ if (dev->interface < 0) USB_ERROR(-EINVAL); - intf.interface_index = dev->interface; - intf.alt_no = alternate; + intf.uai_interface_index = dev->interface; + intf.uai_alt_no = alternate; ret = ioctl(dev->fd, USB_SET_ALTINTERFACE, &intf); if (ret < 0) @@@@ -182,6 +192,11 @@@@ #else snprintf(buf, sizeof(buf) - 1, "%s.%02d", dev->device->filename, ep); d27 3 a29 11 + /* 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", @@@@ -284,14 +299,14 @@@@ fprintf(stderr, "usb_control_msg: %d %d %d %d %p %d %d\n", requesttype, request, value, index, bytes, size, timeout); d31 1 a31 24 - req.request.bmRequestType = requesttype; - req.request.bRequest = request; - USETW(req.request.wValue, value); - USETW(req.request.wIndex, index); - USETW(req.request.wLength, size); + req.ucr_request.bmRequestType = requesttype; + req.ucr_request.bRequest = request; + USETW(req.ucr_request.wValue, value); + USETW(req.ucr_request.wIndex, index); + USETW(req.ucr_request.wLength, size); - req.data = bytes; - req.flags = 0; + req.ucr_data = bytes; + req.ucr_flags = 0; ret = ioctl(dev->fd, USB_SET_TIMEOUT, &timeout); if (ret < 0) @@@@ -303,7 +318,7 @@@@ USB_ERROR_STR(ret, "error sending control message: %s", strerror(errno)); - return UGETW(req.request.wLength); + return UGETW(req.ucr_request.wLength); a32 36 int usb_find_devices_on_bus(struct usb_bus *bus) @@@@ -321,20 +336,20 @@@@ struct usb_device *dev; char buf[20]; - di.addr = device; + di.udi_addr = device; if (ioctl(cfd, USB_DEVICEINFO, &di) < 0) continue; /* There's a device; is it one we should mess with? */ - if (strncmp(di.devnames[0], "ugen", 4) != 0) + if (strncmp(di.udi_devnames[0], "ugen", 4) != 0) /* best not to play with things we don't understand */ continue; #if __FreeBSD__ - snprintf(buf, sizeof(buf) - 1, "/dev/%s", di.devnames[0]); + snprintf(buf, sizeof(buf) - 1, "/dev/%s", di.udi_devnames[0]); #else - snprintf(buf, sizeof(buf) - 1, "/dev/%s.00", di.devnames[0]); + snprintf(buf, sizeof(buf) - 1, "/dev/%s.00", di.udi_devnames[0]); #endif /* Don't re-add it if we were called multiple times */ @@@@ -364,7 +379,7 @@@@ * This seemed easier than having 2 variables... */ #if __NetBSD__ - snprintf(buf, sizeof(buf) - 1, "/dev/%s", di.devnames[0]); + snprintf(buf, sizeof(buf) - 1, "/dev/%s", di.udi_devnames[0]); #endif strncpy(dev->filename, buf, sizeof(dev->filename) - 1); @ 1.2 log @Patch to build it on -current systems after the renaming in usb.h. Use the same logic as in usbutil. @ text @d1 1 a1 1 $NetBSD$ @ 1.2.2.1 log @Merge changes from pkgsrc-current into the buildlink2 branch for the packages that have buildlink2.mk files. @ text @d1 1 a1 1 $NetBSD: patch-ad,v 1.2 2002/03/03 15:22:28 veego Exp $ @ 1.1 log @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. @ text @d3 31 a33 17 =================================================================== 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: bsd.c,v 1.11 2002/02/05 20:43:38 jerdfelt Exp $ + * $Id: bsd.c,v 1.12 2002/02/16 18:56:51 jerdfelt Exp $ * $Name: $ * * This library is covered by the LGPL, read LICENSE for details. @@@@ -182,7 +182,12 @@@@ a36 1 - fd = open(buf, mode); d42 1 a42 1 + fd = open(buf, mode); d45 65 a109 1 buf, strerror(errno)); @