| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: usb_subr.c,v 1.198.2.33 2016/10/07 10:35:25 skrll Exp $ */ | | 1 | /* $NetBSD: usb_subr.c,v 1.198.2.34 2016/10/07 10:37:42 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.33 2016/10/07 10:35:25 skrll Exp $"); | | 35 | __KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.198.2.34 2016/10/07 10:37:42 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> |
| @@ -1543,27 +1543,27 @@ usbd_fill_deviceinfo(struct usbd_device | | | @@ -1543,27 +1543,27 @@ usbd_fill_deviceinfo(struct usbd_device |
1543 | di->udi_devnames[j][0] = 0; /* empty */ | | 1543 | di->udi_devnames[j][0] = 0; /* empty */ |
1544 | | | 1544 | |
1545 | if (!dev->ud_hub) { | | 1545 | if (!dev->ud_hub) { |
1546 | di->udi_nports = 0; | | 1546 | di->udi_nports = 0; |
1547 | return; | | 1547 | return; |
1548 | } | | 1548 | } |
1549 | | | 1549 | |
1550 | const int nports = dev->ud_hub->uh_hubdesc.bNbrPorts; | | 1550 | const int nports = dev->ud_hub->uh_hubdesc.bNbrPorts; |
1551 | for (i = 0; i < __arraycount(di->udi_ports) && i < nports; i++) { | | 1551 | for (i = 0; i < __arraycount(di->udi_ports) && i < nports; i++) { |
1552 | p = &dev->ud_hub->uh_ports[i]; | | 1552 | p = &dev->ud_hub->uh_ports[i]; |
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 | const int s = UGETW(p->up_status.wPortStatus); |
1557 | const bool sshub_p = USB_IS_SS(dev->ud_speed); | | 1557 | const bool sshub_p = USB_IS_SS(dev->ud_speed); |
1558 | if (s & UPS_PORT_ENABLED) | | 1558 | if (s & UPS_PORT_ENABLED) |
1559 | err = USB_PORT_ENABLED; | | 1559 | err = USB_PORT_ENABLED; |
1560 | else if (s & UPS_SUSPEND) | | 1560 | else if (s & UPS_SUSPEND) |
1561 | err = USB_PORT_SUSPENDED; | | 1561 | err = USB_PORT_SUSPENDED; |
1562 | /* | | 1562 | /* |
1563 | * Note: UPS_PORT_POWER_SS is available only | | 1563 | * Note: UPS_PORT_POWER_SS is available only |
1564 | * on 3.x, and UPS_PORT_POWER is available | | 1564 | * on 3.x, and UPS_PORT_POWER is available |
1565 | * only on 2.0 or 1.1. | | 1565 | * only on 2.0 or 1.1. |
1566 | */ | | 1566 | */ |
1567 | else if (sshub_p && (s & UPS_PORT_POWER_SS)) | | 1567 | else if (sshub_p && (s & UPS_PORT_POWER_SS)) |
1568 | err = USB_PORT_POWERED; | | 1568 | err = USB_PORT_POWERED; |
1569 | else if (!sshub_p && (s & UPS_PORT_POWER)) | | 1569 | else if (!sshub_p && (s & UPS_PORT_POWER)) |
| @@ -1619,27 +1619,27 @@ usbd_fill_deviceinfo_old(struct usbd_dev | | | @@ -1619,27 +1619,27 @@ usbd_fill_deviceinfo_old(struct usbd_dev |
1619 | | | 1619 | |
1620 | if (!dev->ud_hub) { | | 1620 | if (!dev->ud_hub) { |
1621 | di->udi_nports = 0; | | 1621 | di->udi_nports = 0; |
1622 | return; | | 1622 | return; |
1623 | } | | 1623 | } |
1624 | | | 1624 | |
1625 | const int nports = dev->ud_hub->uh_hubdesc.bNbrPorts; | | 1625 | const int nports = dev->ud_hub->uh_hubdesc.bNbrPorts; |
1626 | for (i = 0; i < __arraycount(di->udi_ports) && i < nports; | | 1626 | for (i = 0; i < __arraycount(di->udi_ports) && i < nports; |
1627 | i++) { | | 1627 | i++) { |
1628 | p = &dev->ud_hub->uh_ports[i]; | | 1628 | p = &dev->ud_hub->uh_ports[i]; |
1629 | if (p->up_dev) | | 1629 | if (p->up_dev) |
1630 | err = p->up_dev->ud_addr; | | 1630 | err = p->up_dev->ud_addr; |
1631 | else { | | 1631 | else { |
1632 | int s = UGETW(p->up_status.wPortStatus); | | 1632 | const int s = UGETW(p->up_status.wPortStatus); |
1633 | if (s & UPS_PORT_ENABLED) | | 1633 | if (s & UPS_PORT_ENABLED) |
1634 | err = USB_PORT_ENABLED; | | 1634 | err = USB_PORT_ENABLED; |
1635 | else if (s & UPS_SUSPEND) | | 1635 | else if (s & UPS_SUSPEND) |
1636 | err = USB_PORT_SUSPENDED; | | 1636 | err = USB_PORT_SUSPENDED; |
1637 | else if (s & UPS_PORT_POWER) | | 1637 | else if (s & UPS_PORT_POWER) |
1638 | err = USB_PORT_POWERED; | | 1638 | err = USB_PORT_POWERED; |
1639 | else | | 1639 | else |
1640 | err = USB_PORT_DISABLED; | | 1640 | err = USB_PORT_DISABLED; |
1641 | } | | 1641 | } |
1642 | di->udi_ports[i] = err; | | 1642 | di->udi_ports[i] = err; |
1643 | } | | 1643 | } |
1644 | di->udi_nports = nports; | | 1644 | di->udi_nports = nports; |
1645 | } | | 1645 | } |