libusb: implement libusb_wrap_sys_device
The libusb_wrap_sys_device function can wrap an opened fd from the system into a libusb handler. However, in FreeBSD's libusb implementation, a USB device contains two fds: one for control transfers and another for normal (bulk, interrupt, isochronous) transfers. This design makes it impossible for FreeBSD to implement this function without exposing a different structure in libusb.h to provide two fds. Therefore, we return LIBUSB_ERROR_NOT_SUPPORTED to maintain API compatibility. Approved by: makrj (mentor), lwhsu (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D51739
This commit is contained in:
@@ -209,6 +209,14 @@ Decrement the reference counter of the device
|
||||
.Fa dev .
|
||||
.Pp
|
||||
.Ft int
|
||||
.Fn libusb_wrap_sys_device "libusb_context *ctx" "intptr_t sys_dev" "libusb_device_handle **dev_handle"
|
||||
This function creates a libusb handler from a previously opened fd
|
||||
.Fa sys_dev .
|
||||
This function is provided for compatibility and is currently unimplemented.
|
||||
It always returns
|
||||
.Dv LIBUSB_ERROR_NOT_SUPPORTED .
|
||||
.Pp
|
||||
.Ft int
|
||||
.Fn libusb_open "libusb_device *dev" "libusb_device_handle **devh"
|
||||
Open a device and obtain a device_handle.
|
||||
Returns 0 on success,
|
||||
|
||||
@@ -506,6 +506,7 @@ int libusb_get_max_packet_size(libusb_device * dev, uint8_t endpoint);
|
||||
int libusb_get_max_iso_packet_size(libusb_device * dev, uint8_t endpoint);
|
||||
libusb_device *libusb_ref_device(libusb_device * dev);
|
||||
void libusb_unref_device(libusb_device * dev);
|
||||
int libusb_wrap_sys_device(libusb_context *ctx, intptr_t sys_dev, libusb_device_handle **dev_handle);
|
||||
int libusb_open(libusb_device * dev, libusb_device_handle ** devh);
|
||||
libusb_device_handle *libusb_open_device_with_vid_pid(libusb_context * ctx, uint16_t vendor_id, uint16_t product_id);
|
||||
void libusb_close(libusb_device_handle * devh);
|
||||
|
||||
@@ -1918,3 +1918,10 @@ libusb_dev_mem_free(libusb_device_handle *devh, unsigned char *buffer,
|
||||
{
|
||||
return (LIBUSB_ERROR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
int
|
||||
libusb_wrap_sys_device(libusb_context *ctx, intptr_t sys_dev,
|
||||
libusb_device_handle **dev_handle)
|
||||
{
|
||||
return (LIBUSB_ERROR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user