summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2010-10-14 20:04:36 +0000
committerhselasky <hselasky@FreeBSD.org>2010-10-14 20:04:36 +0000
commitf4157327e68c3d9fca74e7293fbcd5643046fd20 (patch)
treefa43319fefc62e8ee751a4bcef8985b2fdf2f589 /lib
parentdd8752941fd5a0473098812a21b50db6dfd30f32 (diff)
downloadFreeBSD-src-f4157327e68c3d9fca74e7293fbcd5643046fd20.zip
FreeBSD-src-f4157327e68c3d9fca74e7293fbcd5643046fd20.tar.gz
LibUSB (new API):
- Add a new API function to check the connected status of the USB handle in the LibUSB v1.0 and LibUSB v0.1 interfaces. Approved by: thompsa (mentor)
Diffstat (limited to 'lib')
-rw-r--r--lib/libusb/libusb.39
-rw-r--r--lib/libusb/libusb.h1
-rw-r--r--lib/libusb/libusb10.c15
-rw-r--r--lib/libusb/libusb20_compat01.c13
-rw-r--r--lib/libusb/usb.h1
5 files changed, 39 insertions, 0 deletions
diff --git a/lib/libusb/libusb.3 b/lib/libusb/libusb.3
index b7967d5..d54ac73 100644
--- a/lib/libusb/libusb.3
+++ b/lib/libusb/libusb.3
@@ -231,6 +231,14 @@ been disconnected and a LIBUSB_ERROR code on failure.
.Pp
.
.Ft int
+.Fn libusb_check_connected "libusb_device_handle *devh"
+Test if USB device is still connected. Returns 0 on success,
+LIBUSB_ERROR_NO_DEVICE if has been disconnected and a LIBUSB_ERROR
+code on failure.
+.
+.Pp
+.
+.Ft int
.Fn libusb_kernel_driver_active "libusb_device_handle *devh" "int interface"
Determine if a driver is active on a interface. Returns 0 if no kernel driver
is active, returns 1 if a kernel driver is active, returns LIBUSB_ERROR_NO_DEVICE
@@ -488,6 +496,7 @@ The library is also compliant with LibUSB version 0.1.12.
.Fn usb_find_devices
.Fn usb_device
.Fn usb_get_busses
+.Fn usb_check_connected
.
.Sh SEE ALSO
.Xr libusb20 3 ,
diff --git a/lib/libusb/libusb.h b/lib/libusb/libusb.h
index b8e2322..9458316 100644
--- a/lib/libusb/libusb.h
+++ b/lib/libusb/libusb.h
@@ -316,6 +316,7 @@ int libusb_set_configuration(libusb_device_handle * devh, int configuration);
int libusb_claim_interface(libusb_device_handle * devh, int interface_number);
int libusb_release_interface(libusb_device_handle * devh, int interface_number);
int libusb_reset_device(libusb_device_handle * devh);
+int libusb_check_connected(libusb_device_handle * devh);
int libusb_kernel_driver_active(libusb_device_handle * devh, int interface);
int libusb_detach_kernel_driver(libusb_device_handle * devh, int interface);
int libusb_attach_kernel_driver(libusb_device_handle * devh, int interface);
diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c
index a3f0087..7d6c9d9 100644
--- a/lib/libusb/libusb10.c
+++ b/lib/libusb/libusb10.c
@@ -663,6 +663,21 @@ libusb_reset_device(struct libusb20_device *pdev)
}
int
+libusb_check_connected(struct libusb20_device *pdev)
+{
+ libusb_device *dev;
+ int err;
+
+ dev = libusb_get_device(pdev);
+ if (dev == NULL)
+ return (LIBUSB_ERROR_INVALID_PARAM);
+
+ err = libusb20_dev_check_connected(pdev);
+
+ return (err ? LIBUSB_ERROR_NO_DEVICE : 0);
+}
+
+int
libusb_kernel_driver_active(struct libusb20_device *pdev, int interface)
{
if (pdev == NULL)
diff --git a/lib/libusb/libusb20_compat01.c b/lib/libusb/libusb20_compat01.c
index 6f261bf..aaafb02 100644
--- a/lib/libusb/libusb20_compat01.c
+++ b/lib/libusb/libusb20_compat01.c
@@ -795,6 +795,19 @@ usb_reset(usb_dev_handle * dev)
return (usb_close(dev));
}
+int
+usb_check_connected(usb_dev_handle * dev)
+{
+ int err;
+
+ err = libusb20_dev_check_connected((void *)dev);
+
+ if (err)
+ return (-1);
+
+ return (0);
+}
+
const char *
usb_strerror(void)
{
diff --git a/lib/libusb/usb.h b/lib/libusb/usb.h
index a29f48d..8ee68f2 100644
--- a/lib/libusb/usb.h
+++ b/lib/libusb/usb.h
@@ -291,6 +291,7 @@ int usb_set_altinterface(usb_dev_handle * dev, int alternate);
int usb_resetep(usb_dev_handle * dev, unsigned int ep);
int usb_clear_halt(usb_dev_handle * dev, unsigned int ep);
int usb_reset(usb_dev_handle * dev);
+int usb_check_connected(usb_dev_handle * dev);
const char *usb_strerror(void);
void usb_init(void);
void usb_set_debug(int level);
OpenPOWER on IntegriCloud