aboutsummaryrefslogtreecommitdiff
path: root/lib/libusb/libusb20_ugen20.c
diff options
context:
space:
mode:
authorAndrew Thompson <thompsa@FreeBSD.org>2010-01-29 02:44:06 +0000
committerAndrew Thompson <thompsa@FreeBSD.org>2010-01-29 02:44:06 +0000
commite50ac68b3dc725aa4b428d2446bb58fe4f5c288c (patch)
tree2391978b0a29215f8e39ca3810313d7efcd63dca /lib/libusb/libusb20_ugen20.c
parent2155c5d81467f646691a8188dd0f0fc3764b2ad2 (diff)
downloadsrc-e50ac68b3dc725aa4b428d2446bb58fe4f5c288c.tar.gz
src-e50ac68b3dc725aa4b428d2446bb58fe4f5c288c.zip
Add a function to check if the usb devices is still connected.
Submitted by: Hans Petter Selasky
Notes
Notes: svn path=/head/; revision=203147
Diffstat (limited to 'lib/libusb/libusb20_ugen20.c')
-rw-r--r--lib/libusb/libusb20_ugen20.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/libusb/libusb20_ugen20.c b/lib/libusb/libusb20_ugen20.c
index efcca63a2095..892ba0eb78aa 100644
--- a/lib/libusb/libusb20_ugen20.c
+++ b/lib/libusb/libusb20_ugen20.c
@@ -67,6 +67,7 @@ static libusb20_get_config_index_t ugen20_get_config_index;
static libusb20_set_config_index_t ugen20_set_config_index;
static libusb20_set_alt_index_t ugen20_set_alt_index;
static libusb20_reset_device_t ugen20_reset_device;
+static libusb20_check_connected_t ugen20_check_connected;
static libusb20_set_power_mode_t ugen20_set_power_mode;
static libusb20_get_power_mode_t ugen20_get_power_mode;
static libusb20_kernel_driver_active_t ugen20_kernel_driver_active;
@@ -553,6 +554,25 @@ ugen20_reset_device(struct libusb20_device *pdev)
}
static int
+ugen20_check_connected(struct libusb20_device *pdev)
+{
+ uint32_t plugtime;
+ int error = 0;
+
+ if (ioctl(pdev->file_ctrl, USB_GET_PLUGTIME, &plugtime)) {
+ error = LIBUSB20_ERROR_NO_DEVICE;
+ goto done;
+ }
+
+ if (pdev->session_data.plugtime != plugtime) {
+ error = LIBUSB20_ERROR_NO_DEVICE;
+ goto done;
+ }
+done:
+ return (error);
+}
+
+static int
ugen20_set_power_mode(struct libusb20_device *pdev, uint8_t power_mode)
{
int temp;