Fri Oct 7 10:32:49 2016 UTC ()
Make the code match the comment wrt port powered status


(skrll)
diff -r1.198.2.31 -r1.198.2.32 src/sys/dev/usb/usb_subr.c

cvs diff -r1.198.2.31 -r1.198.2.32 src/sys/dev/usb/usb_subr.c (expand / switch to unified diff)

--- src/sys/dev/usb/usb_subr.c 2016/10/05 20:55:57 1.198.2.31
+++ src/sys/dev/usb/usb_subr.c 2016/10/07 10:32:49 1.198.2.32
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: usb_subr.c,v 1.198.2.31 2016/10/05 20:55:57 skrll Exp $ */ 1/* $NetBSD: usb_subr.c,v 1.198.2.32 2016/10/07 10:32:49 skrll Exp $ */
2/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ 2/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. 5 * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to The NetBSD Foundation 8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Lennart Augustsson (lennart@augustsson.net) at 9 * by Lennart Augustsson (lennart@augustsson.net) at
10 * Carlstedt Research & Technology. 10 * Carlstedt Research & Technology.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE. 31 * POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.198.2.31 2016/10/05 20:55:57 skrll Exp $"); 35__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.198.2.32 2016/10/07 10:32:49 skrll Exp $");
36 36
37#ifdef _KERNEL_OPT 37#ifdef _KERNEL_OPT
38#include "opt_compat_netbsd.h" 38#include "opt_compat_netbsd.h"
39#include "opt_usb.h" 39#include "opt_usb.h"
40#include "opt_usbverbose.h" 40#include "opt_usbverbose.h"
41#endif 41#endif
42 42
43#include <sys/param.h> 43#include <sys/param.h>
44#include <sys/systm.h> 44#include <sys/systm.h>
45#include <sys/kernel.h> 45#include <sys/kernel.h>
46#include <sys/kmem.h> 46#include <sys/kmem.h>
47#include <sys/device.h> 47#include <sys/device.h>
48#include <sys/select.h> 48#include <sys/select.h>
@@ -1553,30 +1553,29 @@ usbd_fill_deviceinfo(struct usbd_device  @@ -1553,30 +1553,29 @@ usbd_fill_deviceinfo(struct usbd_device
1553 if (p->up_dev) 1553 if (p->up_dev)
1554 err = p->up_dev->ud_addr; 1554 err = p->up_dev->ud_addr;
1555 else { 1555 else {
1556 int s = UGETW(p->up_status.wPortStatus); 1556 int s = UGETW(p->up_status.wPortStatus);
1557 if (s & UPS_PORT_ENABLED) 1557 if (s & UPS_PORT_ENABLED)
1558 err = USB_PORT_ENABLED; 1558 err = USB_PORT_ENABLED;
1559 else if (s & UPS_SUSPEND) 1559 else if (s & UPS_SUSPEND)
1560 err = USB_PORT_SUSPENDED; 1560 err = USB_PORT_SUSPENDED;
1561 /* 1561 /*
1562 * Note: UPS_PORT_POWER_SS is available only 1562 * Note: UPS_PORT_POWER_SS is available only
1563 * on 3.x, and UPS_PORT_POWER is available 1563 * on 3.x, and UPS_PORT_POWER is available
1564 * only on 2.0 or 1.1. 1564 * only on 2.0 or 1.1.
1565 */ 1565 */
1566 else if (USB_IS_SS(dev->ud_speed) && 1566 else if (sshub_p && (s & UPS_PORT_POWER_SS))
1567 (s & UPS_PORT_POWER_SS)) 
1568 err = USB_PORT_POWERED; 1567 err = USB_PORT_POWERED;
1569 else if (s & UPS_PORT_POWER) 1568 else if (!sshub_p && (s & UPS_PORT_POWER))
1570 err = USB_PORT_POWERED; 1569 err = USB_PORT_POWERED;
1571 else 1570 else
1572 err = USB_PORT_DISABLED; 1571 err = USB_PORT_DISABLED;
1573 } 1572 }
1574 di->udi_ports[i] = err; 1573 di->udi_ports[i] = err;
1575 } 1574 }
1576 di->udi_nports = nports; 1575 di->udi_nports = nports;
1577} 1576}
1578 1577
1579#ifdef COMPAT_30 1578#ifdef COMPAT_30
1580void 1579void
1581usbd_fill_deviceinfo_old(struct usbd_device *dev, struct usb_device_info_old *di, 1580usbd_fill_deviceinfo_old(struct usbd_device *dev, struct usb_device_info_old *di,
1582 int usedev) 1581 int usedev)