aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libusb/libusb.320
-rw-r--r--lib/libusb/libusb20.c44
-rw-r--r--lib/libusb/libusb20.h2
-rw-r--r--lib/libusb/libusb20_compat01.c38
-rw-r--r--lib/libusb/libusb20_int.h8
-rw-r--r--lib/libusb/libusb20_ugen20.c24
6 files changed, 12 insertions, 124 deletions
diff --git a/lib/libusb/libusb.3 b/lib/libusb/libusb.3
index 90f0c14f7ba8..8a0315e65620 100644
--- a/lib/libusb/libusb.3
+++ b/lib/libusb/libusb.3
@@ -117,8 +117,6 @@ USB access library (libusb -lusb)
.Ft const char *
.Fn libusb20_dev_get_desc "struct libusb20_device *pdev"
.Ft int
-.Fn libusb20_dev_claim_interface "struct libusb20_device *pdev" "uint8_t iface_index"
-.Ft int
.Fn libusb20_dev_close "struct libusb20_device *pdev"
.Ft int
.Fn libusb20_dev_detach_kernel_driver "struct libusb20_device *pdev" "uint8_t iface_index"
@@ -135,8 +133,6 @@ USB access library (libusb -lusb)
.Ft int
.Fn libusb20_dev_process "struct libusb20_device *pdev"
.Ft int
-.Fn libusb20_dev_release_interface "struct libusb20_device *pdev" "uint8_t iface_index"
-.Ft int
.Fn libusb20_dev_request_sync "struct libusb20_device *pdev" "struct LIBUSB20_CONTROL_SETUP_DECODED *setup" "void *data" "uint16_t *pactlen" "uint32_t timeout" "uint8_t flags"
.Ft int
.Fn libusb20_dev_req_string_sync "struct libusb20_device *pdev" "uint8_t index" "uint16_t langid" "void *ptr" "uint16_t len"
@@ -517,14 +513,6 @@ The format of the string is: "drivername<unit>: <description>"
.
.Pp
.
-.Fn libusb20_dev_claim_interface
-This function will try to claim the given USB interface given by
-.Fa iface_index .
-This function returns zero on success else a LIBUSB20_ERROR value is
-returned.
-.
-.Pp
-.
.Fn libusb20_dev_close
will close the given USB device.
.
@@ -601,14 +589,6 @@ detached.
.
.Pp
.
-.Fn libusb20_dev_release_interface
-will try to release a claimed USB interface for the specified USB device.
-.
-This function returns zero on success else a LIBUSB20_ERROR value is
-returned.
-.
-.Pp
-.
.Fn libusb20_dev_request_sync
will perform a synchronous control request on the given
USB device.
diff --git a/lib/libusb/libusb20.c b/lib/libusb/libusb20.c
index f684bef0e7c7..6e0ec476f3d3 100644
--- a/lib/libusb/libusb20.c
+++ b/lib/libusb/libusb20.c
@@ -65,8 +65,6 @@ dummy_callback(struct libusb20_transfer *xfer)
#define dummy_get_config_desc_full (void *)dummy_int
#define dummy_get_config_index (void *)dummy_int
#define dummy_set_config_index (void *)dummy_int
-#define dummy_claim_interface (void *)dummy_int
-#define dummy_release_interface (void *)dummy_int
#define dummy_set_alt_index (void *)dummy_int
#define dummy_reset_device (void *)dummy_int
#define dummy_set_power_mode (void *)dummy_int
@@ -451,24 +449,6 @@ libusb20_tr_start(struct libusb20_transfer *xfer)
/* USB device operations */
int
-libusb20_dev_claim_interface(struct libusb20_device *pdev, uint8_t ifaceIndex)
-{
- int error;
-
- if (ifaceIndex >= 32) {
- error = LIBUSB20_ERROR_INVALID_PARAM;
- } else if (pdev->claimed_interfaces & (1 << ifaceIndex)) {
- error = LIBUSB20_ERROR_NOT_FOUND;
- } else {
- error = pdev->methods->claim_interface(pdev, ifaceIndex);
- }
- if (!error) {
- pdev->claimed_interfaces |= (1 << ifaceIndex);
- }
- return (error);
-}
-
-int
libusb20_dev_close(struct libusb20_device *pdev)
{
struct libusb20_transfer *xfer;
@@ -494,7 +474,11 @@ libusb20_dev_close(struct libusb20_device *pdev)
pdev->is_opened = 0;
- pdev->claimed_interfaces = 0;
+ /*
+ * The following variable is only used by the libusb v0.1
+ * compat layer:
+ */
+ pdev->claimed_interface = 0;
return (error);
}
@@ -580,24 +564,6 @@ libusb20_dev_open(struct libusb20_device *pdev, uint16_t nTransferMax)
}
int
-libusb20_dev_release_interface(struct libusb20_device *pdev, uint8_t ifaceIndex)
-{
- int error;
-
- if (ifaceIndex >= 32) {
- error = LIBUSB20_ERROR_INVALID_PARAM;
- } else if (!(pdev->claimed_interfaces & (1 << ifaceIndex))) {
- error = LIBUSB20_ERROR_NOT_FOUND;
- } else {
- error = pdev->methods->release_interface(pdev, ifaceIndex);
- }
- if (!error) {
- pdev->claimed_interfaces &= ~(1 << ifaceIndex);
- }
- return (error);
-}
-
-int
libusb20_dev_reset(struct libusb20_device *pdev)
{
int error;
diff --git a/lib/libusb/libusb20.h b/lib/libusb/libusb20.h
index 161411198320..9f45861f7388 100644
--- a/lib/libusb/libusb20.h
+++ b/lib/libusb/libusb20.h
@@ -237,7 +237,6 @@ void *libusb20_tr_get_priv_sc1(struct libusb20_transfer *xfer);
const char *libusb20_dev_get_backend_name(struct libusb20_device *pdev);
const char *libusb20_dev_get_desc(struct libusb20_device *pdev);
-int libusb20_dev_claim_interface(struct libusb20_device *pdev, uint8_t iface_index);
int libusb20_dev_close(struct libusb20_device *pdev);
int libusb20_dev_detach_kernel_driver(struct libusb20_device *pdev, uint8_t iface_index);
int libusb20_dev_set_config_index(struct libusb20_device *pdev, uint8_t configIndex);
@@ -246,7 +245,6 @@ int libusb20_dev_get_fd(struct libusb20_device *pdev);
int libusb20_dev_kernel_driver_active(struct libusb20_device *pdev, uint8_t iface_index);
int libusb20_dev_open(struct libusb20_device *pdev, uint16_t transfer_max);
int libusb20_dev_process(struct libusb20_device *pdev);
-int libusb20_dev_release_interface(struct libusb20_device *pdev, uint8_t iface_index);
int libusb20_dev_request_sync(struct libusb20_device *pdev, struct LIBUSB20_CONTROL_SETUP_DECODED *setup, void *data, uint16_t *pactlen, uint32_t timeout, uint8_t flags);
int libusb20_dev_req_string_sync(struct libusb20_device *pdev, uint8_t index, uint16_t langid, void *ptr, uint16_t len);
int libusb20_dev_req_string_simple_sync(struct libusb20_device *pdev, uint8_t index, void *ptr, uint16_t len);
diff --git a/lib/libusb/libusb20_compat01.c b/lib/libusb/libusb20_compat01.c
index aae819c08026..f97ff4dc947c 100644
--- a/lib/libusb/libusb20_compat01.c
+++ b/lib/libusb/libusb20_compat01.c
@@ -99,26 +99,6 @@ struct usb_parse_state {
uint8_t preparse;
};
-static uint8_t
-usb_get_first_claimed_interface(usb_dev_handle * dev)
-{
- struct libusb20_device *pdev = (void *)dev;
- uint32_t x;
- uint8_t y;
-
- x = pdev->claimed_interfaces;
-
- for (y = 0; y != 32; y++) {
- if (x & (1 << y))
- break;
- }
-
- if (y == 32)
- y = 0xFF; /* dummy */
-
- return (y);
-}
-
static struct libusb20_transfer *
usb_get_transfer_by_ep_no(usb_dev_handle * dev, uint8_t ep_no)
{
@@ -746,12 +726,9 @@ usb_set_configuration(usb_dev_handle * udev, int bConfigurationValue)
int
usb_claim_interface(usb_dev_handle * dev, int interface)
{
- int err;
-
- err = libusb20_dev_claim_interface((void *)dev, interface);
+ struct libusb20_device *pdev = (void *)dev;
- if (err)
- return (-1);
+ pdev->claimed_interface = interface;
return (0);
}
@@ -759,23 +736,18 @@ usb_claim_interface(usb_dev_handle * dev, int interface)
int
usb_release_interface(usb_dev_handle * dev, int interface)
{
- int err;
-
- err = libusb20_dev_release_interface((void *)dev, interface);
-
- if (err)
- return (-1);
-
+ /* do nothing */
return (0);
}
int
usb_set_altinterface(usb_dev_handle * dev, int alternate)
{
+ struct libusb20_device *pdev = (void *)dev;
int err;
uint8_t iface;
- iface = usb_get_first_claimed_interface(dev);
+ iface = pdev->claimed_interface;
err = libusb20_dev_set_alt_index((void *)dev, iface, alternate);
diff --git a/lib/libusb/libusb20_int.h b/lib/libusb/libusb20_int.h
index 706f857e8567..aa89611313ef 100644
--- a/lib/libusb/libusb20_int.h
+++ b/lib/libusb/libusb20_int.h
@@ -90,14 +90,12 @@ typedef int (libusb20_dummy_int_t)(void);
typedef void (libusb20_dummy_void_t)(void);
/* USB device specific */
-typedef int (libusb20_claim_interface_t)(struct libusb20_device *pdev, uint8_t iface_index);
typedef int (libusb20_detach_kernel_driver_t)(struct libusb20_device *pdev, uint8_t iface_index);
typedef int (libusb20_do_request_sync_t)(struct libusb20_device *pdev, struct LIBUSB20_CONTROL_SETUP_DECODED *setup, void *data, uint16_t *pactlen, uint32_t timeout, uint8_t flags);
typedef int (libusb20_get_config_desc_full_t)(struct libusb20_device *pdev, uint8_t **ppbuf, uint16_t *plen, uint8_t index);
typedef int (libusb20_get_config_index_t)(struct libusb20_device *pdev, uint8_t *pindex);
typedef int (libusb20_kernel_driver_active_t)(struct libusb20_device *pdev, uint8_t iface_index);
typedef int (libusb20_process_t)(struct libusb20_device *pdev);
-typedef int (libusb20_release_interface_t)(struct libusb20_device *pdev, uint8_t iface_index);
typedef int (libusb20_reset_device_t)(struct libusb20_device *pdev);
typedef int (libusb20_set_power_mode_t)(struct libusb20_device *pdev, uint8_t power_mode);
typedef int (libusb20_get_power_mode_t)(struct libusb20_device *pdev, uint8_t *power_mode);
@@ -112,14 +110,12 @@ typedef void (libusb20_tr_submit_t)(struct libusb20_transfer *xfer);
typedef void (libusb20_tr_cancel_async_t)(struct libusb20_transfer *xfer);
#define LIBUSB20_DEVICE(m,n) \
- m(n, claim_interface) \
m(n, detach_kernel_driver) \
m(n, do_request_sync) \
m(n, get_config_desc_full) \
m(n, get_config_index) \
m(n, kernel_driver_active) \
m(n, process) \
- m(n, release_interface) \
m(n, reset_device) \
m(n, set_power_mode) \
m(n, get_power_mode) \
@@ -198,8 +194,8 @@ struct libusb20_device {
/* libUSB v0.1 compat data */
void *priv01Data;
- /* claimed interfaces */
- uint32_t claimed_interfaces;
+ /* claimed interface */
+ uint8_t claimed_interface;
/* device file handle */
int file;
diff --git a/lib/libusb/libusb20_ugen20.c b/lib/libusb/libusb20_ugen20.c
index 219e6e7e0769..f130b1f86dbc 100644
--- a/lib/libusb/libusb20_ugen20.c
+++ b/lib/libusb/libusb20_ugen20.c
@@ -67,8 +67,6 @@ const struct libusb20_backend_methods libusb20_ugen20_backend = {
static libusb20_get_config_desc_full_t ugen20_get_config_desc_full;
static libusb20_get_config_index_t ugen20_get_config_index;
static libusb20_set_config_index_t ugen20_set_config_index;
-static libusb20_claim_interface_t ugen20_claim_interface;
-static libusb20_release_interface_t ugen20_release_interface;
static libusb20_set_alt_index_t ugen20_set_alt_index;
static libusb20_reset_device_t ugen20_reset_device;
static libusb20_set_power_mode_t ugen20_set_power_mode;
@@ -517,28 +515,6 @@ ugen20_set_config_index(struct libusb20_device *pdev, uint8_t cfg_index)
}
static int
-ugen20_claim_interface(struct libusb20_device *pdev, uint8_t iface_index)
-{
- int temp = iface_index;
-
- if (ioctl(pdev->file_ctrl, USB_CLAIM_INTERFACE, &temp)) {
- return (LIBUSB20_ERROR_OTHER);
- }
- return (0);
-}
-
-static int
-ugen20_release_interface(struct libusb20_device *pdev, uint8_t iface_index)
-{
- int temp = iface_index;
-
- if (ioctl(pdev->file_ctrl, USB_RELEASE_INTERFACE, &temp)) {
- return (LIBUSB20_ERROR_OTHER);
- }
- return (0);
-}
-
-static int
ugen20_set_alt_index(struct libusb20_device *pdev,
uint8_t iface_index, uint8_t alt_index)
{