Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Mar 2009 21:48:11 +0000 (UTC)
From:      Andrew Thompson <thompsa@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r190180 - in head/sys/dev/usb: . controller
Message-ID:  <200903202148.n2KLmBD1014532@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: thompsa
Date: Fri Mar 20 21:48:11 2009
New Revision: 190180
URL: http://svn.freebsd.org/changeset/base/190180

Log:
  MFp4 //depot/projects/usb@159392
  
  Add ifdefs for making parts of usb conditional.
  
  Submitted by:	Hans Petter Selasky

Modified:
  head/sys/dev/usb/controller/at91dci.c
  head/sys/dev/usb/controller/atmegadci.c
  head/sys/dev/usb/controller/musb_otg.c
  head/sys/dev/usb/controller/usb_controller.c
  head/sys/dev/usb/controller/uss820dci.c
  head/sys/dev/usb/usb_busdma.c
  head/sys/dev/usb/usb_busdma.h
  head/sys/dev/usb/usb_core.h
  head/sys/dev/usb/usb_debug.h
  head/sys/dev/usb/usb_device.c
  head/sys/dev/usb/usb_device.h
  head/sys/dev/usb/usb_request.c
  head/sys/dev/usb/usb_transfer.c
  head/sys/dev/usb/usb_transfer.h
  head/sys/dev/usb/usb_util.c
  head/sys/dev/usb/usb_util.h

Modified: head/sys/dev/usb/controller/at91dci.c
==============================================================================
--- head/sys/dev/usb/controller/at91dci.c	Fri Mar 20 21:47:26 2009	(r190179)
+++ head/sys/dev/usb/controller/at91dci.c	Fri Mar 20 21:48:11 2009	(r190180)
@@ -69,7 +69,7 @@ __FBSDID("$FreeBSD$");
    USB_P2U(&(((struct at91dci_softc *)0)->sc_bus))))
 
 #define	AT9100_DCI_PC2SC(pc) \
-   AT9100_DCI_BUS2SC((pc)->tag_parent->info->bus)
+   AT9100_DCI_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)
 
 #if USB_DEBUG
 static int at91dcidebug = 0;

Modified: head/sys/dev/usb/controller/atmegadci.c
==============================================================================
--- head/sys/dev/usb/controller/atmegadci.c	Fri Mar 20 21:47:26 2009	(r190179)
+++ head/sys/dev/usb/controller/atmegadci.c	Fri Mar 20 21:48:11 2009	(r190180)
@@ -62,7 +62,7 @@ __FBSDID("$FreeBSD$");
    USB_P2U(&(((struct atmegadci_softc *)0)->sc_bus))))
 
 #define	ATMEGA_PC2SC(pc) \
-   ATMEGA_BUS2SC((pc)->tag_parent->info->bus)
+   ATMEGA_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)
 
 #if USB_DEBUG
 static int atmegadci_debug = 0;

Modified: head/sys/dev/usb/controller/musb_otg.c
==============================================================================
--- head/sys/dev/usb/controller/musb_otg.c	Fri Mar 20 21:47:26 2009	(r190179)
+++ head/sys/dev/usb/controller/musb_otg.c	Fri Mar 20 21:48:11 2009	(r190180)
@@ -63,7 +63,7 @@
    USB_P2U(&(((struct musbotg_softc *)0)->sc_bus))))
 
 #define	MUSBOTG_PC2SC(pc) \
-   MUSBOTG_BUS2SC((pc)->tag_parent->info->bus)
+   MUSBOTG_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)
 
 #if USB_DEBUG
 static int musbotgdebug = 0;

Modified: head/sys/dev/usb/controller/usb_controller.c
==============================================================================
--- head/sys/dev/usb/controller/usb_controller.c	Fri Mar 20 21:47:26 2009	(r190179)
+++ head/sys/dev/usb/controller/usb_controller.c	Fri Mar 20 21:48:11 2009	(r190180)
@@ -49,15 +49,6 @@ static device_detach_t usb2_detach;
 
 static void	usb2_attach_sub(device_t, struct usb2_bus *);
 static void	usb2_post_init(void *);
-static void	usb2_bus_mem_flush_all_cb(struct usb2_bus *,
-		    struct usb2_page_cache *, struct usb2_page *, uint32_t,
-		    uint32_t);
-static void	usb2_bus_mem_alloc_all_cb(struct usb2_bus *,
-		    struct usb2_page_cache *, struct usb2_page *, uint32_t,
-		    uint32_t);
-static void	usb2_bus_mem_free_all_cb(struct usb2_bus *,
-		    struct usb2_page_cache *, struct usb2_page *, uint32_t,
-		    uint32_t);
 static void	usb2_bus_roothub(struct usb2_proc_msg *pm);
 
 /* static variables */
@@ -487,16 +478,19 @@ SYSUNINIT(usb2_bus_unload, SI_SUB_KLD, S
 /*------------------------------------------------------------------------*
  *	usb2_bus_mem_flush_all_cb
  *------------------------------------------------------------------------*/
+#if USB_HAVE_BUSDMA
 static void
 usb2_bus_mem_flush_all_cb(struct usb2_bus *bus, struct usb2_page_cache *pc,
     struct usb2_page *pg, uint32_t size, uint32_t align)
 {
 	usb2_pc_cpu_flush(pc);
 }
+#endif
 
 /*------------------------------------------------------------------------*
  *	usb2_bus_mem_flush_all - factored out code
  *------------------------------------------------------------------------*/
+#if USB_HAVE_BUSDMA
 void
 usb2_bus_mem_flush_all(struct usb2_bus *bus, usb2_bus_mem_cb_t *cb)
 {
@@ -504,10 +498,12 @@ usb2_bus_mem_flush_all(struct usb2_bus *
 		cb(bus, &usb2_bus_mem_flush_all_cb);
 	}
 }
+#endif
 
 /*------------------------------------------------------------------------*
  *	usb2_bus_mem_alloc_all_cb
  *------------------------------------------------------------------------*/
+#if USB_HAVE_BUSDMA
 static void
 usb2_bus_mem_alloc_all_cb(struct usb2_bus *bus, struct usb2_page_cache *pc,
     struct usb2_page *pg, uint32_t size, uint32_t align)
@@ -519,6 +515,7 @@ usb2_bus_mem_alloc_all_cb(struct usb2_bu
 		bus->alloc_failed = 1;
 	}
 }
