[sane-devel] usb_claim_interface() missing?

Henning Meier-Geinitz henning@meier-geinitz.de
Sun, 15 Dec 2002 19:23:27 +0100


Hi,

On Sun, Dec 15, 2002 at 06:27:30PM +0100, Beat Birkhofer wrote:
> The libusb-documentation states that usb_claim_interface() (and thus 
> usb_release_interface()) must be called when performing any 
> operations related to his interface (usb_bulk_write() etc.).

True.

> In sanei_usb.c usb_claim_interface() is only called in usb_open().

Also true. I guess usb_release_interface could be added to
sane_close. But is it really necessary? libusb should be intelligent
enough to release any interfaces on close.

> I 
> get somewhat further if I pad usb_bulk_write() and usb_bulk_read() 
> with usb_claim_interface()/usb_release_interface().

I don't think usb_claim_interface is intended to be used that way.
Sure, it must be called before using the interface the first time. But
not everytime you write or read some bytes. Otherwise in the mean time
a different SANE backend or other driver could claim the interface and
mess with your scanner.

Bye,
  Henning