Cleanup claim/release interface code, which is specific to libusb v0.1. Remove
claim and release interface support from libusb v2.0, because it is not useful. Submitted by: Hans Petter Selasky
This commit is contained in:
parent
fd4f10ceca
commit
4315b3c95d
@ -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.
|
||||
|
@ -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
|
||||
@ -450,24 +448,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)
|
||||
{
|
||||
@ -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);
|
||||
}
|
||||
@ -579,24 +563,6 @@ libusb20_dev_open(struct libusb20_device *pdev, uint16_t nTransferMax)
|
||||
return (error);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
struct libusb20_device *pdev = (void *)dev;
|
||||
|
||||
err = libusb20_dev_claim_interface((void *)dev, interface);
|
||||
|
||||
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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
@ -516,28 +514,6 @@ ugen20_set_config_index(struct libusb20_device *pdev, uint8_t cfg_index)
|
||||
return (ugen20_tr_renew(pdev));
|
||||
}
|
||||
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user