+#endif
 
 /*------------------------------------------------------------------------*
  *	usb2_bus_mem_alloc_all - factored out code
@@ -541,9 +538,10 @@ usb2_bus_mem_alloc_all(struct usb2_bus *
 
 	TAILQ_INIT(&bus->intr_q.head);
 
+#if USB_HAVE_BUSDMA
 	usb2_dma_tag_setup(bus->dma_parent_tag, bus->dma_tags,
-	    dmat, &bus->bus_mtx, NULL, NULL, 32, USB_BUS_DMA_TAG_MAX);
-
+	    dmat, &bus->bus_mtx, NULL, 32, USB_BUS_DMA_TAG_MAX);
+#endif
 	if ((bus->devices_max > USB_MAX_DEVICES) ||
 	    (bus->devices_max < USB_MIN_DEVICES) ||
 	    (bus->devices == NULL)) {
@@ -551,9 +549,11 @@ usb2_bus_mem_alloc_all(struct usb2_bus *
 		    "initialised properly!\n");
 		bus->alloc_failed = 1;		/* failure */
 	}
+#if USB_HAVE_BUSDMA
 	if (cb) {
 		cb(bus, &usb2_bus_mem_alloc_all_cb);
 	}
+#endif
 	if (bus->alloc_failed) {
 		usb2_bus_mem_free_all(bus, cb);
 	}
@@ -563,12 +563,14 @@ usb2_bus_mem_alloc_all(struct usb2_bus *
 /*------------------------------------------------------------------------*
  *	usb2_bus_mem_free_all_cb
  *------------------------------------------------------------------------*/
+#if USB_HAVE_BUSDMA
 static void
 usb2_bus_mem_free_all_cb(struct usb2_bus *bus, struct usb2_page_cache *pc,
     struct usb2_page *pg, uint32_t size, uint32_t align)
 {
 	usb2_pc_free_mem(pc);
 }
+#endif
 
 /*------------------------------------------------------------------------*
  *	usb2_bus_mem_free_all - factored out code
@@ -576,10 +578,12 @@ usb2_bus_mem_free_all_cb(struct usb2_bus
 void
 usb2_bus_mem_free_all(struct usb2_bus *bus, usb2_bus_mem_cb_t *cb)
 {
+#if USB_HAVE_BUSDMA
 	if (cb) {
 		cb(bus, &usb2_bus_mem_free_all_cb);
 	}
 	usb2_dma_tag_unsetup(bus->dma_parent_tag);
+#endif
 
 	mtx_destroy(&bus->bus_mtx);
 }

Modified: head/sys/dev/usb/controller/uss820dci.c
==============================================================================
--- head/sys/dev/usb/controller/uss820dci.c	Fri Mar 20 21:47:26 2009	(r190179)
+++ head/sys/dev/usb/controller/uss820dci.c	Fri Mar 20 21:48:11 2009	(r190180)
@@ -58,7 +58,7 @@
    USB_P2U(&(((struct uss820dci_softc *)0)->sc_bus))))
 
 #define	USS820_DCI_PC2SC(pc) \
-   USS820_DCI_BUS2SC((pc)->tag_parent->info->bus)
+   USS820_DCI_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)
 
 #if USB_DEBUG
 static int uss820dcidebug = 0;

Modified: head/sys/dev/usb/usb_busdma.c
==============================================================================
--- head/sys/dev/usb/usb_busdma.c	Fri Mar 20 21:47:26 2009	(r190179)
+++ head/sys/dev/usb/usb_busdma.c	Fri Mar 20 21:48:11 2009	(r190180)
@@ -41,20 +41,20 @@
 #include <dev/usb/usb_controller.h>
 #include <dev/usb/usb_bus.h>
 
+#if USB_HAVE_BUSDMA
 static void	usb2_dma_tag_create(struct usb2_dma_tag *, uint32_t, uint32_t);
 static void	usb2_dma_tag_destroy(struct usb2_dma_tag *);
+#endif
 
-#ifdef __FreeBSD__
+#if USB_HAVE_BUSDMA && defined(__FreeBSD__)
 static void	usb2_dma_lock_cb(void *, bus_dma_lock_op_t);
-static int32_t	usb2_m_copy_in_cb(void *, void *, uint32_t);
 static void	usb2_pc_alloc_mem_cb(void *, bus_dma_segment_t *, int, int);
 static void	usb2_pc_load_mem_cb(void *, bus_dma_segment_t *, int, int);
 static void	usb2_pc_common_mem_cb(void *, bus_dma_segment_t *, int, int,
 		    uint8_t);
 #endif
 
-#ifdef __NetBSD__
-static int32_t	usb2_m_copy_in_cb(void *, caddr_t, uint32_t);
+#if USB_HAVE_BUSDMA && defined(__NetBSD__)
 static void	usb2_pc_common_mem_cb(struct usb2_page_cache *,
 		    bus_dma_segment_t *, int, int, uint8_t);
 #endif
@@ -71,6 +71,7 @@ usb2_get_page(struct usb2_page_cache *pc
 {
 	struct usb2_page *page;
 
+#if USB_HAVE_BUSDMA
 	if (pc->page_start) {
 
 		/* Case 1 - something has been loaded into DMA */
@@ -105,14 +106,16 @@ usb2_get_page(struct usb2_page_cache *pc
 
 			res->buffer = USB_ADD_BYTES(page->buffer, offset);
 		}
-	} else {
-
-		/* Case 2 - Plain PIO */
-
-		res->buffer = USB_ADD_BYTES(pc->buffer, offset);
-		res->length = 0 - 1;
-		res->physaddr = 0;
+		return;
 	}
