<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From david-b@pacbell.net Sat May  7 14:09:28 2005
From: David Brownell &lt;david-b@pacbell.net&gt;
To: Greg KH &lt;greg@kroah.com&gt;
Subject: USB: net2280 updates (sparse, SETUP api change)
Date: Sat, 7 May 2005 13:05:18 -0700
Message-Id: &lt;200505071305.18555.david-b@pacbell.net&gt;

This is mostly "sparse" related updates, one of which was a missing
le32_to_cpu() should have affected big-endian hardware.

Notable is the API change:  setup packets are now provided in USB
byte order.  This affects only big-endian hardware, and the gadget
drivers have been updated in a separate patch. 

Signed-off-by: David Brownell &lt;dbrownell@users.sourceforge.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

---
 drivers/usb/gadget/net2280.c |   51 ++++++++++++++++++++++++-------------------
 1 files changed, 29 insertions(+), 22 deletions(-)

--- gregkh-2.6.orig/drivers/usb/gadget/net2280.c	2005-05-09 09:07:09.000000000 -0700
+++ gregkh-2.6/drivers/usb/gadget/net2280.c	2005-05-09 16:56:44.000000000 -0700
@@ -448,7 +448,7 @@
 #elif	defined(CONFIG_PPC) &amp;&amp; !defined(CONFIG_NOT_COHERENT_CACHE)
 #define USE_KMALLOC
 
-#elif	defined(CONFIG_MIPS) &amp;&amp; !defined(CONFIG_NONCOHERENT_IO)
+#elif	defined(CONFIG_MIPS) &amp;&amp; !defined(CONFIG_DMA_NONCOHERENT)
 #define USE_KMALLOC
 
 /* FIXME there are other cases, including an x86-64 one ...  */
@@ -1113,7 +1113,7 @@
 		if (ep-&gt;in_fifo_validate)
 			dmactl |= (1 &lt;&lt; DMA_FIFO_VALIDATE);
 		list_for_each_entry (entry, &amp;ep-&gt;queue, queue) {
-			u32		dmacount;
+			__le32		dmacount;
 
 			if (entry == req)
 				continue;
@@ -1238,7 +1238,7 @@
 				&amp;ep-&gt;dma-&gt;dmadesc);
 			if (req-&gt;td-&gt;dmacount &amp; dma_done_ie)
 				writel (readl (&amp;ep-&gt;dma-&gt;dmacount)
-						| dma_done_ie,
+						| le32_to_cpu(dma_done_ie),
 					&amp;ep-&gt;dma-&gt;dmacount);
 		} else {
 			struct net2280_request	*prev;
@@ -1779,6 +1779,9 @@
 	list_add_tail (&amp;dev-&gt;ep [6].ep.ep_list, &amp;dev-&gt;gadget.ep_list);
 }
 
+/* just declare this in any driver that really need it */
+extern int net2280_set_fifo_mode (struct usb_gadget *gadget, int mode);
+
 /**
  * net2280_set_fifo_mode - change allocation of fifo buffers
  * @gadget: access to the net2280 device that will be updated
@@ -2382,9 +2385,9 @@
 		cpu_to_le32s (&amp;u.raw [0]);
 		cpu_to_le32s (&amp;u.raw [1]);
 
-		le16_to_cpus (&amp;u.r.wValue);
-		le16_to_cpus (&amp;u.r.wIndex);
-		le16_to_cpus (&amp;u.r.wLength);
+#define	w_value		le16_to_cpup (&amp;u.r.wValue)
+#define	w_index		le16_to_cpup (&amp;u.r.wIndex)
+#define	w_length	le16_to_cpup (&amp;u.r.wLength)
 
 		/* ack the irq */
 		writel (1 &lt;&lt; SETUP_PACKET_INTERRUPT, &amp;dev-&gt;regs-&gt;irqstat0);
