summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMarcus Glocker <mglocker@cvs.openbsd.org>2013-04-17 11:53:11 +0000
committerMarcus Glocker <mglocker@cvs.openbsd.org>2013-04-17 11:53:11 +0000
commite59d65e0f42e37c54151166956798f9c6d004bbe (patch)
tree315f8658e814cdb3f1df8cdbba417357e4b5afe2 /sys/dev
parent2ce0060119199186f806c91f69788c868f46539f (diff)
Add new ioctl command USB_DEVICE_GET_DDESC to usb(4) to retrieve the
device descriptor. Help and ok mpi@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/usb/usb.c21
-rw-r--r--sys/dev/usb/usb.h9
2 files changed, 28 insertions, 2 deletions
diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c
index b3bf1440a09..ca67a997c2f 100644
--- a/sys/dev/usb/usb.c
+++ b/sys/dev/usb/usb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb.c,v 1.86 2013/04/15 09:23:02 mglocker Exp $ */
+/* $OpenBSD: usb.c,v 1.87 2013/04/17 11:53:10 mglocker Exp $ */
/* $NetBSD: usb.c,v 1.77 2003/01/01 00:10:26 thorpej Exp $ */
/*
@@ -679,6 +679,25 @@ usbioctl(dev_t devt, u_long cmd, caddr_t data, int flag, struct proc *p)
*(struct usb_device_stats *)data = sc->sc_bus->stats;
break;
+ case USB_DEVICE_GET_DDESC:
+ {
+ struct usb_device_ddesc *udd = (struct usb_device_ddesc *)data;
+ int addr = udd->udd_addr;
+ struct usbd_device *dev;
+
+ if (addr < 1 || addr >= USB_MAX_DEVICES)
+ return (EINVAL);
+
+ dev = sc->sc_bus->devices[addr];
+ if (dev == NULL)
+ return (ENXIO);
+
+ udd->udd_bus = unit;
+
+ udd->udd_desc = *usbd_get_device_descriptor(dev);
+ break;
+ }
+
case USB_DEVICE_GET_CDESC:
{
struct usb_device_cdesc *udc = (struct usb_device_cdesc *)data;
diff --git a/sys/dev/usb/usb.h b/sys/dev/usb/usb.h
index a889553c302..bc37a1afda7 100644
--- a/sys/dev/usb/usb.h
+++ b/sys/dev/usb/usb.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb.h,v 1.43 2013/04/08 10:34:20 mglocker Exp $ */
+/* $OpenBSD: usb.h,v 1.44 2013/04/17 11:53:10 mglocker Exp $ */
/* $NetBSD: usb.h,v 1.69 2002/09/22 23:20:50 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb.h,v 1.14 1999/11/17 22:33:46 n_hibma Exp $ */
@@ -596,6 +596,12 @@ struct usb_device_fdesc {
u_char *udf_data;
};
+struct usb_device_ddesc {
+ u_int8_t udd_bus;
+ u_int8_t udd_addr; /* device address */
+ usb_device_descriptor_t udd_desc;
+};
+
struct usb_string_desc {
int usd_string_index;
int usd_language_id;
@@ -654,6 +660,7 @@ struct usb_device_stats {
#define USB_DEVICESTATS _IOR ('U', 5, struct usb_device_stats)
#define USB_DEVICE_GET_CDESC _IOWR('U', 6, struct usb_device_cdesc)
#define USB_DEVICE_GET_FDESC _IOWR('U', 7, struct usb_device_fdesc)
+#define USB_DEVICE_GET_DDESC _IOWR('U', 8, struct usb_device_ddesc)
/* Generic HID device */
#define USB_GET_REPORT_DESC _IOR ('U', 21, struct usb_ctl_report_desc)