[sane-devel] sanei_usb_claim_interface, sanei_usb_release_interface

ABC abc at telekom.ru
Wed Dec 3 02:51:22 UTC 2008

Sorry for my curiosity.

What is the point of having in sanei_usb these two functions?
(Besides misuse of course.)

Because, sanei_usb_open is already claiming correct interface after
its opening, it is mandatory (for libusb).

Plus, there is no way to know correct interface number to claim under
sanei, so all few backends (hpljm1005, rts8891, sm3840) who using
sanei_usb_claim_interface always claiming interface 0.

Interestingly to read documentation for sanei_usb_claim_interface:
> Change claim interface
> Change release interface


Moreover, if you claim interface manually with sanei_usb_claim_interface
and it is happen to be correct interface number, for example 0, and
later before closing device you want to sanei_usb_release_interface,
then when you call sanei_usb_close it tries to release correct interface
(because it is claimed in sanei_osb_open, remember) it will fail a bit
becasue you just released it yourself. In debug mode you will see such

> [sanei_usb] sanei_usb_release_interface: interface_number = 0
> [sanei_usb] sanei_usb_close: closing device 0
> USB error: could not release intf 0: Invalid argument

(Multiple claiming is allowed though, and not producing warning).

In my opinion sanei_usb_claim_interface should never be used.

More information about the sane-devel mailing list