@@ -2413,25 +2416,25 @@
 		switch (u.r.bRequest) {
 		case USB_REQ_GET_STATUS: {
 			struct net2280_ep	*e;
-			u16			status;
+			__le32			status;
 
 			/* hw handles device and interface status */
 			if (u.r.bRequestType != (USB_DIR_IN|USB_RECIP_ENDPOINT))
 				goto delegate;
-			if ((e = get_ep_by_addr (dev, u.r.wIndex)) == 0
-					|| u.r.wLength &gt; 2)
+			if ((e = get_ep_by_addr (dev, w_index)) == 0
+					|| w_length &gt; 2)
 				goto do_stall;
 
 			if (readl (&amp;e-&gt;regs-&gt;ep_rsp)
 					&amp; (1 &lt;&lt; SET_ENDPOINT_HALT))
-				status = __constant_cpu_to_le16 (1);
+				status = __constant_cpu_to_le32 (1);
 			else
-				status = __constant_cpu_to_le16 (0);
+				status = __constant_cpu_to_le32 (0);
 
 			/* don't bother with a request object! */
 			writel (0, &amp;dev-&gt;epregs [0].ep_irqenb);
-			set_fifo_bytecount (ep, u.r.wLength);
-			writel (status, &amp;dev-&gt;epregs [0].ep_data);
+			set_fifo_bytecount (ep, w_length);
+			writel ((__force u32)status, &amp;dev-&gt;epregs [0].ep_data);
 			allow_status (ep);
 			VDEBUG (dev, "%s stat %02x\n", ep-&gt;ep.name, status);
 			goto next_endpoints;
@@ -2443,10 +2446,10 @@
 			/* hw handles device features */
 			if (u.r.bRequestType != USB_RECIP_ENDPOINT)
 				goto delegate;
-			if (u.r.wValue != USB_ENDPOINT_HALT
-					|| u.r.wLength != 0)
+			if (w_value != USB_ENDPOINT_HALT
+					|| w_length != 0)
 				goto do_stall;
-			if ((e = get_ep_by_addr (dev, u.r.wIndex)) == 0)
+			if ((e = get_ep_by_addr (dev, w_index)) == 0)
 				goto do_stall;
 			clear_halt (e);
 			allow_status (ep);
@@ -2460,10 +2463,10 @@
 			/* hw handles device features */
 			if (u.r.bRequestType != USB_RECIP_ENDPOINT)
 				goto delegate;
-			if (u.r.wValue != USB_ENDPOINT_HALT
-					|| u.r.wLength != 0)
+			if (w_value != USB_ENDPOINT_HALT
+					|| w_length != 0)
 				goto do_stall;
-			if ((e = get_ep_by_addr (dev, u.r.wIndex)) == 0)
+			if ((e = get_ep_by_addr (dev, w_index)) == 0)
 				goto do_stall;
 			set_halt (e);
 			allow_status (ep);
@@ -2473,10 +2476,10 @@
 			break;
 		default:
 delegate:
-			VDEBUG (dev, "setup %02x.%02x v%04x i%04x "
+			VDEBUG (dev, "setup %02x.%02x v%04x i%04x l%04x"
 				"ep_cfg %08x\n",
 				u.r.bRequestType, u.r.bRequest,
-				u.r.wValue, u.r.wIndex,
+				w_value, w_index, w_length,
 				readl (&amp;ep-&gt;regs-&gt;ep_cfg));
 			spin_unlock (&amp;dev-&gt;lock);
 			tmp = dev-&gt;driver-&gt;setup (&amp;dev-&gt;gadget, &amp;u.r);
@@ -2497,6 +2500,10 @@
 		 */
 	}
 
+#undef	w_value
+#undef	w_index
+#undef	w_length
+
 next_endpoints:
 	/* endpoint data irq ? */
 	scratch = stat &amp; 0x7f;
@@ -2653,7 +2660,7 @@
 				restart_dma (ep);
 			else if (ep-&gt;is_in &amp;&amp; use_dma_chaining) {
 				struct net2280_request	*req;
-				u32			dmacount;
+				__le32			dmacount;
 
 				/* the descriptor at the head of the chain
 				 * may still have VALID_BIT clear; that's
</pre></body></html>