summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthompsa <thompsa@FreeBSD.org>2009-01-13 19:02:50 +0000
committerthompsa <thompsa@FreeBSD.org>2009-01-13 19:02:50 +0000
commit7906c47b626b305182f260caf65a2b24771dc011 (patch)
treee4248d01dcc9ffe73324d45cad067bf65e6b3c03
parent0364e2114140007154073576bb28307c0c27ed45 (diff)
downloadFreeBSD-src-7906c47b626b305182f260caf65a2b24771dc011.zip
FreeBSD-src-7906c47b626b305182f260caf65a2b24771dc011.tar.gz
MFp4: //depot/projects/usb@155829
Code style changes requested by: M. Warner Losh Submitted by: Hans Petter Selasky
-rw-r--r--sys/dev/usb2/core/usb2_core.h2
-rw-r--r--sys/dev/usb2/core/usb2_device.c21
-rw-r--r--sys/dev/usb2/core/usb2_hub.c16
-rw-r--r--sys/dev/usb2/include/usb2_defs.h13
4 files changed, 22 insertions, 30 deletions
diff --git a/sys/dev/usb2/core/usb2_core.h b/sys/dev/usb2/core/usb2_core.h
index f1e5586..217ba38 100644
--- a/sys/dev/usb2/core/usb2_core.h
+++ b/sys/dev/usb2/core/usb2_core.h
@@ -101,8 +101,6 @@
#define USB_HOST_ALIGN 8 /* bytes, must be power of two */
-#define USB_ROOT_HUB_ADDR 1 /* value */
-
#define USB_ISOC_TIME_MAX 128 /* ms */
#define USB_FS_ISOC_UFRAME_MAX 4 /* exclusive unit */
diff --git a/sys/dev/usb2/core/usb2_device.c b/sys/dev/usb2/core/usb2_device.c
index 739af1a..b54f863 100644
--- a/sys/dev/usb2/core/usb2_device.c
+++ b/sys/dev/usb2/core/usb2_device.c
@@ -1293,18 +1293,15 @@ usb2_alloc_device(device_t parent_dev, struct usb2_bus *bus,
* Device index zero is not used and device index 1 should
* always be the root hub.
*/
- for (device_index = USB_ROOT_HUB_ADDR;; device_index++) {
-#if (USB_ROOT_HUB_ADDR > USB_MIN_DEVICES)
-#error "Incorrect device limit."
-#endif
- if (device_index == bus->devices_max) {
- device_printf(bus->bdev,
- "No free USB device "
- "index for new device!\n");
- return (NULL);
- }
- if (bus->devices[device_index] == NULL)
- break;
+ for (device_index = USB_ROOT_HUB_ADDR;
+ (device_index != bus->devices_max) &&
+ (bus->devices[device_index] != NULL);
+ device_index++) /* nop */;
+
+ if (device_index == bus->devices_max) {
+ device_printf(bus->bdev,
+ "No free USB device index for new device!\n");
+ return (NULL);
}
if (depth > 0x10) {
diff --git a/sys/dev/usb2/core/usb2_hub.c b/sys/dev/usb2/core/usb2_hub.c
index 7756cb6..e5c9c8d 100644
--- a/sys/dev/usb2/core/usb2_hub.c
+++ b/sys/dev/usb2/core/usb2_hub.c
@@ -1520,12 +1520,8 @@ usb2_bus_powerd(struct usb2_bus *bus)
* The root HUB device is never suspended
* and we simply skip it.
*/
- for (x = USB_ROOT_HUB_ADDR + 1;; x++) {
-#if ((USB_ROOT_HUB_ADDR + 1) > USB_MIN_DEVICES)
-#error "Incorrect device limit."
-#endif
- if (x == bus->devices_max)
- break;
+ for (x = USB_ROOT_HUB_ADDR + 1;
+ x != bus->devices_max; x++) {
udev = bus->devices[x];
if (udev == NULL)
@@ -1568,12 +1564,8 @@ usb2_bus_powerd(struct usb2_bus *bus)
/* Re-loop all the devices to get the actual state */
- for (x = USB_ROOT_HUB_ADDR + 1;; x++) {
-#if ((USB_ROOT_HUB_ADDR + 1) > USB_MIN_DEVICES)
-#error "Incorrect device limit."
-#endif
- if (x == bus->devices_max)
- break;
+ for (x = USB_ROOT_HUB_ADDR + 1;
+ x != bus->devices_max; x++) {
udev = bus->devices[x];
if (udev == NULL)
diff --git a/sys/dev/usb2/include/usb2_defs.h b/sys/dev/usb2/include/usb2_defs.h
index a31a7cd..64caf39 100644
--- a/sys/dev/usb2/include/usb2_defs.h
+++ b/sys/dev/usb2/include/usb2_defs.h
@@ -35,6 +35,8 @@
#define USB_EP_MAX (2*16) /* hardcoded */
#define USB_FIFO_MAX (4 * USB_EP_MAX)
+#define USB_ROOT_HUB_ADDR 1 /* index */
+
#define USB_MIN_DEVICES 2 /* unused + root HUB */
#define USB_MAX_DEVICES USB_DEV_MAX /* including virtual root HUB and
@@ -58,15 +60,18 @@
/* sanity checks */
#if (USB_FIFO_MAX < USB_EP_MAX)
-#error "Misconfigured limits #1"
+#error "There cannot be less FIFOs than USB endpoints."
#endif
#if (USB_FIFO_MAX & 1)
-#error "Misconfigured limits #2"
+#error "Number of FIFOs must be odd."
#endif
#if (USB_EP_MAX < (2*16))
-#error "Misconfigured limits #3"
+#error "Number of hardware USB endpoints cannot be less than 32."
#endif
#if (USB_MAX_DEVICES < USB_MIN_DEVICES)
-#error "Misconfigured limits #4"
+#error "Minimum number of devices is greater than maximum number of devices."
+#endif
+#if (USB_ROOT_HUB_ADDR >= USB_MIN_DEVICES)
+#error "The root hub address must be less than USB_MIN_DEVICES."
#endif
#endif /* _USB2_DEFS_H_ */
OpenPOWER on IntegriCloud