From owner-svn-src-head@FreeBSD.ORG Mon Jan 24 17:38:38 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3C87D106564A; Mon, 24 Jan 2011 17:38:38 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2BB068FC0A; Mon, 24 Jan 2011 17:38:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p0OHccM6000527; Mon, 24 Jan 2011 17:38:38 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0OHccPE000525; Mon, 24 Jan 2011 17:38:38 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201101241738.p0OHccPE000525@svn.freebsd.org> From: Hans Petter Selasky Date: Mon, 24 Jan 2011 17:38:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217793 - head/sys/dev/usb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Jan 2011 17:38:38 -0000 Author: hselasky Date: Mon Jan 24 17:38:37 2011 New Revision: 217793 URL: http://svn.freebsd.org/changeset/base/217793 Log: Add more sanity checks for USB_HOST_ALIGN input values. Re-factor existing checks for readability. Approved by: thompsa (mentor) Modified: head/sys/dev/usb/usb_freebsd.h Modified: head/sys/dev/usb/usb_freebsd.h ============================================================================== --- head/sys/dev/usb/usb_freebsd.h Mon Jan 24 17:08:26 2011 (r217792) +++ head/sys/dev/usb/usb_freebsd.h Mon Jan 24 17:38:37 2011 (r217793) @@ -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 */