diff options
| author | skrll <skrll@NetBSD.org> | 2016-05-06 10:24:06 +0000 |
|---|---|---|
| committer | skrll <skrll@NetBSD.org> | 2016-05-06 10:24:06 +0000 |
| commit | 609fc089a0613c5958ace8b1108d6401adb73b44 (patch) | |
| tree | 41bafed7e918c15e5869a2469a99b80a7444c883 /sys/dev | |
| parent | 1cc9f17160751094eafb53010d15d8769da0b292 (diff) | |
Remove magic numbers from xhci_hc_reset. From t-hash.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/usb/xhci.c | 16 | ||||
| -rw-r--r-- | sys/dev/usb/xhcireg.h | 5 |
2 files changed, 12 insertions, 9 deletions
diff --git a/sys/dev/usb/xhci.c b/sys/dev/usb/xhci.c index 401c9e792bc..be076b5a64d 100644 --- a/sys/dev/usb/xhci.c +++ b/sys/dev/usb/xhci.c @@ -1,4 +1,4 @@ -/* $NetBSD: xhci.c,v 1.41 2016/04/30 15:03:55 skrll Exp $ */ +/* $NetBSD: xhci.c,v 1.42 2016/05/06 10:24:06 skrll Exp $ */ /* * Copyright (c) 2013 Jonathan A. Kollasch @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.41 2016/04/30 15:03:55 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.42 2016/05/06 10:24:06 skrll Exp $"); #include "opt_usb.h" @@ -603,13 +603,13 @@ xhci_hc_reset(struct xhci_softc * const sc) int i; /* Check controller not ready */ - for (i = 0; i < 100; i++) { + for (i = 0; i < XHCI_WAIT_CNR; i++) { usbsts = xhci_op_read_4(sc, XHCI_USBSTS); if ((usbsts & XHCI_STS_CNR) == 0) break; usb_delay_ms(&sc->sc_bus, 1); } - if (i >= 100) { + if (i >= XHCI_WAIT_CNR) { aprint_error_dev(sc->sc_dev, "controller not ready timeout\n"); return EIO; } @@ -622,25 +622,25 @@ xhci_hc_reset(struct xhci_softc * const sc) /* Reset controller */ usbcmd = XHCI_CMD_HCRST; xhci_op_write_4(sc, XHCI_USBCMD, usbcmd); - for (i = 0; i < 100; i++) { + for (i = 0; i < XHCI_WAIT_HCRST; i++) { usbcmd = xhci_op_read_4(sc, XHCI_USBCMD); if ((usbcmd & XHCI_CMD_HCRST) == 0) break; usb_delay_ms(&sc->sc_bus, 1); } - if (i >= 100) { + if (i >= XHCI_WAIT_HCRST) { aprint_error_dev(sc->sc_dev, "host controller reset timeout\n"); return EIO; } /* Check controller not ready */ - for (i = 0; i < 100; i++) { + for (i = 0; i < XHCI_WAIT_CNR; i++) { usbsts = xhci_op_read_4(sc, XHCI_USBSTS); if ((usbsts & XHCI_STS_CNR) == 0) break; usb_delay_ms(&sc->sc_bus, 1); } - if (i >= 100) { + if (i >= XHCI_WAIT_CNR) { aprint_error_dev(sc->sc_dev, "controller not ready timeout after reset\n"); return EIO; diff --git a/sys/dev/usb/xhcireg.h b/sys/dev/usb/xhcireg.h index 42e1ada3485..0b23612df8f 100644 --- a/sys/dev/usb/xhcireg.h +++ b/sys/dev/usb/xhcireg.h @@ -1,4 +1,4 @@ -/* $NetBSD: xhcireg.h,v 1.5 2016/04/23 10:15:32 skrll Exp $ */ +/* $NetBSD: xhcireg.h,v 1.6 2016/05/06 10:24:06 skrll Exp $ */ /*- * Copyright (c) 2010 Hans Petter Selasky. All rights reserved. @@ -97,6 +97,9 @@ #define XHCI_CMD_EWE 0x00000400 /* RW Enable Wrap Event */ #define XHCI_CMD_EU3S 0x00000800 /* RW Enable U3 MFINDEX Stop */ +#define XHCI_WAIT_CNR 100 /* in 1ms */ +#define XHCI_WAIT_HCRST 100 /* in 1ms */ + #define XHCI_USBSTS 0x04 /* XHCI status */ #define XHCI_STS_HCH 0x00000001 /* RO - Host Controller Halted */ #define XHCI_STS_HSE 0x00000004 /* RW - Host System Error */ |
