Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Bail out early from usbd_fill_devinfo if we're n...
details: https://anonhg.NetBSD.org/src/rev/169247eb2e3f
branches: trunk
changeset: 817701:169247eb2e3f
user: skrll <skrll%NetBSD.org@localhost>
date: Sat Sep 03 07:20:12 2016 +0000
description:
Bail out early from usbd_fill_devinfo if we're not a hub to use less
indentation in the code.
No functional change. Same code before and after.
diffstat:
sys/dev/usb/usb_subr.c | 115 +++++++++++++++++++++++++-----------------------
1 files changed, 59 insertions(+), 56 deletions(-)
diffs (145 lines):
diff -r ea78ca3d4828 -r 169247eb2e3f sys/dev/usb/usb_subr.c
--- a/sys/dev/usb/usb_subr.c Sat Sep 03 07:14:19 2016 +0000
+++ b/sys/dev/usb/usb_subr.c Sat Sep 03 07:20:12 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usb_subr.c,v 1.212 2016/09/03 07:14:19 skrll Exp $ */
+/* $NetBSD: usb_subr.c,v 1.213 2016/09/03 07:20:12 skrll Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */
/*
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.212 2016/09/03 07:14:19 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.213 2016/09/03 07:20:12 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -1540,38 +1540,40 @@
for (/* j is set */; j < USB_MAX_DEVNAMES; j++)
di->udi_devnames[j][0] = 0; /* empty */
- if (dev->ud_hub) {
- for (i = 0;
- i < __arraycount(di->udi_ports) &&
- i < dev->ud_hub->uh_hubdesc.bNbrPorts;
- i++) {
- p = &dev->ud_hub->uh_ports[i];
- if (p->up_dev)
- err = p->up_dev->ud_addr;
- else {
- s = UGETW(p->up_status.wPortStatus);
- if (s & UPS_PORT_ENABLED)
- err = USB_PORT_ENABLED;
- else if (s & UPS_SUSPEND)
- err = USB_PORT_SUSPENDED;
- /*
- * Note: UPS_PORT_POWER_SS is available only
- * on 3.x, and UPS_PORT_POWER is available
- * only on 2.0 or 1.1.
- */
- else if (USB_IS_SS(dev->ud_speed) &&
- (s & UPS_PORT_POWER_SS))
- err = USB_PORT_POWERED;
- else if (s & UPS_PORT_POWER)
- err = USB_PORT_POWERED;
- else
- err = USB_PORT_DISABLED;
- }
- di->udi_ports[i] = err;
+ if (!dev->ud_hub) {
+ di->udi_nports = 0;
+ return;
+ }
+
+ for (i = 0;
+ i < __arraycount(di->udi_ports) &&
+ i < dev->ud_hub->uh_hubdesc.bNbrPorts;
+ i++) {
+ p = &dev->ud_hub->uh_ports[i];
+ if (p->up_dev)
+ err = p->up_dev->ud_addr;
+ else {
+ s = UGETW(p->up_status.wPortStatus);
+ if (s & UPS_PORT_ENABLED)
+ err = USB_PORT_ENABLED;
+ else if (s & UPS_SUSPEND)
+ err = USB_PORT_SUSPENDED;
+ /*
+ * Note: UPS_PORT_POWER_SS is available only
+ * on 3.x, and UPS_PORT_POWER is available
+ * only on 2.0 or 1.1.
+ */
+ else if (USB_IS_SS(dev->ud_speed) &&
+ (s & UPS_PORT_POWER_SS))
+ err = USB_PORT_POWERED;
+ else if (s & UPS_PORT_POWER)
+ err = USB_PORT_POWERED;
+ else
+ err = USB_PORT_DISABLED;
}
- di->udi_nports = dev->ud_hub->uh_hubdesc.bNbrPorts;
- } else
- di->udi_nports = 0;
+ di->udi_ports[i] = err;
+ }
+ di->udi_nports = dev->ud_hub->uh_hubdesc.bNbrPorts;
}
#ifdef COMPAT_30
@@ -1615,30 +1617,31 @@
for (/* j is set */; j < USB_MAX_DEVNAMES; j++)
di->udi_devnames[j][0] = 0; /* empty */
- if (dev->ud_hub) {
- for (i = 0;
- i < __arraycount(di->udi_ports) &&
- i < dev->ud_hub->uh_hubdesc.bNbrPorts;
- i++) {
- p = &dev->ud_hub->uh_ports[i];
- if (p->up_dev)
- err = p->up_dev->ud_addr;
- else {
- s = UGETW(p->up_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;
+ if (!dev->ud_hub) {
+ di->udi_nports = 0;
+ return;
+ }
+ for (i = 0;
+ i < __arraycount(di->udi_ports) &&
+ i < dev->ud_hub->uh_hubdesc.bNbrPorts;
+ i++) {
+ p = &dev->ud_hub->uh_ports[i];
+ if (p->up_dev)
+ err = p->up_dev->ud_addr;
+ else {
+ s = UGETW(p->up_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_nports = dev->ud_hub->uh_hubdesc.bNbrPorts;
- } else
- di->udi_nports = 0;
+ di->udi_ports[i] = err;
+ }
+ di->udi_nports = dev->ud_hub->uh_hubdesc.bNbrPorts;
}
#endif
Home |
Main Index |
Thread Index |
Old Index