summaryrefslogtreecommitdiff
path: root/sys/dev/usb
diff options
context:
space:
mode:
authorJacob Meuser <jakemsr@cvs.openbsd.org>2011-01-15 23:58:44 +0000
committerJacob Meuser <jakemsr@cvs.openbsd.org>2011-01-15 23:58:44 +0000
commite49c859ef8128657cabedb4c878ba7f810bc43ba (patch)
tree6676ad3a46f22401bf1c805bb95a62a12ea1bb29 /sys/dev/usb
parent1107d63076ec520054de914099e92a43313b1e37 (diff)
* add 'udi_serial' to struct usb_device_info.
* fill 'udi_serial' with the serial number in usbd_fill_deviceinfo(). * add compatability ioctl/struct so old binaries continue to work. discussed with deraadt and miod
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/usb.c22
-rw-r--r--sys/dev/usb/usb.h26
-rw-r--r--sys/dev/usb/usb_subr.c6
3 files changed, 51 insertions, 3 deletions
diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c
index 6207c070266..f6ba1f2a168 100644
--- a/sys/dev/usb/usb.c
+++ b/sys/dev/usb/usb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb.c,v 1.70 2010/12/06 04:28:41 jakemsr Exp $ */
+/* $OpenBSD: usb.c,v 1.71 2011/01/15 23:58:43 jakemsr Exp $ */
/* $NetBSD: usb.c,v 1.77 2003/01/01 00:10:26 thorpej Exp $ */
/*
@@ -687,6 +687,26 @@ usbioctl(dev_t devt, u_long cmd, caddr_t data, int flag, struct proc *p)
break;
}
+ case USB_DEVICEINFO_48:
+ {
+ struct usb_device_info_48 *di_48 = (void *)data;
+ struct usb_device_info di_tmp;
+ int addr = di_48->udi_addr;
+ usbd_device_handle dev;
+
+ if (addr < 1 || addr >= USB_MAX_DEVICES)
+ return (EINVAL);
+ dev = sc->sc_bus->devices[addr];
+ if (dev == NULL)
+ return (ENXIO);
+
+ bzero(&di_tmp, sizeof(struct usb_device_info));
+ bcopy(di_48, &di_tmp, sizeof(struct usb_device_info_48));
+ usbd_fill_deviceinfo(dev, &di_tmp, 1);
+ bcopy(&di_tmp, di_48, sizeof(struct usb_device_info_48));
+ break;
+ }
+
case USB_DEVICESTATS:
*(struct usb_device_stats *)data = sc->sc_bus->stats;
break;
diff --git a/sys/dev/usb/usb.h b/sys/dev/usb/usb.h
index c2131b20ca3..d8ed1dcfa1f 100644
--- a/sys/dev/usb/usb.h
+++ b/sys/dev/usb/usb.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb.h,v 1.35 2010/03/01 23:35:56 mk Exp $ */
+/* $OpenBSD: usb.h,v 1.36 2011/01/15 23:58:43 jakemsr 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 $ */
@@ -617,6 +617,29 @@ struct usb_device_info {
#define USB_PORT_SUSPENDED 0xfe
#define USB_PORT_POWERED 0xfd
#define USB_PORT_DISABLED 0xfc
+ char udi_serial[USB_MAX_STRING_LEN];
+};
+
+/* OpenBSD <= 4.8 version, to be removed eventually */
+struct usb_device_info_48 {
+ u_int8_t udi_bus;
+ u_int8_t udi_addr; /* device address */
+ usb_event_cookie_t udi_cookie;
+ char udi_product[USB_MAX_STRING_LEN];
+ char udi_vendor[USB_MAX_STRING_LEN];
+ char udi_release[8];
+ u_int16_t udi_productNo;
+ u_int16_t udi_vendorNo;
+ u_int16_t udi_releaseNo;
+ u_int8_t udi_class;
+ u_int8_t udi_subclass;
+ u_int8_t udi_protocol;
+ u_int8_t udi_config;
+ u_int8_t udi_speed;
+ int udi_power; /* power consumption in mA, 0 if selfpowered */
+ int udi_nports;
+ char udi_devnames[USB_MAX_DEVNAMES][USB_MAX_DEVNAMELEN];
+ u_int8_t udi_ports[16];/* hub only: addresses of devices on ports */
};
struct usb_ctl_report {
@@ -657,6 +680,7 @@ struct usb_event {
#define USB_SETDEBUG _IOW ('U', 2, unsigned int)
#define USB_DISCOVER _IO ('U', 3)
#define USB_DEVICEINFO _IOWR('U', 4, struct usb_device_info)
+#define USB_DEVICEINFO_48 _IOWR('U', 4, struct usb_device_info_48)
#define USB_DEVICESTATS _IOR ('U', 5, struct usb_device_stats)
/* Generic HID device */
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c
index d67b43ee4da..498c579b4db 100644
--- a/sys/dev/usb/usb_subr.c
+++ b/sys/dev/usb/usb_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb_subr.c,v 1.77 2010/12/17 22:38:54 jasper Exp $ */
+/* $OpenBSD: usb_subr.c,v 1.78 2011/01/15 23:58:43 jakemsr Exp $ */
/* $NetBSD: usb_subr.c,v 1.103 2003/01/10 11:19:13 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */
@@ -1402,6 +1402,10 @@ usbd_fill_deviceinfo(usbd_device_handle dev, struct usb_device_info *di,
di->udi_nports = dev->hub->hubdesc.bNbrPorts;
} else
di->udi_nports = 0;
+
+ bzero(di->udi_serial, sizeof(di->udi_serial));
+ usbd_get_string(dev, dev->ddesc.iSerialNumber, di->udi_serial,
+ sizeof(di->udi_serial));
}
void