aboutsummaryrefslogtreecommitdiff
path: root/lib/libusb/libusb20_ugen20.c
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2013-05-03 07:44:58 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2013-05-03 07:44:58 +0000
commitc77a24c24a844f32150345c9967c026a5a50da4c (patch)
treebae81f1e85342c7dae2df723f345aafb486ea339 /lib/libusb/libusb20_ugen20.c
parent3b48e348d5c2e70f071a75e37edac8c5eba8d478 (diff)
downloadsrc-c77a24c24a844f32150345c9967c026a5a50da4c.tar.gz
src-c77a24c24a844f32150345c9967c026a5a50da4c.zip
Add new USB API to get the port path of a USB device.
MFC after: 2 weeks Requested by: emaste @
Notes
Notes: svn path=/head/; revision=250201
Diffstat (limited to 'lib/libusb/libusb20_ugen20.c')
-rw-r--r--lib/libusb/libusb20_ugen20.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/libusb/libusb20_ugen20.c b/lib/libusb/libusb20_ugen20.c
index 0846eb4b7d52..a4c973e10725 100644
--- a/lib/libusb/libusb20_ugen20.c
+++ b/lib/libusb/libusb20_ugen20.c
@@ -73,6 +73,7 @@ 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_get_port_path_t ugen20_get_port_path;
static libusb20_get_power_usage_t ugen20_get_power_usage;
static libusb20_kernel_driver_active_t ugen20_kernel_driver_active;
static libusb20_detach_kernel_driver_t ugen20_detach_kernel_driver;
@@ -644,6 +645,22 @@ ugen20_get_power_mode(struct libusb20_device *pdev, uint8_t *power_mode)
}
static int
+ugen20_get_port_path(struct libusb20_device *pdev, uint8_t *buf, uint8_t bufsize)
+{
+ struct usb_device_port_path udpp;
+
+ if (ioctl(pdev->file_ctrl, USB_GET_DEV_PORT_PATH, &udpp))
+ return (LIBUSB20_ERROR_OTHER);
+
+ if (udpp.udp_port_level > bufsize)
+ return (LIBUSB20_ERROR_OVERFLOW);
+
+ memcpy(buf, udpp.udp_port_no, udpp.udp_port_level);
+
+ return (udpp.udp_port_level); /* success */
+}
+
+static int
ugen20_get_power_usage(struct libusb20_device *pdev, uint16_t *power_usage)
{
int temp;