+#endif
+	/* Case 2 - Plain PIO */
+
+	res->buffer = USB_ADD_BYTES(pc->buffer, offset);
+	res->length = 0 - 1;
+#if USB_HAVE_BUSDMA
+	res->physaddr = 0;
+#endif
 }
 
 /*------------------------------------------------------------------------*
@@ -146,6 +149,7 @@ usb2_copy_in(struct usb2_page_cache *cac
  *    0: Success
  * Else: Failure
  *------------------------------------------------------------------------*/
+#if USB_HAVE_USER_IO
 int
 usb2_copy_in_user(struct usb2_page_cache *cache, uint32_t offset,
     const void *ptr, uint32_t len)
@@ -170,10 +174,12 @@ usb2_copy_in_user(struct usb2_page_cache
 	}
 	return (0);			/* success */
 }
+#endif
 
 /*------------------------------------------------------------------------*
  *  usb2_m_copy_in - copy a mbuf chain directly into DMA-able memory
  *------------------------------------------------------------------------*/
+#if USB_HAVE_MBUF
 struct usb2_m_copy_in_arg {
 	struct usb2_page_cache *cache;
 	uint32_t dst_offset;
@@ -202,10 +208,12 @@ usb2_m_copy_in(struct usb2_page_cache *c
 
 	error = m_apply(m, src_offset, src_len, &usb2_m_copy_in_cb, &arg);
 }
+#endif
 
 /*------------------------------------------------------------------------*
  *  usb2_uiomove - factored out code
  *------------------------------------------------------------------------*/
+#if USB_HAVE_USER_IO
 int
 usb2_uiomove(struct usb2_page_cache *pc, struct uio *uio,
     uint32_t pc_offset, uint32_t len)
@@ -234,6 +242,7 @@ usb2_uiomove(struct usb2_page_cache *pc,
 	}
 	return (error);
 }
+#endif
 
 /*------------------------------------------------------------------------*
  *  usb2_copy_out - copy directly from DMA-able memory
@@ -266,6 +275,7 @@ usb2_copy_out(struct usb2_page_cache *ca
  *    0: Success
  * Else: Failure
  *------------------------------------------------------------------------*/
+#if USB_HAVE_USER_IO
 int
 usb2_copy_out_user(struct usb2_page_cache *cache, uint32_t offset,
     void *ptr, uint32_t len)
@@ -290,6 +300,7 @@ usb2_copy_out_user(struct usb2_page_cach
 	}
 	return (0);			/* success */
 }
+#endif
 
 /*------------------------------------------------------------------------*
  *  usb2_bzero - zero DMA-able memory
@@ -313,8 +324,7 @@ usb2_bzero(struct usb2_page_cache *cache
 	}
 }
 
-
-#ifdef __FreeBSD__
+#if USB_HAVE_BUSDMA && defined(__FreeBSD__)
 
 /*------------------------------------------------------------------------*
  *	usb2_dma_lock_cb - dummy callback
@@ -691,7 +701,7 @@ usb2_pc_dmamap_create(struct usb2_page_c
 	struct usb2_dma_tag *utag;
 
 	/* get info */
