svn commit: r217718 - in head/sys: conf dev/usb
Hans Petter Selasky
hselasky at freebsd.org
Sun Jan 23 09:28:58 UTC 2011
On Saturday 22 January 2011 16:09:18 Gary Jennejohn wrote:
> On Sat, 22 Jan 2011 13:52:23 +0000 (UTC)
>
> Hans Petter Selasky <hselasky at FreeBSD.org> wrote:
> > Author: hselasky
> > Date: Sat Jan 22 13:52:23 2011
> > New Revision: 217718
> > URL: http://svn.freebsd.org/changeset/base/217718
> >
> > Log:
> > Allow USB_HOST_ALIGN to be configured at compile time. This patch is
> > necessary for MIPS based RouterStation Pro board and maybe other MIPS
> > based boards as well.
> >
> > Submitted by: Milan Obuch
> > Approved by: thompsa (mentor)
> >
> > Modified:
> > head/sys/conf/options
> > head/sys/dev/usb/usb_freebsd.h
> >
> > Modified: head/sys/conf/options
> > =========================================================================
> > ===== --- head/sys/conf/options Sat Jan 22 13:18:28 2011 (r217717)
> > +++ head/sys/conf/options Sat Jan 22 13:52:23 2011 (r217718)
> > @@ -642,6 +642,7 @@ BUS_DEBUG opt_bus.h
> >
> > # options for USB support
> > USB_DEBUG opt_usb.h
> >
> > +USB_HOST_ALIGN opt_usb.h
Sorry I didn't see this option sneaking in during r217631 :-) Anyway, two
times is better than one time :-)
> >
> > USB_REQ_DEBUG opt_usb.h
> > USB_VERBOSE opt_usb.h
> > USB_EHCI_BIG_ENDIAN_DESC opt_usb.h
> >
> > Modified: head/sys/dev/usb/usb_freebsd.h
> > =========================================================================
> > ===== --- head/sys/dev/usb/usb_freebsd.h Sat Jan 22 13:18:28
> > 2011 (r217717) +++ head/sys/dev/usb/usb_freebsd.h Sat Jan 22 13:52:23
> > 2011 (r217718) @@ -46,7 +46,12 @@
> >
> > #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 */
>
> Not necessarily valid. What if the user sets it to -24? The compiler
> will happily accept that with the above #if-statement.
>
> IMO you should test for USB_HOST_ALIGN > 0, which should always work.
>
> Defensive programming is always a good idea.
I agree.
Does this look OK:
#if defined(USB_HOST_ALIGN) && (USB_HOST_ALIGN != 0)
#if (-USB_HOST_ALIGN & USB_HOST_ALIGN) == USB_HOST_ALIGN
#error "USB_HOST_ALIGN is not power of two."
#endif
#if (USB_HOST_ALIGN <= 0)
#error "USB_HOST_ALIGN is less than or equal to zero."
#endif
...
>
> > +#else
> > +#undef USB_HOST_ALIGN
> >
> > #define USB_HOST_ALIGN 8 /* bytes, must be 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 */
--HPS
More information about the svn-src-all
mailing list