summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2018-07-10 09:17:04 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2018-07-10 09:17:04 +0000
commitda61dd5754518c621af9372db3802e9f4a1a6c52 (patch)
tree101a1a4c1b0844b9b33c8b90a4e4cd010b775d7e /sys
parent97c750c8ac7f11958ff9231a3edf8d3e7da953f5 (diff)
Change USB_DEVICEINFO to report USB port status/changes as currently
seen by the stack. This will allows us to debug port status changes without relying on external tools, like lsusb(1), that generate I/O. While here correct USB3 LS port defines.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/usb/usb.h33
-rw-r--r--sys/dev/usb/usb_subr.c20
2 files changed, 19 insertions, 34 deletions
diff --git a/sys/dev/usb/usb.h b/sys/dev/usb/usb.h
index 8194db9d73b..619bac8cb01 100644
--- a/sys/dev/usb/usb.h
+++ b/sys/dev/usb/usb.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb.h,v 1.59 2017/09/01 16:38:14 stsp Exp $ */
+/* $OpenBSD: usb.h,v 1.60 2018/07/10 09:17:03 mpi 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 $ */
@@ -442,18 +442,19 @@ struct usb_port_status {
#define UPS_PORT_L1 0x0020 /* USB 2.0 only */
/* Super-Speed port link state values. */
-#define UPS_PORT_LS_U0 0x0000
-#define UPS_PORT_LS_U1 0x0020
-#define UPS_PORT_LS_U2 0x0040
-#define UPS_PORT_LS_U3 0x0060
-#define UPS_PORT_LS_SS_DISABLED 0x0080
-#define UPS_PORT_LS_RX_DETECT 0x00a0
-#define UPS_PORT_LS_SS_INACTIVE 0x00c0
-#define UPS_PORT_LS_POLLING 0x00e0
-#define UPS_PORT_LS_RECOVERY 0x0100
-#define UPS_PORT_LS_HOT_RESET 0x0120
-#define UPS_PORT_LS_COMP_MOD 0x0140
-#define UPS_PORT_LS_LOOPBACK 0x0160
+#define UPS_PORT_LS_U0 0x00
+#define UPS_PORT_LS_U1 0x01
+#define UPS_PORT_LS_U2 0x02
+#define UPS_PORT_LS_U3 0x03
+#define UPS_PORT_LS_SS_DISABLED 0x04
+#define UPS_PORT_LS_RX_DETECT 0x05
+#define UPS_PORT_LS_SS_INACTIVE 0x06
+#define UPS_PORT_LS_POLLING 0x07
+#define UPS_PORT_LS_RECOVERY 0x08
+#define UPS_PORT_LS_HOT_RESET 0x09
+#define UPS_PORT_LS_COMP_MOD 0x0a
+#define UPS_PORT_LS_LOOPBACK 0x0b
+#define UPS_PORT_LS_RESUME 0x0f
#define UPS_PORT_LS_GET(x) (((x) >> 5) & 0xf)
#define UPS_PORT_LS_SET(x) (((x) & 0xf) << 5)
@@ -739,11 +740,7 @@ struct usb_device_info {
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 */
-#define USB_PORT_ENABLED 0xff
-#define USB_PORT_SUSPENDED 0xfe
-#define USB_PORT_POWERED 0xfd
-#define USB_PORT_DISABLED 0xfc
+ u_int32_t udi_ports[16]; /* hub only: ports status/change */
char udi_serial[USB_MAX_STRING_LEN];
};
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c
index 67ab10ff312..6fc14ed93a7 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.136 2018/05/01 18:14:46 landry Exp $ */
+/* $OpenBSD: usb_subr.c,v 1.137 2018/07/10 09:17:03 mpi 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 $ */
@@ -1304,7 +1304,7 @@ void
usbd_fill_deviceinfo(struct usbd_device *dev, struct usb_device_info *di)
{
struct usbd_port *p;
- int i, err, s;
+ int i;
di->udi_bus = dev->bus->usbctl->dv_unit;
di->udi_addr = dev->address;
@@ -1338,20 +1338,8 @@ usbd_fill_deviceinfo(struct usbd_device *dev, struct usb_device_info *di)
for (i = 0;
i < nitems(di->udi_ports) && i < dev->hub->nports; i++) {
p = &dev->hub->ports[i];
- if (p->device)
- err = p->device->address;
- else {
- s = UGETW(p->status.wPortStatus);
- if (s & UPS_PORT_ENABLED)
- err = USB_PORT_ENABLED;
- else if (s & UPS_SUSPEND)
- err = USB_PORT_SUSPENDED;
- else if (s & UPS_PORT_POWER)
- err = USB_PORT_POWERED;
- else
- err = USB_PORT_DISABLED;
- }
- di->udi_ports[i] = err;
+ di->udi_ports[i] = UGETW(p->status.wPortChange) << 16 |
+ UGETW(p->status.wPortStatus);
}
di->udi_nports = dev->hub->nports;
} else