diff options
author | hselasky <hselasky@FreeBSD.org> | 2013-02-14 12:22:40 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2013-02-14 12:22:40 +0000 |
commit | d7b1840a86d06ec4dc5506a5063682c00642dadf (patch) | |
tree | a0b0c710f98a991d5594c3cd1efed27bd508c825 /lib/libusb/libusb20_ugen20.c | |
parent | af9a6b59013c48aa503513ce55d93fe84817996a (diff) | |
download | FreeBSD-src-d7b1840a86d06ec4dc5506a5063682c00642dadf.zip FreeBSD-src-d7b1840a86d06ec4dc5506a5063682c00642dadf.tar.gz |
Add USB API to read power draw on USB devices.
Update usbconfig to print power draw on USB devices.
MFC after: 2 weeks
Submitted by: Matt Burke @ icritical.com
Diffstat (limited to 'lib/libusb/libusb20_ugen20.c')
-rw-r--r-- | lib/libusb/libusb20_ugen20.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/libusb/libusb20_ugen20.c b/lib/libusb/libusb20_ugen20.c index 2c67778..bff8e02 100644 --- a/lib/libusb/libusb20_ugen20.c +++ b/lib/libusb/libusb20_ugen20.c @@ -69,6 +69,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_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; static libusb20_do_request_sync_t ugen20_do_request_sync; @@ -639,6 +640,18 @@ ugen20_get_power_mode(struct libusb20_device *pdev, uint8_t *power_mode) } static int +ugen20_get_power_usage(struct libusb20_device *pdev, uint16_t *power_usage) +{ + int temp; + + if (ioctl(pdev->file_ctrl, USB_GET_POWER_USAGE, &temp)) { + return (LIBUSB20_ERROR_OTHER); + } + *power_usage = temp; + return (0); /* success */ +} + +static int ugen20_kernel_driver_active(struct libusb20_device *pdev, uint8_t iface_index) { |