-	info = pc->tag_parent->info;
+	info = USB_DMATAG_TO_XROOT(pc->tag_parent);
 
 	/* sanity check */
 	if (info == NULL) {
@@ -731,7 +741,7 @@ usb2_pc_dmamap_destroy(struct usb2_page_
 
 #endif
 
-#ifdef __NetBSD__
+#if USB_HAVE_BUSDMA && defined(__NetBSD__)
 
 /*------------------------------------------------------------------------*
  *	usb2_dma_tag_create - allocate a DMA tag
@@ -1062,7 +1072,7 @@ usb2_pc_dmamap_create(struct usb2_page_c
 	struct usb2_dma_tag *utag;
 
 	/* get info */
-	info = pc->tag_parent->info;
+	info = USB_DMATAG_TO_XROOT(pc->tag_parent);
 
 	/* sanity check */
 	if (info == NULL) {
@@ -1106,6 +1116,8 @@ usb2_pc_dmamap_destroy(struct usb2_page_
 
 #endif
 
+#if USB_HAVE_BUSDMA
+
 /*------------------------------------------------------------------------*
  *	usb2_dma_tag_find - factored out code
  *------------------------------------------------------------------------*/
@@ -1148,8 +1160,7 @@ void
 usb2_dma_tag_setup(struct usb2_dma_parent_tag *udpt,
     struct usb2_dma_tag *udt, bus_dma_tag_t dmat,
     struct mtx *mtx, usb2_dma_callback_t *func,
-    struct usb2_xfer_root *info, uint8_t ndmabits,
-    uint8_t nudt)
+    uint8_t ndmabits, uint8_t nudt)
 {
 	bzero(udpt, sizeof(*udpt));
 
@@ -1167,7 +1178,6 @@ usb2_dma_tag_setup(struct usb2_dma_paren
 
 	/* store some information */
 	udpt->mtx = mtx;
-	udpt->info = info;
 	udpt->func = func;
 	udpt->tag = dmat;
 	udpt->utag_first = udt;
@@ -1349,7 +1359,7 @@ usb2_bdma_done_event(struct usb2_dma_par
 {
 	struct usb2_xfer_root *info;
 
-	info = udpt->info;
+	info = USB_DMATAG_TO_XROOT(udpt);
 
 	mtx_assert(info->xfer_mtx, MA_OWNED);
 
@@ -1423,3 +1433,5 @@ usb2_bdma_post_sync(struct usb2_xfer *xf
 		pc++;
 	}
 }
+
+#endif

Modified: head/sys/dev/usb/usb_busdma.h
==============================================================================
--- head/sys/dev/usb/usb_busdma.h	Fri Mar 20 21:47:26 2009	(r190179)
+++ head/sys/dev/usb/usb_busdma.h	Fri Mar 20 21:48:11 2009	(r190180)
@@ -60,8 +60,10 @@ typedef void (usb2_dma_callback_t)(struc
  * address of a memory page having size USB_PAGE_SIZE.
  */
 struct usb2_page {
+#if USB_HAVE_BUSDMA
 	bus_size_t physaddr;
 	void   *buffer;			/* non Kernel Virtual Address */
+#endif
 };
 
 /*
@@ -71,7 +73,9 @@ struct usb2_page {
  */
 struct usb2_page_search {
 	void   *buffer;
+#if USB_HAVE_BUSDMA
 	bus_size_t physaddr;
+#endif
 	uint32_t length;
 };
 
@@ -81,62 +85,67 @@ struct usb2_page_search {
  */
 struct usb2_page_cache {
 
-#ifdef __FreeBSD__
+#if USB_HAVE_BUSDMA && defined(__FreeBSD__)
 	bus_dma_tag_t tag;
 	bus_dmamap_t map;
 #endif
-#ifdef __NetBSD__
+#if USB_HAVE_BUSDMA && defined(__NetBSD__)
 	bus_dma_tag_t tag;
 	bus_dmamap_t map;
 	bus_dma_segment_t *p_seg;
 #endif
+#if USB_HAVE_BUSDMA
 	struct usb2_page *page_start;
+#endif
 	struct usb2_dma_parent_tag *tag_parent;	/* always set */
 	void   *buffer;			/* virtual buffer pointer */
-#ifdef __NetBSD__
+#if USB_HAVE_BUSDMA && defined(_NetBSD__)
 	int	n_seg;
 #endif
+#if USB_HAVE_BUSDMA
 	uint32_t page_offset_buf;
 	uint32_t page_offset_end;
 	uint8_t	isread:1;		/* set if we are currently reading
 					 * from the memory. Else write. */
 	uint8_t	ismultiseg:1;		/* set if we can have multiple
 					 * segments */
+#endif
 };
 
 /*
  * The following structure describes the parent USB DMA tag.
  */
 struct usb2_dma_parent_tag {
-#ifdef __FreeBSD__
+#if USB_HAVE_BUSDMA && defined(__FreeBSD__)
 	struct cv cv[1];		/* internal condition variable */
 #endif
-
+#if USB_HAVE_BUSDMA
 	bus_dma_tag_t tag;		/* always set */
 
 	struct mtx *mtx;		/* private mutex, always set */
-	struct usb2_xfer_root *info;	/* used by the callback function */
 	usb2_dma_callback_t *func;	/* load complete callback function */
 	struct usb2_dma_tag *utag_first;/* pointer to first USB DMA tag */
-
 	uint8_t	dma_error;		/* set if DMA load operation failed */
 	uint8_t	dma_bits;		/* number of DMA address lines */
 	uint8_t	utag_max;		/* number of USB DMA tags */
+#endif
 };
 
 /*
  * The following structure describes an USB DMA tag.
  */
 struct usb2_dma_tag {
-#ifdef __NetBSD__
+#if USB_HAVE_BUSDMA && defined(__NetBSD__)
 	bus_dma_segment_t *p_seg;
 #endif
+#if USB_HAVE_BUSDMA
 	struct usb2_dma_parent_tag *tag_parent;
 	bus_dma_tag_t tag;
 
 	uint32_t align;
 	uint32_t size;
-#ifdef __NetBSD__
+#endif
+#if USB_HAVE_BUSDMA && defined(__NetBSD__)
 	uint32_t n_seg;
 #endif
 };
@@ -168,8 +177,7 @@ int	usb2_copy_out_user(struct usb2_page_
 	    void *ptr, uint32_t len);
 void	usb2_dma_tag_setup(struct usb2_dma_parent_tag *udpt,
 	    struct usb2_dma_tag *udt, bus_dma_tag_t dmat, struct mtx *mtx,
-	    usb2_dma_callback_t *func, struct usb2_xfer_root *info,
-	    uint8_t ndmabits, uint8_t nudt);
+	    usb2_dma_callback_t *func, uint8_t ndmabits, uint8_t nudt);
 void	usb2_dma_tag_unsetup(struct usb2_dma_parent_tag *udpt);
 void	usb2_get_page(struct usb2_page_cache *pc, uint32_t offset,
 	    struct usb2_page_search *res);

Modified: head/sys/dev/usb/usb_core.h
==============================================================================
--- head/sys/dev/usb/usb_core.h	Fri Mar 20 21:47:26 2009	(r190179)
+++ head/sys/dev/usb/usb_core.h	Fri Mar 20 21:48:11 2009	(r190180)
@@ -32,16 +32,84 @@
 #ifndef _USB2_CORE_H_
 #define	_USB2_CORE_H_
 
+/* Allow defines in "opt_usb.h" to override configuration */
+
+#include "opt_usb.h"
+#include "opt_bus.h"
+
 /* Default USB configuration */
 
-#ifndef USB_USE_CONDVAR
-#define	USB_USE_CONDVAR 0
+/*
+ * The following macro defines if the code shall use cv_xxx() instead
+ * of msleep() and wakeup().
+ */
+#ifndef USB_HAVE_CONDVAR
+#define	USB_HAVE_CONDVAR 0
 #endif
 
+/*
+ * The following macro defines if the code shall support
+ * /dev/usb/x.y.z.
+ */
 #ifndef USB_HAVE_UGEN
 #define	USB_HAVE_UGEN 1
 #endif
 
+/*
+ * The following macro defines if the code shall support any forms of
+ * ASCII strings.
+ */
+#ifndef USB_HAVE_STRINGS
+#define	USB_HAVE_STRINGS 1
+#endif
+
+/*
+ * The following macro defines if the code shall support BUS-DMA.
+ */
+#ifndef USB_HAVE_BUSDMA
+#define	USB_HAVE_BUSDMA 1
+#endif
+
+/*
+ * The following macro defines if the code shall support the Linux
+ * compatibility layer.
+ */
+#ifndef USB_HAVE_COMPAT_LINUX
+#define	USB_HAVE_COMPAT_LINUX 1
+#endif
+
+/*
+ * The following macro defines if the code shall support
+ * userland data transfer via copyin() and copyout()
+ */
+#ifndef USB_HAVE_USER_IO
+#define	USB_HAVE_USER_IO 1
+#endif
+
+/*
+ * The following macro defines if the code shall support copy in via
+ * bsd-mbufs to USB.
+ */
+#ifndef USB_HAVE_MBUF
+#define	USB_HAVE_MBUF 1
+#endif
+
+/*
+ * The following macro defines if the code shall compile a table
+ * describing USB vendor and product IDs.
+ */
+#ifndef USB_VERBOSE
+#define	USB_VERBOSE 1
+#endif
+
+/*
+ * The following macro defines if USB debugging support shall be
+ * compiled for the USB core and all drivers.
+ */
+#ifndef USB_DEBUG
+#define	USB_DEBUG 1
+#endif
+
 #ifndef USB_TD_GET_PROC
 #define	USB_TD_GET_PROC(td) (td)->td_proc
 #endif
@@ -76,8 +144,6 @@
 #include <dev/usb/usb_revision.h>
 
 #include "usb_if.h"
-#include "opt_usb.h"
-#include "opt_bus.h"
 
 #define	USB_STACK_VERSION 2000		/* 2.0 */
 
@@ -95,10 +161,6 @@
 
 #define	USB_MAX_IPACKET		8	/* maximum size of the initial USB
 					 * data packet */
-#ifndef USB_VERBOSE
-#define	USB_VERBOSE 1
-#endif
-
 #define	USB_HUB_MAX_DEPTH 5
 
 /* USB transfer states */
@@ -256,12 +318,14 @@ struct usb2_xfer_flags_int {
 
 	uint8_t	short_frames_ok:1;	/* filtered version */
 	uint8_t	short_xfer_ok:1;	/* filtered version */
+#if USB_HAVE_BUSDMA
 	uint8_t	bdma_enable:1;		/* filtered version (only set if
 					 * hardware supports DMA) */
 	uint8_t	bdma_no_post_sync:1;	/* set if the USB callback wrapper
 					 * should not do the BUS-DMA post sync
 					 * operation */
 	uint8_t	bdma_setup:1;		/* set if BUS-DMA has been setup */
+#endif
 	uint8_t	isochronous_xfr:1;	/* set if isochronous transfer */
 	uint8_t	usb2_mode:1;		/* shadow copy of "udev->usb2_mode" */
 	uint8_t	curr_dma_set:1;		/* used by USB HC/DC driver */

Modified: head/sys/dev/usb/usb_debug.h
==============================================================================
--- head/sys/dev/usb/usb_debug.h	Fri Mar 20 21:47:26 2009	(r190179)
+++ head/sys/dev/usb/usb_debug.h	Fri Mar 20 21:48:11 2009	(r190180)
@@ -35,11 +35,6 @@ SYSCTL_DECL(_hw_usb2);
 /* Declare global USB debug variable. */
 extern int usb2_debug;
 
-/* Force debugging until further */
-#ifndef USB_DEBUG
-#define	USB_DEBUG 1
-#endif
-
 /* Check if USB debugging is enabled. */
 #ifdef USB_DEBUG_VAR
 #if (USB_DEBUG != 0)

Modified: head/sys/dev/usb/usb_device.c
==============================================================================
--- head/sys/dev/usb/usb_device.c	Fri Mar 20 21:47:26 2009	(r190179)
+++ head/sys/dev/usb/usb_device.c	Fri Mar 20 21:48:11 2009	(r190180)
@@ -44,9 +44,11 @@
 #include <dev/usb/usb_hub.h>
 #include <dev/usb/usb_util.h>
 #include <dev/usb/usb_mbuf.h>
-#include <dev/usb/usb_dev.h>
 #include <dev/usb/usb_msctest.h>
+#if USB_HAVE_UGEN
+#include <dev/usb/usb_dev.h>
 #include <dev/usb/usb_generic.h>
+#endif
 
 #include <dev/usb/quirk/usb_quirk.h>
 
@@ -68,7 +70,9 @@ static void	usb2_init_attach_arg(struct 
 static void	usb2_suspend_resume_sub(struct usb2_device *, device_t,
 		    uint8_t);
 static void	usb2_clear_stall_proc(struct usb2_proc_msg *_pm);
+#if USB_HAVE_STRINGS
 static void	usb2_check_strings(struct usb2_device *);
+#endif
 static usb2_error_t usb2_fill_iface_data(struct usb2_device *, uint8_t,
 		    uint8_t);
 static void	usb2_notify_addq(const char *type, struct usb2_device *);
@@ -482,11 +486,13 @@ usb2_free_iface_data(struct usb2_device 
 
 	/* mtx_assert() */
 
+#if USB_HAVE_COMPAT_LINUX
 	/* free Linux compat device, if any */
 	if (udev->linux_dev) {
 		usb_linux_free_device(udev->linux_dev);
 		udev->linux_dev = NULL;
 	}
+#endif
 	/* free all pipes, if any */
 	usb2_free_pipe_data(udev, 0, 0);
 
@@ -1584,6 +1590,7 @@ usb2_alloc_device(device_t parent_dev, s
 	/* assume 100mA bus powered for now. Changed when configured. */
 	udev->power = USB_MIN_POWER;
 
+#if USB_HAVE_STRINGS
 	/* get serial number string */
 	err = usb2_req_get_string_any
 	    (udev, NULL, (char *)scratch_ptr,
@@ -1607,6 +1614,7 @@ usb2_alloc_device(device_t parent_dev, s
 
 	/* finish up all the strings */
 	usb2_check_strings(udev);
+#endif
 
 	if (udev->flags.usb2_mode == USB_MODE_HOST) {
 		uint8_t config_index;
@@ -2032,6 +2040,7 @@ usb2_devinfo(struct usb2_device *udev, c
 	}
 }
 
+#if USB_HAVE_STRINGS
 #if USB_VERBOSE
 /*
  * Descriptions of of known vendors and devices ("products").
@@ -2128,6 +2137,7 @@ usb2_check_strings(struct usb2_device *u
 		    sizeof(udev->product), "product 0x%04x", product_id);
 	}
 }
+#endif
 
 /*
  * Returns:

Modified: head/sys/dev/usb/usb_device.h
==============================================================================
--- head/sys/dev/usb/usb_device.h	Fri Mar 20 21:47:26 2009	(r190179)
+++ head/sys/dev/usb/usb_device.h	Fri Mar 20 21:48:11 2009	(r190180)
@@ -28,6 +28,7 @@
 #define	_USB2_DEVICE_H_
 
 struct usb2_symlink;
+struct usb_device;		/* linux compat */
 
 #define	USB_DEFAULT_XFER_MAX 2
 
@@ -114,7 +115,9 @@ struct usb2_device {
 	struct usb2_device *parent_hub;
 	struct usb2_config_descriptor *cdesc;	/* full config descr */
 	struct usb2_hub *hub;		/* only if this is a hub */
+#if USB_HAVE_COMPAT_LINUX
 	struct usb_device *linux_dev;
+#endif
 	struct usb2_xfer *default_xfer[USB_DEFAULT_XFER_MAX];
 	struct usb2_temp_data *usb2_template_ptr;
 	struct usb2_pipe *pipe_curr;	/* current clear stall pipe */

Modified: head/sys/dev/usb/usb_request.c
==============================================================================
--- head/sys/dev/usb/usb_request.c	Fri Mar 20 21:47:26 2009	(r190179)
+++ head/sys/dev/usb/usb_request.c	Fri Mar 20 21:48:11 2009	(r190180)
@@ -264,6 +264,10 @@ usb2_do_request_flags(struct usb2_device
 	if (actlen) {
 		*actlen = 0;
 	}
+#if (USB_HAVE_USER_IO == 0)
+	if (flags & USB_USER_DATA_PTR)
+		return (USB_ERR_INVAL);
+#endif
 	if (udev->flags.usb2_mode == USB_MODE_DEVICE) {
 		DPRINTF("USB device mode\n");
 		(usb2_temp_get_desc_p) (udev, req, &desc, &temp);
@@ -277,13 +281,14 @@ usb2_do_request_flags(struct usb2_device
 			*actlen = length;
 		}
 		if (length > 0) {
+#if USB_HAVE_USER_IO
 			if (flags & USB_USER_DATA_PTR) {
 				if (copyout(desc, data, length)) {
 					return (USB_ERR_INVAL);
 				}
-			} else {
+			} else
+#endif
 				bcopy(desc, data, length);
-			}
 		}
 		return (0);		/* success */
 	}
@@ -339,6 +344,7 @@ usb2_do_request_flags(struct usb2_device
 
 		if (temp > 0) {
 			if (!(req->bmRequestType & UT_READ)) {
+#if USB_HAVE_USER_IO
 				if (flags & USB_USER_DATA_PTR) {
 					USB_XFER_UNLOCK(xfer);
 					err = usb2_copy_in_user(xfer->frbuffers + 1,
@@ -348,9 +354,10 @@ usb2_do_request_flags(struct usb2_device
 						err = USB_ERR_INVAL;
 						break;
 					}
-				} else {
-					usb2_copy_in(xfer->frbuffers + 1, 0, data, temp);
-				}
+				} else
+#endif
+					usb2_copy_in(xfer->frbuffers + 1,
+					    0, data, temp);
 			}
 			xfer->nframes = 2;
 		} else {
@@ -408,6 +415,7 @@ usb2_do_request_flags(struct usb2_device
 		}
 		if (temp > 0) {
 			if (req->bmRequestType & UT_READ) {
+#if USB_HAVE_USER_IO
 				if (flags & USB_USER_DATA_PTR) {
 					USB_XFER_UNLOCK(xfer);
 					err = usb2_copy_out_user(xfer->frbuffers + 1,
@@ -417,10 +425,10 @@ usb2_do_request_flags(struct usb2_device
 						err = USB_ERR_INVAL;
 						break;
 					}
-				} else {
+				} else
+#endif
 					usb2_copy_out(xfer->frbuffers + 1,
 					    0, data, temp);
-				}
 			}
 		}
 		/*

Modified: head/sys/dev/usb/usb_transfer.c
==============================================================================
--- head/sys/dev/usb/usb_transfer.c	Fri Mar 20 21:47:26 2009	(r190179)
+++ head/sys/dev/usb/usb_transfer.c	Fri Mar 20 21:48:11 2009	(r190180)
@@ -191,6 +191,7 @@ usb2_get_dma_delay(struct usb2_bus *bus)
  *    0: Success
  * Else: Failure
  *------------------------------------------------------------------------*/
+#if USB_HAVE_BUSDMA
 uint8_t
 usb2_transfer_setup_sub_malloc(struct usb2_setup_params *parm,
     struct usb2_page_cache **ppc, uint32_t size, uint32_t align,
@@ -301,6 +302,7 @@ usb2_transfer_setup_sub_malloc(struct us
 	parm->dma_page_ptr = pg;
 	return (0);
 }
+#endif
 
 /*------------------------------------------------------------------------*
  *	usb2_transfer_setup_sub - transfer setup subroutine
@@ -643,6 +645,7 @@ usb2_transfer_setup_sub(struct usb2_setu
 	if (parm->bufsize_max < parm->bufsize) {
 		parm->bufsize_max = parm->bufsize;
 	}
+#if USB_HAVE_BUSDMA
 	if (xfer->flags_int.bdma_enable) {
 		/*
 		 * Setup "dma_page_ptr".
@@ -670,6 +673,7 @@ usb2_transfer_setup_sub(struct usb2_setu
 		parm->dma_page_ptr += (2 * n_frbuffers);
 		parm->dma_page_ptr += (parm->bufsize / USB_PAGE_SIZE);
 	}
+#endif
 	if (zmps) {
 		/* correct maximum data length */
 		xfer->max_data_length = 0;
@@ -694,7 +698,7 @@ usb2_transfer_setup_sub(struct usb2_setu
 		for (x = 0; x != n_frbuffers; x++) {
 			xfer->frbuffers[x].tag_parent =
 			    &xfer->xroot->dma_parent_tag;
-
+#if USB_HAVE_BUSDMA
 			if (xfer->flags_int.bdma_enable &&
 			    (parm->bufsize_max > 0)) {
 
@@ -705,6 +709,7 @@ usb2_transfer_setup_sub(struct usb2_setu
 					goto done;
 				}
 			}
+#endif
 		}
 	}
 done:
@@ -815,28 +820,31 @@ usb2_transfer_setup(struct usb2_device *
 			info->memory_base = buf;
 			info->memory_size = parm.size[0];
 
+#if USB_HAVE_BUSDMA
 			info->dma_page_cache_start = USB_ADD_BYTES(buf, parm.size[4]);
 			info->dma_page_cache_end = USB_ADD_BYTES(buf, parm.size[5]);
+#endif
 			info->xfer_page_cache_start = USB_ADD_BYTES(buf, parm.size[5]);
 			info->xfer_page_cache_end = USB_ADD_BYTES(buf, parm.size[2]);
 
 			usb2_cv_init(&info->cv_drain, "WDRAIN");
 
 			info->xfer_mtx = xfer_mtx;
-
+#if USB_HAVE_BUSDMA
 			usb2_dma_tag_setup(&info->dma_parent_tag,
 			    parm.dma_tag_p, udev->bus->dma_parent_tag[0].tag,
-			    xfer_mtx, &usb2_bdma_done_event, info, 32, parm.dma_tag_max);
+			    xfer_mtx, &usb2_bdma_done_event, 32, parm.dma_tag_max);
+#endif
 
 			info->bus = udev->bus;
 			info->udev = udev;
 
 			TAILQ_INIT(&info->done_q.head);
 			info->done_q.command = &usb2_callback_wrapper;
-
+#if USB_HAVE_BUSDMA
 			TAILQ_INIT(&info->dma_q.head);
 			info->dma_q.command = &usb2_bdma_work_loop;
-
+#endif
 			info->done_m[0].hdr.pm_callback = &usb2_callback_proc;
 			info->done_m[0].xroot = info;
 			info->done_m[1].hdr.pm_callback = &usb2_callback_proc;
@@ -1084,6 +1092,7 @@ usb2_transfer_unsetup_sub(struct usb2_xf
 
 	USB_BUS_UNLOCK(info->bus);
 
+#if USB_HAVE_BUSDMA
 	/* free DMA'able memory, if any */
 	pc = info->dma_page_cache_start;
 	while (pc != info->dma_page_cache_end) {
@@ -1100,6 +1109,7 @@ usb2_transfer_unsetup_sub(struct usb2_xf
 
 	/* free all DMA tags */
 	usb2_dma_tag_unsetup(&info->dma_parent_tag);
+#endif
 
 	usb2_cv_destroy(&info->cv_drain);
 
@@ -1161,9 +1171,10 @@ usb2_transfer_unsetup(struct usb2_xfer *
 
 		usb2_transfer_drain(xfer);
 
+#if USB_HAVE_BUSDMA
 		if (xfer->flags_int.bdma_enable)
 			needs_delay = 1;
-
+#endif
 		/*
 		 * NOTE: default pipe does not have an
 		 * interface, even if pipe->iface_index == 0
@@ -1412,9 +1423,10 @@ usb2_start_hardware(struct usb2_xfer *xf
 	/* clear "did_close" flag */
 	xfer->flags_int.did_close = 0;
 
+#if USB_HAVE_BUSDMA
 	/* clear "bdma_setup" flag */
 	xfer->flags_int.bdma_setup = 0;
-
+#endif
 	/* by default we cannot cancel any USB transfer immediately */
 	xfer->flags_int.can_cancel_immed = 0;
 
@@ -1507,11 +1519,13 @@ usb2_start_hardware(struct usb2_xfer *xf
 	 * Check if BUS-DMA support is enabled and try to load virtual
 	 * buffers into DMA, if any:
 	 */
+#if USB_HAVE_BUSDMA
 	if (xfer->flags_int.bdma_enable) {
 		/* insert the USB transfer last in the BUS-DMA queue */
 		usb2_command_wrapper(&xfer->xroot->dma_q, xfer);
 		return;
 	}
+#endif
 	/*
 	 * Enter the USB transfer into the Host Controller or
 	 * Device Controller schedule:
@@ -1923,12 +1937,13 @@ usb2_callback_wrapper(struct usb2_xfer_q
 		} else {
 			/* set transferred state */
 			xfer->usb2_state = USB_ST_TRANSFERRED;
-
+#if USB_HAVE_BUSDMA
 			/* sync DMA memory, if any */
 			if (xfer->flags_int.bdma_enable &&
 			    (!xfer->flags_int.bdma_no_post_sync)) {
 				usb2_bdma_post_sync(xfer);
 			}
+#endif
 		}
 	}
 
@@ -2042,8 +2057,6 @@ usb2_transfer_enqueue(struct usb2_xfer_q
 void
 usb2_transfer_done(struct usb2_xfer *xfer, usb2_error_t error)
 {
-	struct usb2_xfer_queue *pq;
-
 	USB_BUS_LOCK_ASSERT(xfer->xroot->bus, MA_OWNED);
 
 	DPRINTF("err=%s\n", usb2_errstr(error));
@@ -2070,7 +2083,10 @@ usb2_transfer_done(struct usb2_xfer *xfe
 	 */
 	usb2_transfer_dequeue(xfer);
 
+#if USB_HAVE_BUSDMA
 	if (mtx_owned(xfer->xroot->xfer_mtx)) {
+		struct usb2_xfer_queue *pq;
+
 		/*
 		 * If the private USB lock is not locked, then we assume
 		 * that the BUS-DMA load stage has been passed:
@@ -2082,6 +2098,7 @@ usb2_transfer_done(struct usb2_xfer *xfe
 			usb2_command_wrapper(pq, NULL);
 		}
 	}
+#endif
 	/* keep some statistics */
 	if (xfer->error) {
 		xfer->xroot->bus->stats_err.uds_requests

Modified: head/sys/dev/usb/usb_transfer.h
==============================================================================
--- head/sys/dev/usb/usb_transfer.h	Fri Mar 20 21:47:26 2009	(r190179)
+++ head/sys/dev/usb/usb_transfer.h	Fri Mar 20 21:48:11 2009	(r190180)
@@ -36,23 +36,33 @@ struct usb2_done_msg {
 	struct usb2_xfer_root *xroot;
 };
 
+#define	USB_DMATAG_TO_XROOT(dpt)				\
+  ((struct usb2_xfer_root *)(					\
+   ((uint8_t *)(dpt)) -						\
+   ((uint8_t *)&((struct usb2_xfer_root *)0)->dma_parent_tag) +	\
+   ((uint8_t *)0)))
+
 /*
  * The following structure is used to keep information about memory
  * that should be automatically freed at the moment all USB transfers
  * have been freed.
  */
 struct usb2_xfer_root {
+	struct usb2_dma_parent_tag dma_parent_tag;
+#if USB_HAVE_BUSDMA
 	struct usb2_xfer_queue dma_q;
+#endif
 	struct usb2_xfer_queue done_q;
 	struct usb2_done_msg done_m[2];
 	struct cv cv_drain;
-	struct usb2_dma_parent_tag dma_parent_tag;
 
 	struct usb2_process *done_p;	/* pointer to callback process */
 	void   *memory_base;
 	struct mtx *xfer_mtx;	/* cannot be changed during operation */
+#if USB_HAVE_BUSDMA
 	struct usb2_page_cache *dma_page_cache_start;
 	struct usb2_page_cache *dma_page_cache_end;
+#endif
 	struct usb2_page_cache *xfer_page_cache_start;
 	struct usb2_page_cache *xfer_page_cache_end;
 	struct usb2_bus *bus;		/* pointer to USB bus (cached) */

Modified: head/sys/dev/usb/usb_util.c
==============================================================================
--- head/sys/dev/usb/usb_util.c	Fri Mar 20 21:47:26 2009	(r190179)
+++ head/sys/dev/usb/usb_util.c	Fri Mar 20 21:48:11 2009	(r190180)
@@ -39,7 +39,7 @@
 #include <dev/usb/usb_bus.h>
 
 /* function prototypes */
-#if (USB_USE_CONDVAR == 0)
+#if (USB_HAVE_CONDVAR == 0)
 static int usb2_msleep(void *chan, struct mtx *mtx, int priority, const char *wmesg, int timo);
 
 #endif
@@ -47,6 +47,7 @@ static int usb2_msleep(void *chan, struc
 /*------------------------------------------------------------------------*
  * device_delete_all_children - delete all children of a device
  *------------------------------------------------------------------------*/

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903202148.n2KLmBD1014532>