# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.492   -> 1.493  
#	drivers/usb/core/hcd.h	1.13    -> 1.14   
#	 include/linux/usb.h	1.46    -> 1.47   
#	drivers/usb/core/hub.c	1.33    -> 1.34   
#	drivers/usb/core/usb.c	1.82    -> 1.83   
#	drivers/usb/core/hcd.c	1.30    -> 1.31   
#	drivers/usb/core/urb.c	1.4     -> 1.5    
#	drivers/usb/host/hc_sl811_rh.c	1.1     -> 1.2    
#	drivers/usb/host/uhci-hcd.h	1.2     -> 1.3    
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/08/18	david-b@pacbell.net	1.493
# [PATCH] misc usbcore cleanups
# 
# Another cleanup patch:
# 
#    - removes more usbcore-internal symbols from sight of device drivers
#        * some are only for the uhci driver
#        * most are shared just a bit more widely
#    - DEVNUM_ROUND_ROBIN is no longer an internal option
#    - usb_root_hub_string() gone, per the FIXME
#    - various kerneldoc fixes and updates
#    - uses legal value (en-us) for root hub strings
#    - hub driver only shows port fixed/removable for compound devices
# --------------------------------------------
#
diff -Nru a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
--- a/drivers/usb/core/hcd.c	Sun Aug 18 20:48:26 2002
+++ b/drivers/usb/core/hcd.c	Sun Aug 18 20:48:26 2002
@@ -289,7 +289,7 @@
 	// language ids
 	if (id == 0) {
 		*data++ = 4; *data++ = 3;	/* 4 bytes string data */
-		*data++ = 0; *data++ = 0;	/* some language id */
+		*data++ = 0x09; *data++ = 0x04;	/* MSFT-speak for "en-us" */
 		return 4;
 
 	// serial number
@@ -585,9 +585,7 @@
 {
 	memset (&bus->devmap, 0, sizeof(struct usb_devmap));
 
-#ifdef DEVNUM_ROUND_ROBIN
 	bus->devnum_next = 1;
-#endif /* DEVNUM_ROUND_ROBIN */
 
 	bus->root_hub = NULL;
 	bus->hcpriv = NULL;
@@ -738,10 +736,10 @@
 /*-------------------------------------------------------------------------*/
 
 /**
- * usb_calc_bus_time: approximate periodic transaction time in nanoseconds
+ * usb_calc_bus_time - approximate periodic transaction time in nanoseconds
  * @speed: from dev->speed; USB_SPEED_{LOW,FULL,HIGH}
  * @is_input: true iff the transaction sends data to the host
- * @is_isoc: true for isochronous transactions, false for interrupt ones
+ * @isoc: true for isochronous transactions, false for interrupt ones
  * @bytecount: how many bytes in the transaction.
  *
  * Returns approximate bus time in nanoseconds for a periodic transaction.
@@ -1286,8 +1284,8 @@
  * This hands the URB from HCD to its USB device driver, using its
  * completion function.  The HCD has freed all per-urb resources
  * (and is done using urb->hcpriv).  It also released all HCD locks;
- * the device driver won't cause deadlocks if it resubmits this URB,
- * and won't confuse things by modifying and resubmitting this one.
+ * the device driver won't cause problems if it frees, modifies,
+ * or resubmits this URB.
  * Bandwidth and other resources will be deallocated.
  *
  * HCDs must not use this for periodic URBs that are still scheduled
diff -Nru a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
--- a/drivers/usb/core/hcd.h	Sun Aug 18 20:48:26 2002
+++ b/drivers/usb/core/hcd.h	Sun Aug 18 20:48:26 2002
@@ -19,6 +19,31 @@
 
 #ifdef __KERNEL__
 
+/* This file contains declarations of usbcore internals that are mostly
+ * used or exposed by Host Controller Drivers.
+ */
+
+/*
+ * USB Packet IDs (PIDs)
+ */
+#define USB_PID_UNDEF_0			0xf0
+#define USB_PID_OUT			0xe1
+#define USB_PID_ACK			0xd2
+#define USB_PID_DATA0			0xc3
+#define USB_PID_PING			0xb4	/* USB 2.0 */
+#define USB_PID_SOF			0xa5
+#define USB_PID_NYET			0x96	/* USB 2.0 */
+#define USB_PID_DATA2			0x87	/* USB 2.0 */
+#define USB_PID_SPLIT			0x78	/* USB 2.0 */
+#define USB_PID_IN			0x69
+#define USB_PID_NAK			0x5a
+#define USB_PID_DATA1			0x4b
+#define USB_PID_PREAMBLE		0x3c	/* Token mode */
+#define USB_PID_ERR			0x3c	/* USB 2.0: handshake mode */
+#define USB_PID_SETUP			0x2d
+#define USB_PID_STALL			0x1e
+#define USB_PID_MDATA			0x0f	/* USB 2.0 */
+
 /*-------------------------------------------------------------------------*/
 
 /*
@@ -234,13 +259,11 @@
 extern void usb_connect(struct usb_device *dev);
 extern void usb_disconnect(struct usb_device **);
 
-#ifndef _LINUX_HUB_H
 /* exported to hub driver ONLY to support usb_reset_device () */
 extern int usb_get_configuration(struct usb_device *dev);
 extern void usb_set_maxpacket(struct usb_device *dev);
 extern void usb_destroy_configuration(struct usb_device *dev);
 extern int usb_set_address(struct usb_device *dev);
-#endif /* _LINUX_HUB_H */
 
 /*-------------------------------------------------------------------------*/
 
@@ -354,9 +377,47 @@
 extern int usb_find_interface_driver (struct usb_device *dev,
 	struct usb_interface *interface);
 
+#define usb_endpoint_halt(dev, ep, out) ((dev)->halted[out] |= (1 << (ep)))
+
+#define usb_endpoint_out(ep_dir)	(!((ep_dir) & USB_DIR_IN))
+
 /* for probe/disconnect with correct module usage counting */
 void *usb_bind_driver(struct usb_driver *driver, struct usb_interface *intf);
 void usb_unbind_driver(struct usb_device *device, struct usb_interface *intf);
+
+extern struct list_head usb_driver_list;
+
+/*
+ * USB device fs stuff
+ */
+
+#ifdef CONFIG_USB_DEVICEFS
+
+/*
+ * these are expected to be called from the USB core/hub thread
+ * with the kernel lock held
+ */
+extern void usbfs_add_bus(struct usb_bus *bus);
+extern void usbfs_remove_bus(struct usb_bus *bus);
+extern void usbfs_add_device(struct usb_device *dev);
+extern void usbfs_remove_device(struct usb_device *dev);
+extern void usbfs_update_special (void);
+
+extern int usbfs_init(void);
+extern void usbfs_cleanup(void);
+
+#else /* CONFIG_USB_DEVICEFS */
+
+static inline void usbfs_add_bus(struct usb_bus *bus) {}
+static inline void usbfs_remove_bus(struct usb_bus *bus) {}
+static inline void usbfs_add_device(struct usb_device *dev) {}
+static inline void usbfs_remove_device(struct usb_device *dev) {}
+static inline void usbfs_update_special (void) {}
+
+static inline int usbfs_init(void) { return 0; }
+static inline void usbfs_cleanup(void) { }
+
+#endif /* CONFIG_USB_DEVICEFS */
 
 /*-------------------------------------------------------------------------*/
 
diff -Nru a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
--- a/drivers/usb/core/hub.c	Sun Aug 18 20:48:26 2002
+++ b/drivers/usb/core/hub.c	Sun Aug 18 20:48:26 2002
@@ -261,9 +261,8 @@
 {
 	struct usb_device *dev = hub->dev;
 	struct usb_hub_status hubstatus;
-	char portstr[USB_MAXCHILDREN + 1];
 	unsigned int pipe;
-	int i, maxp, ret;
+	int maxp, ret;
 
 	hub->descriptor = kmalloc(sizeof(*hub->descriptor), GFP_KERNEL);
 	if (!hub->descriptor) {
@@ -294,9 +293,17 @@
 
 	le16_to_cpus(&hub->descriptor->wHubCharacteristics);
 
-	if (hub->descriptor->wHubCharacteristics & HUB_CHAR_COMPOUND)
-		dbg("part of a compound device");
-	else
+	if (hub->descriptor->wHubCharacteristics & HUB_CHAR_COMPOUND) {
+		int	i;
+		char	portstr [USB_MAXCHILDREN + 1];
+
+		for (i = 0; i < dev->maxchild; i++)
+			portstr[i] = hub->descriptor->DeviceRemovable
+				    [((i + 1) / 8)] & (1 << ((i + 1) % 8))
+				? 'F' : 'R';
+		portstr[dev->maxchild] = 0;
+		dbg("compound device; port removable status: %s", portstr);
+	} else
 		dbg("standalone hub");
 
 	switch (hub->descriptor->wHubCharacteristics & HUB_CHAR_LPSM) {
@@ -370,14 +377,6 @@
 		hub->descriptor->bPwrOn2PwrGood * 2);
 	dbg("hub controller current requirement: %dmA",
 		hub->descriptor->bHubContrCurrent);
-
-	for (i = 0; i < dev->maxchild; i++)
-		portstr[i] = hub->descriptor->DeviceRemovable
-			    [((i + 1) / 8)] & (1 << ((i + 1) % 8))
-			? 'F' : 'R';
-	portstr[dev->maxchild] = 0;
-
-	dbg("port removable status: %s", portstr);
 
 	ret = usb_get_hub_status(dev, &hubstatus);
 	if (ret < 0) {
diff -Nru a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
--- a/drivers/usb/core/urb.c	Sun Aug 18 20:48:26 2002
+++ b/drivers/usb/core/urb.c	Sun Aug 18 20:48:26 2002
@@ -88,15 +88,17 @@
 /*-------------------------------------------------------------------*/
 
 /**
- * usb_submit_urb - asynchronously issue a transfer request for an endpoint
+ * usb_submit_urb - issue an asynchronous transfer request for an endpoint
  * @urb: pointer to the urb describing the request
  * @mem_flags: the type of memory to allocate, see kmalloc() for a list
  *	of valid options for this.
  *
  * This submits a transfer request, and transfers control of the URB
  * describing that request to the USB subsystem.  Request completion will
- * indicated later, asynchronously, by calling the completion handler.
- * This call may be issued in interrupt context.
+ * be indicated later, asynchronously, by calling the completion handler.
+ * The three types of completion are success, error, and unlink
+ * (also called "request cancellation").
+ * URBs may be submitted in interrupt context.
  *
  * The caller must have correctly initialized the URB before submitting
  * it.  Functions such as usb_fill_bulk_urb() and usb_fill_control_urb() are
@@ -148,20 +150,19 @@
  *
  * Memory Flags:
  *
- * General rules for how to decide which mem_flags to use:
- * 
- * Basically the rules are the same as for kmalloc.  There are four
+ * The general rules for how to decide which mem_flags to use
+ * are the same as for kmalloc.  There are four
  * different possible values; GFP_KERNEL, GFP_NOFS, GFP_NOIO and
  * GFP_ATOMIC.
  *
  * GFP_NOFS is not ever used, as it has not been implemented yet.
  *
- * There are three situations you must use GFP_ATOMIC.
- *    a) you are inside a completion handler, an interrupt, bottom half,
- *       tasklet or timer.
- *    b) you are holding a spinlock or rwlock (does not apply to
- *       semaphores)
- *    c) current->state != TASK_RUNNING, this is the case only after
+ * GFP_ATOMIC is used when
+ *   (a) you are inside a completion handler, an interrupt, bottom half,
+ *       tasklet or timer, or
+ *   (b) you are holding a spinlock or rwlock (does not apply to
+ *       semaphores), or
+ *   (c) current->state != TASK_RUNNING, this is the case only after
  *       you've changed it.
  * 
  * GFP_NOIO is used in the block io path and error handling of storage
@@ -169,17 +170,17 @@
  *
  * All other situations use GFP_KERNEL.
  *
- * Specfic rules for how to decide which mem_flags to use:
- *
- *    - start_xmit, timeout, and receive methods of network drivers must
- *      use GFP_ATOMIC (spinlock)
- *    - queuecommand methods of scsi drivers must use GFP_ATOMIC (spinlock)
- *    - If you use a kernel thread with a network driver you must use
- *      GFP_NOIO, unless b) or c) apply
- *    - After you have done a down() you use GFP_KERNEL, unless b) or c)
- *      apply or your are in a storage driver's block io path
- *    - probe and disconnect use GFP_KERNEL unless b) or c) apply
- *    - Changing firmware on a running storage or net device uses
+ * Some more specific rules for mem_flags can be inferred, such as
+ *  (1) start_xmit, timeout, and receive methods of network drivers must
+ *      use GFP_ATOMIC (they are called with a spinlock held);
+ *  (2) queuecommand methods of scsi drivers must use GFP_ATOMIC (also
+ *      called with a spinlock held);
+ *  (3) If you use a kernel thread with a network driver you must use
+ *      GFP_NOIO, unless (b) or (c) apply;
+ *  (4) after you have done a down() you can use GFP_KERNEL, unless (b) or (c)
+ *      apply or your are in a storage driver's block io path;
+ *  (5) USB probe and disconnect can use GFP_KERNEL unless (b) or (c) apply; and
+ *  (6) changing firmware on a running storage or net device uses
  *      GFP_NOIO, unless b) or c) apply
  *
  */
diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
--- a/drivers/usb/core/usb.c	Sun Aug 18 20:48:26 2002
+++ b/drivers/usb/core/usb.c	Sun Aug 18 20:48:26 2002
@@ -1057,56 +1057,6 @@
 }
 
 /*-------------------------------------------------------------------*/
-
-
-/* for returning string descriptors in UTF-16LE */
-static int ascii2utf (char *ascii, __u8 *utf, int utfmax)
-{
-	int retval;
-
-	for (retval = 0; *ascii && utfmax > 1; utfmax -= 2, retval += 2) {
-		*utf++ = *ascii++ & 0x7f;
-		*utf++ = 0;
-	}
-	return retval;
-}
-
-/*
- * root_hub_string is used by each host controller's root hub code,
- * so that they're identified consistently throughout the system.
- */
-int usb_root_hub_string (int id, int serial, char *type, __u8 *data, int len)
-{
-	char buf [30];
-
-	// assert (len > (2 * (sizeof (buf) + 1)));
-	// assert (strlen (type) <= 8);
-
-	// language ids
-	if (id == 0) {
-		*data++ = 4; *data++ = 3;	/* 4 bytes data */
-		*data++ = 0; *data++ = 0;	/* some language id */
-		return 4;
-
-	// serial number
-	} else if (id == 1) {
-		sprintf (buf, "%x", serial);
-
-	// product description
-	} else if (id == 2) {
-		sprintf (buf, "USB %s Root Hub", type);
-
-	// id 3 == vendor description
-
-	// unsupported IDs --> "stall"
-	} else
-	    return 0;
-
-	data [0] = 2 + ascii2utf (buf, data + 2, len - 2);
-	data [1] = 3;
-	return data [0];
-}
-
 /*
  * __usb_get_extra_descriptor() finds a descriptor of specific type in the
  * extra field of the interface and endpoint descriptor structs.
@@ -1221,16 +1171,13 @@
 	 * won't have seen this, but not so for reinit ... 
 	 */
 	dev->descriptor.bMaxPacketSize0 = 8;  /* Start off at 8 bytes  */
-#ifndef DEVNUM_ROUND_ROBIN
-	devnum = find_next_zero_bit(dev->bus->devmap.devicemap, 128, 1);
-#else	/* round_robin alloc of devnums */
+
 	/* Try to allocate the next devnum beginning at bus->devnum_next. */
 	devnum = find_next_zero_bit(dev->bus->devmap.devicemap, 128, dev->bus->devnum_next);
 	if (devnum >= 128)
 		devnum = find_next_zero_bit(dev->bus->devmap.devicemap, 128, 1);
 
 	dev->bus->devnum_next = ( devnum >= 127 ? 1 : devnum + 1);
-#endif	/* round_robin alloc of devnums */
 
 	if (devnum < 128) {
 		set_bit(devnum, dev->bus->devmap.devicemap);
@@ -1649,7 +1596,6 @@
 EXPORT_SYMBOL(usb_driver_release_interface);
 EXPORT_SYMBOL(usb_match_id);
 
-EXPORT_SYMBOL(usb_root_hub_string);
 EXPORT_SYMBOL(usb_new_device);
 EXPORT_SYMBOL(usb_reset_device);
 EXPORT_SYMBOL(usb_connect);
diff -Nru a/drivers/usb/host/hc_sl811_rh.c b/drivers/usb/host/hc_sl811_rh.c
--- a/drivers/usb/host/hc_sl811_rh.c	Sun Aug 18 20:48:26 2002
+++ b/drivers/usb/host/hc_sl811_rh.c	Sun Aug 18 20:48:26 2002
@@ -21,6 +21,8 @@
  *
  *-------------------------------------------------------------------------*/
 
+/* FIXME:  reuse the root hub framework in usbcore, shrinking this code.  */
+
 #ifdef DEBUG
 #undef DEBUG
 #endif
@@ -229,6 +231,52 @@
 
 /*-------------------------------------------------------------------------*/
 
+/* for returning string descriptors in UTF-16LE */
+static int ascii2utf (char *ascii, __u8 *utf, int utfmax)
+{
+	int retval;
+
+	for (retval = 0; *ascii && utfmax > 1; utfmax -= 2, retval += 2) {
+		*utf++ = *ascii++ & 0x7f;
+		*utf++ = 0;
+	}
+	return retval;
+}
+
+static int root_hub_string (int id, int serial, char *type, __u8 *data, int len)
+{
+	char buf [30];
+
+	// assert (len > (2 * (sizeof (buf) + 1)));
+	// assert (strlen (type) <= 8);
+
+	// language ids
+	if (id == 0) {
+		*data++ = 4; *data++ = 3;	/* 4 bytes data */
+		*data++ = 0; *data++ = 0;	/* some language id */
+		return 4;
+
+	// serial number
+	} else if (id == 1) {
+		sprintf (buf, "%x", serial);
+
+	// product description
+	} else if (id == 2) {
+		sprintf (buf, "USB %s Root Hub", type);
+
+	// id 3 == vendor description
+
+	// unsupported IDs --> "stall"
+	} else
+	    return 0;
+
+	data [0] = 2 + ascii2utf (buf, data + 2, len - 2);
+	data [1] = 3;
+	return data [0];
+}
+
+/*-------------------------------------------------------------------------*/
+
 /* helper macro */
 #define OK(x) 			len = (x); break
 
@@ -409,7 +457,7 @@
 			OK (len);
 
 		case (0x03):	/* string descriptors */
-			len = usb_root_hub_string (wValue & 0xff, (int) (long) 0,
+			len = root_hub_string (wValue & 0xff, (int) (long) 0,
 						   "SL811HS", data, wLength);
 			if (len > 0) {
 				data_buf = data;
diff -Nru a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h
--- a/drivers/usb/host/uhci-hcd.h	Sun Aug 18 20:48:26 2002
+++ b/drivers/usb/host/uhci-hcd.h	Sun Aug 18 20:48:26 2002
@@ -4,6 +4,9 @@
 #include <linux/list.h>
 #include <linux/usb.h>
 
+#define usb_packetid(pipe)	(usb_pipein(pipe) ? USB_PID_IN : USB_PID_OUT)
+#define PIPE_DEVEP_MASK		0x0007ff00
+
 /*
  * Universal Host Controller Interface data structures and defines
  */
diff -Nru a/include/linux/usb.h b/include/linux/usb.h
--- a/include/linux/usb.h	Sun Aug 18 20:48:26 2002
+++ b/include/linux/usb.h	Sun Aug 18 20:48:26 2002
@@ -58,27 +58,6 @@
 #define USB_ENDPOINT_XFER_INT		3
 
 /*
- * USB Packet IDs (PIDs)
- */
-#define USB_PID_UNDEF_0			0xf0
-#define USB_PID_OUT			0xe1
-#define USB_PID_ACK			0xd2
-#define USB_PID_DATA0			0xc3
-#define USB_PID_PING			0xb4	/* USB 2.0 */
-#define USB_PID_SOF			0xa5
-#define USB_PID_NYET			0x96	/* USB 2.0 */
-#define USB_PID_DATA2			0x87	/* USB 2.0 */
-#define USB_PID_SPLIT			0x78	/* USB 2.0 */
-#define USB_PID_IN			0x69
-#define USB_PID_NAK			0x5a
-#define USB_PID_DATA1			0x4b
-#define USB_PID_PREAMBLE		0x3c	/* Token mode */
-#define USB_PID_ERR			0x3c	/* USB 2.0: handshake mode */
-#define USB_PID_SETUP			0x2d
-#define USB_PID_STALL			0x1e
-#define USB_PID_MDATA			0x0f	/* USB 2.0 */
-
-/*
  * Standard requests
  */
 #define USB_REQ_GET_STATUS		0x00
@@ -318,8 +297,6 @@
 
 struct usb_operations;
 
-#define DEVNUM_ROUND_ROBIN	/***** OPTION *****/
-
 /*
  * Allocated per bus we have
  */
@@ -327,9 +304,7 @@
 	int busnum;			/* Bus number (in order of reg) */
 	char *bus_name;			/* stable id (PCI slot_name etc) */
 
-#ifdef DEVNUM_ROUND_ROBIN
 	int devnum_next;		/* Next open device number in round-robin allocation */
-#endif /* DEVNUM_ROUND_ROBIN */
 
 	struct usb_devmap devmap;	/* device address allocation map */
 	struct usb_operations *op;	/* Operations (specific to the HC) */
@@ -353,10 +328,6 @@
 	atomic_t refcnt;
 };
 
-// FIXME:  root_hub_string vanishes when "usb_hcd" conversion is done,
-// along with pre-hcd versions of the OHCI and UHCI drivers.
-extern int usb_root_hub_string(int id, int serial,
-		char *type, __u8 *data, int len);
 
 /* -------------------------------------------------------------------------- */
 
@@ -745,7 +716,7 @@
 /**
  * struct urb - USB Request Block
  * @urb_list: For use by current owner of the URB.
- * @pipe: Holds endpoint number, direction, type, and max packet size.
+ * @pipe: Holds endpoint number, direction, type, and more.
  *	Create these values with the eight macros available;
  *	usb_{snd,rcv}TYPEpipe(dev,endpoint), where the type is "ctrl"
  *	(control), "bulk", "int" (interrupt), or "iso" (isochronous).
@@ -774,7 +745,8 @@
  * @transfer_buffer_length: How big is transfer_buffer.  The transfer may
  *	be broken up into chunks according to the current maximum packet
  *	size for the endpoint, which is a function of the configuration
- *	and is encoded in the pipe.
+ *	and is encoded in the pipe.  When the length is zero, neither
+ *	transfer_buffer nor transfer_dma is used.
  * @actual_length: This is read in non-iso completion functions, and
  *	it tells how many bytes (out of transfer_buffer_length) were
  *	transferred.  It will normally be the same as requested, unless
@@ -787,7 +759,7 @@
  *	(Not used when URB_NO_DMA_MAP is set.)
  * @setup_dma: For control transfers with URB_NO_DMA_MAP set, the device
  * 	driver has provided this DMA address for the setup packet.  The
- * 	host controller driver should use instead of setup_buffer.
+ * 	host controller driver should use this instead of setup_buffer.
  * 	If there is a data phase, its buffer is identified by transfer_dma.
  * @start_frame: Returns the initial frame for interrupt or isochronous
  *	transfers.
@@ -817,8 +789,9 @@
  * taken from the general page pool.  That is provided by transfer_buffer
  * (control requests also use setup_packet), and host controller drivers
  * perform a dma mapping (and unmapping) for each buffer transferred.  Those
- * mapping operations can be expensive on some platforms (such using a dma
- * bounce buffer), although they're cheap on commodity x86 and ppc hardware.
+ * mapping operations can be expensive on some platforms (perhaps using a dma
+ * bounce buffer or talking to an IOMMU),
+ * although they're cheap on commodity x86 and ppc hardware.
  *
  * Alternatively, drivers may pass the URB_NO_DMA_MAP transfer flag, which
  * tells the host controller driver that no such mapping is needed since
@@ -884,7 +857,7 @@
  * things that a completion handler should do is check the status field.
  * The status field is provided for all URBs.  It is used to report
  * unlinked URBs, and status for all non-ISO transfers.  It should not
- * be examined outside of the completion handler.
+ * be examined before the URB is returned to the completion handler.
  *
  * The context field is normally used to link URBs back to the relevant
  * driver or request state.
@@ -1075,7 +1048,6 @@
 	int timeout);
 
 /* wrappers around usb_control_msg() for the most common standard requests */
-extern int usb_clear_halt(struct usb_device *dev, int pipe);
 extern int usb_get_descriptor(struct usb_device *dev, unsigned char desctype,
 	unsigned char descindex, void *buf, int size);
 extern int usb_get_device_descriptor(struct usb_device *dev);
@@ -1085,6 +1057,9 @@
 	unsigned short langid, unsigned char index, void *buf, int size);
 extern int usb_string(struct usb_device *dev, int index,
 	char *buf, size_t size);
+
+/* wrappers that also update important state inside usbcore */
+extern int usb_clear_halt(struct usb_device *dev, int pipe);
 extern int usb_set_configuration(struct usb_device *dev, int configuration);
 extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate);
 
@@ -1123,9 +1098,10 @@
  *
  *  - max size:		bits 0-1	[Historical; now gone.]
  *  - direction:	bit 7		(0 = Host-to-Device [Out],
- *					 1 = Device-to-Host [In])
- *  - device:		bits 8-14
- *  - endpoint:		bits 15-18
+ *					 1 = Device-to-Host [In] ...
+ *					like endpoint bEndpointAddress)
+ *  - device:		bits 8-14       ... bit positions known to uhci-hcd
+ *  - endpoint:		bits 15-18      ... bit positions known to uhci-hcd
  *  - Data0/1:		bit 19		[Historical; now gone. ]
  *  - lowspeed:		bit 26		[Historical; now gone. ]
  *  - pipe type:	bits 30-31	(00 = isochronous, 01 = interrupt,
@@ -1146,10 +1122,9 @@
 #define usb_maxpacket(dev, pipe, out)	(out \
 				? (dev)->epmaxpacketout[usb_pipeendpoint(pipe)] \
 				: (dev)->epmaxpacketin [usb_pipeendpoint(pipe)] )
-#define usb_packetid(pipe)	(((pipe) & USB_DIR_IN) ? USB_PID_IN : USB_PID_OUT)
 
-#define usb_pipeout(pipe)	((((pipe) >> 7) & 1) ^ 1)
-#define usb_pipein(pipe)	(((pipe) >> 7) & 1)
+#define usb_pipein(pipe)	((pipe) & USB_DIR_IN)
+#define usb_pipeout(pipe)	(!usb_pipein(pipe))
 #define usb_pipedevice(pipe)	(((pipe) >> 8) & 0x7f)
 #define usb_pipeendpoint(pipe)	(((pipe) >> 15) & 0xf)
 #define usb_pipetype(pipe)	(((pipe) >> 30) & 3)
@@ -1158,19 +1133,16 @@
 #define usb_pipecontrol(pipe)	(usb_pipetype((pipe)) == PIPE_CONTROL)
 #define usb_pipebulk(pipe)	(usb_pipetype((pipe)) == PIPE_BULK)
 
-#define PIPE_DEVEP_MASK		0x0007ff00
-
-/* The D0/D1 toggle bits */
+/* The D0/D1 toggle bits ... USE WITH CAUTION (they're almost hcd-internal) */
 #define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> (ep)) & 1)
 #define	usb_dotoggle(dev, ep, out)  ((dev)->toggle[out] ^= (1 << (ep)))
 #define usb_settoggle(dev, ep, out, bit) ((dev)->toggle[out] = ((dev)->toggle[out] & ~(1 << (ep))) | ((bit) << (ep)))
 
-/* Endpoint halt control/status */
-#define usb_endpoint_out(ep_dir)	((((ep_dir) >> 7) & 1) ^ 1)
-#define usb_endpoint_halt(dev, ep, out) ((dev)->halted[out] |= (1 << (ep)))
+/* Endpoint halt control/status ... likewise USE WITH CAUTION */
 #define usb_endpoint_running(dev, ep, out) ((dev)->halted[out] &= ~(1 << (ep)))
 #define usb_endpoint_halted(dev, ep, out) ((dev)->halted[out] & (1 << (ep)))
 
+
 static inline unsigned int __create_pipe(struct usb_device *dev, unsigned int endpoint)
 {
 	return (dev->devnum << 8) | (endpoint << 15);
@@ -1210,47 +1182,6 @@
 #define info(format, arg...) printk(KERN_INFO __FILE__ ": " format "\n" , ## arg)
 #define warn(format, arg...) printk(KERN_WARNING __FILE__ ": " format "\n" , ## arg)
 
-
-/* -------------------------------------------------------------------------- */
-
-/*
- * driver list
- * exported only for usbfs (not visible outside usbcore)
- */
-
-extern struct list_head usb_driver_list;
-
-/*
- * USB device fs stuff
- */
-
-#ifdef CONFIG_USB_DEVICEFS
-
-/*
- * these are expected to be called from the USB core/hub thread
- * with the kernel lock held
- */
-extern void usbfs_add_bus(struct usb_bus *bus);
-extern void usbfs_remove_bus(struct usb_bus *bus);
-extern void usbfs_add_device(struct usb_device *dev);
-extern void usbfs_remove_device(struct usb_device *dev);
-extern void usbfs_update_special (void);
-
-extern int usbfs_init(void);
-extern void usbfs_cleanup(void);
-
-#else /* CONFIG_USB_DEVICEFS */
-
-static inline void usbfs_add_bus(struct usb_bus *bus) {}
-static inline void usbfs_remove_bus(struct usb_bus *bus) {}
-static inline void usbfs_add_device(struct usb_device *dev) {}
-static inline void usbfs_remove_device(struct usb_device *dev) {}
-static inline void usbfs_update_special (void) {}
-
-static inline int usbfs_init(void) { return 0; }
-static inline void usbfs_cleanup(void) { }
-
-#endif /* CONFIG_USB_DEVICEFS */
 
 #endif  /* __KERNEL__ */
 
