diff options
author | Daniel Drake <dsd@gentoo.org> | 2008-05-29 12:35:01 +0100 |
---|---|---|
committer | Daniel Drake <dsd@gentoo.org> | 2008-05-29 12:35:01 +0100 |
commit | 514bb8790cfe8b93ccfff82bc17081b1030acce0 (patch) | |
tree | 8a59c368cbca414f2dc46532593ee7be463d5934 /libusb/libusbi.h | |
parent | d1292f8e7300051239a7ed2769d221dc7a6f9fca (diff) | |
download | libusb-514bb8790cfe8b93ccfff82bc17081b1030acce0.tar.gz |
Refine libusb_set_configuration() semantics
Applications will generally want to set a configuration before claiming
interfaces. The problem is that the interface may already be set, and
someone else may have claimed an interface (meaning that all calls to
set_configuration will fail, even if it's for the same configuration).
There are now 2 options:
1. Use the new libusb_get_configuration() to determine active
configuration before calling libusb_set_configuration()
2. Or just call libusb_set_configuration() as usual, which will do
nothing if that configuration is already active.
Diffstat (limited to 'libusb/libusbi.h')
-rw-r--r-- | libusb/libusbi.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libusb/libusbi.h b/libusb/libusbi.h index 41c8097..5c00a63 100644 --- a/libusb/libusbi.h +++ b/libusb/libusbi.h @@ -436,6 +436,25 @@ struct usbi_os_backend { uint8_t config_index, unsigned char *buffer, size_t len, int *host_endian); + /* Get the bConfigurationValue for the active configuration for a device. + * Optional. This should only be implemented if you can retrieve it from + * cache (don't generate I/O). + * + * If you cannot retrieve this from cache, either do not implement this + * function, or return LIBUSB_ERROR_NOT_SUPPORTED. This will cause + * libusb to retrieve the information through a standard control transfer. + * + * This function must be non-blocking. + * Return: + * - 0 on success + * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since it + * was opened + * - LIBUSB_ERROR_NOT_SUPPORTED if the value cannot be retrieved without + * blocking + * - another LIBUSB_ERROR code on other failure. + */ + int (*get_configuration)(struct libusb_device_handle *handle, int *config); + /* Set the active configuration for a device. * * A configuration value of -1 should put the device in unconfigured state. |