diff options
author | Hans Petter Selasky <hselasky@FreeBSD.org> | 2013-02-14 12:22:40 +0000 |
---|---|---|
committer | Hans Petter Selasky <hselasky@FreeBSD.org> | 2013-02-14 12:22:40 +0000 |
commit | aafcb7320759529843b0d0efa3c6a918aa1aaa50 (patch) | |
tree | a0b0c710f98a991d5594c3cd1efed27bd508c825 /sys/dev | |
parent | 0af99eef9e4d3c463ece2da2342499cd5b55b8ab (diff) | |
download | src-aafcb7320759529843b0d0efa3c6a918aa1aaa50.tar.gz src-aafcb7320759529843b0d0efa3c6a918aa1aaa50.zip |
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
Notes
Notes:
svn path=/head/; revision=246789
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/usb/usb_generic.c | 15 | ||||
-rw-r--r-- | sys/dev/usb/usb_ioctl.h | 3 |
2 files changed, 17 insertions, 1 deletions
diff --git a/sys/dev/usb/usb_generic.c b/sys/dev/usb/usb_generic.c index 34b7778e1f17..9557686e9416 100644 --- a/sys/dev/usb/usb_generic.c +++ b/sys/dev/usb/usb_generic.c @@ -1841,6 +1841,17 @@ ugen_get_power_mode(struct usb_fifo *f) } static int +ugen_get_power_usage(struct usb_fifo *f) +{ + struct usb_device *udev = f->udev; + + if (udev == NULL) + return (0); + + return (udev->power); +} + +static int ugen_do_port_feature(struct usb_fifo *f, uint8_t port_no, uint8_t set, uint16_t feature) { @@ -2202,6 +2213,10 @@ ugen_ioctl_post(struct usb_fifo *f, u_long cmd, void *addr, int fflags) *u.pint = ugen_get_power_mode(f); break; + case USB_GET_POWER_USAGE: + *u.pint = ugen_get_power_usage(f); + break; + case USB_SET_PORT_ENABLE: error = ugen_do_port_feature(f, *u.pint, 1, UHF_PORT_ENABLE); diff --git a/sys/dev/usb/usb_ioctl.h b/sys/dev/usb/usb_ioctl.h index 1d9b2230d059..979240f05734 100644 --- a/sys/dev/usb/usb_ioctl.h +++ b/sys/dev/usb/usb_ioctl.h @@ -277,7 +277,8 @@ struct usb_gen_quirk { #define USB_IFACE_DRIVER_DETACH _IOW ('U', 125, int) #define USB_GET_PLUGTIME _IOR ('U', 126, uint32_t) #define USB_READ_DIR _IOW ('U', 127, struct usb_read_dir) -/* 128 - 135 unused */ +/* 128 - 134 unused */ +#define USB_GET_POWER_USAGE _IOR ('U', 135, int) #define USB_SET_TX_FORCE_SHORT _IOW ('U', 136, int) #define USB_SET_TX_TIMEOUT _IOW ('U', 137, int) #define USB_GET_TX_FRAME_SIZE _IOR ('U', 138, int) |