usb/173666: [USB, LIBUSB] usb_reset() behavior different between GNU/Linux and FreeBSD
Hans Petter Selasky
hselasky at c2i.net
Fri Dec 21 07:37:00 UTC 2012
On Friday 21 December 2012 08:15:23 Xiaofan Chen wrote:
> On Sat, Nov 17, 2012 at 8:19 PM, Hans Petter Selasky <hselasky at c2i.net>
wrote:
> > On Friday 16 November 2012 23:47:29 Wojciech A. Koszek wrote:
> >> >Number: 173666
> >> >Category: usb
> >> >Synopsis: [USB, LIBUSB] usb_reset() behavior different between
> >> >GNU/Linux and FreeBSD Confidential: no
> >> >Severity: non-critical
> >> >Priority: low
> >> >Responsible: freebsd-usb
> >> >State: open
> >> >Quarter:
> >> >Keywords:
> >> >Date-Required:
> >> >Class: sw-bug
> >> >Submitter-Id: current-users
> >> >Arrival-Date: Fri Nov 16 22:50:00 UTC 2012
> >> >Closed-Date:
> >> >Last-Modified:
> >> >Originator: Wojciech A. Koszek
> >> >Release: 9.0-RELEASE
> >>
> >> >Organization:
> >> FreeBSD
> >>
> >> >Environment:
> >> FreeBSD seu 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:15:25 UTC
> >> 2012 root at obrian.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386
> >>
> >> >Description:
> >> I have a driver written for libusb, which works fine under GNU/Linux and
> >> libusb. Device:
> >>
> >> gen0.2: <JSB283 Relay Module J-Works,Inc> at usbus0, cfg=0 md=HOST
> >> spd=LOW (1.5Mbps) pwr=ON
> >>
> >> (I used USB sniffer to uncover traffic based on what Windows was doing)
> >>
> >> Under Linux usb_reset()+usb_set_configuration() calls works fine. Under
> >> FreeBSD I have to disable calling usb_reset(), otherwise
> >> usb_set_configuration() fails with I/O error.
> >
> > According to:
> >
> > http://libusb.sourceforge.net/doc/function.usbreset.html
> >
> > What you describe is the expected behaviour.
>
> The above document is really meant for libusb-0.1 but the
> behavior of libusb-compat's usb_reset() is different since
> it is based on libusb-1.0's libusb_reset_device.
>
> http://git.libusb.org/?p=libusb-compat-0.1.git;a=blob;f=libusb/core.c
> 743 API_EXPORTED int usb_reset(usb_dev_handle *dev)
> 744 {
> 745 usbi_dbg("");
> 746 return compat_err(libusb_reset_device(dev->handle));
> 747 }
>
> For libusb-1.0 under Linux and Mac OS X, usually
> libusb_reset_device will not cause enumeration.
>
> Reference:
> http://libusb.6.n5.nabble.com/PATCH-make-libusb-reset-force-re-enumeration-
> on-Mac-td4499375.html
>
> http://libusb.sourceforge.net/api-1.0/group__dev.html#ga7321bd8dc28e9a20b41
> 1bf18e6d0e9aa
>
> int libusb_reset_device ( libusb_device_handle * dev )
> Perform a USB port reset to reinitialize a device.
>
> The system will attempt to restore the previous configuration and
> alternate settings after the reset has completed.
>
> If the reset fails, the descriptors change, or the previous state
> cannot be restored, the device will appear to be disconnected
> and reconnected. This means that the device handle is no longer
> valid (you should close it) and rediscover the device. A return code
> of LIBUSB_ERROR_NOT_FOUND indicates when this is the case.
>
> This is a blocking function which usually incurs a noticeable delay.
>
> Parameters:
> dev a handle of the device to reset
> Returns:
> 0 on success
> LIBUSB_ERROR_NOT_FOUND if re-enumeration is required, or if the
> device has been disconnected
> another LIBUSB_ERROR code on other failure
Hi,
If you look in the old libusb-0.1 code you'll see something different I think.
Could you check that?
--HPS
More information about the freebsd-usb
mailing list