summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2011-01-24 17:38:37 +0000
committerhselasky <hselasky@FreeBSD.org>2011-01-24 17:38:37 +0000
commitd0e4831ad198ca8ad6fd06008a4ad49a71be2cee (patch)
treeaf1a8c29cf9d914a9d3723c4ef05a85baaf515ad
parentaec2294356812c27219b097226db9f5c589f1953 (diff)
downloadFreeBSD-src-d0e4831ad198ca8ad6fd06008a4ad49a71be2cee.zip
FreeBSD-src-d0e4831ad198ca8ad6fd06008a4ad49a71be2cee.tar.gz
Add more sanity checks for USB_HOST_ALIGN input values. Re-factor existing
checks for readability. Approved by: thompsa (mentor)
-rw-r--r--sys/dev/usb/usb_freebsd.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/dev/usb/usb_freebsd.h b/sys/dev/usb/usb_freebsd.h
index 70dd383..a44e530 100644
--- a/sys/dev/usb/usb_freebsd.h
+++ b/sys/dev/usb/usb_freebsd.h
@@ -46,12 +46,15 @@
#define USB_TD_GET_PROC(td) (td)->td_proc
#define USB_PROC_GET_GID(td) (td)->p_pgid
-#if defined(USB_HOST_ALIGN) && (USB_HOST_ALIGN != 0)
-/* USB_HOST_ALIGN is already defined and valid */
-#else
+#if (!defined(USB_HOST_ALIGN)) || (USB_HOST_ALIGN <= 0)
+/* Use default value. */
#undef USB_HOST_ALIGN
#define USB_HOST_ALIGN 8 /* bytes, must be power of two */
#endif
+/* Sanity check for USB_HOST_ALIGN: Verify power of two. */
+#if ((-USB_HOST_ALIGN) & USB_HOST_ALIGN) != USB_HOST_ALIGN
+#error "USB_HOST_ALIGN is not power of two."
+#endif
#define USB_FS_ISOC_UFRAME_MAX 4 /* exclusive unit */
#define USB_BUS_MAX 256 /* units */
#define USB_MAX_DEVICES 128 /* units */
OpenPOWER on IntegriCloud