Module Name: src
Committed By: skrll
Date: Fri May 6 10:24:06 UTC 2016
Modified Files:
src/sys/dev/usb: xhci.c xhcireg.h
Log Message:
Remove magic numbers from xhci_hc_reset. From t-hash.
To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/usb/xhcireg.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.41 src/sys/dev/usb/xhci.c:1.42
--- src/sys/dev/usb/xhci.c:1.41 Sat Apr 30 15:03:55 2016
+++ src/sys/dev/usb/xhci.c Fri May 6 10:24:06 2016
@@ -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
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
/* 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;
Index: src/sys/dev/usb/xhcireg.h
diff -u src/sys/dev/usb/xhcireg.h:1.5 src/sys/dev/usb/xhcireg.h:1.6
--- src/sys/dev/usb/xhcireg.h:1.5 Sat Apr 23 10:15:32 2016
+++ src/sys/dev/usb/xhcireg.h Fri May 6 10:24:06 2016
@@ -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 */