ChangeSet 1.1595.7.23, 2003/07/30 14:24:29-07:00, stern@rowland.harvard.edu

[PATCH] USB: Rename usb_connect() to usb_choose_address()

This revised patch includes the change that David Brownell asked for.  It
renames usb_connect() to usb_choose_address(), no longer exports the
function, and adds equivalent functionality to usb_register_root_hub().
It also removes the unnecessary (and incorrect) assignment to
bMaxPacketSize0.


 drivers/usb/core/hcd.c         |    8 +++++++-
 drivers/usb/core/hcd.h         |    2 +-
 drivers/usb/core/hub.c         |    2 +-
 drivers/usb/core/usb.c         |   11 +++--------
 drivers/usb/host/ehci-hcd.c    |    1 -
 drivers/usb/host/hc_sl811_rh.c |    5 ++++-
 drivers/usb/host/ohci-hcd.c    |    1 -
 drivers/usb/host/uhci-hcd.c    |    1 -
 8 files changed, 16 insertions(+), 15 deletions(-)


diff -Nru a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
--- a/drivers/usb/core/hcd.c	Fri Aug  1 10:54:34 2003
+++ b/drivers/usb/core/hcd.c	Fri Aug  1 10:54:34 2003
@@ -734,14 +734,20 @@
  * The USB host controller calls this function to register the root hub
  * properly with the USB subsystem.  It sets up the device properly in
  * the driverfs tree, and then calls usb_new_device() to register the
- * usb device.
+ * usb device.  It also assigns the root hub's USB address (always 1).
  */
 int usb_register_root_hub (struct usb_device *usb_dev, struct device *parent_dev)
 {
+	const int devnum = 1;
 	int retval;
 
 	sprintf (&usb_dev->dev.bus_id[0], "usb%d", usb_dev->bus->busnum);
 	usb_dev->state = USB_STATE_DEFAULT;
+
+	usb_dev->devnum = devnum;
+	usb_dev->bus->devnum_next = devnum + 1;
+	set_bit (devnum, usb_dev->bus->devmap.devicemap);
+
 	retval = usb_new_device (usb_dev, parent_dev);
 	if (retval)
 		dev_err (parent_dev, "can't register root hub for %s, %d\n",
diff -Nru a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
--- a/drivers/usb/core/hcd.h	Fri Aug  1 10:54:34 2003
+++ b/drivers/usb/core/hcd.h	Fri Aug  1 10:54:34 2003
@@ -246,7 +246,7 @@
 
 /* Enumeration is only for the hub driver, or HCD virtual root hubs */
 extern int usb_new_device(struct usb_device *dev, struct device *parent);
-extern void usb_connect(struct usb_device *dev);
+extern void usb_choose_address(struct usb_device *dev);
 extern void usb_disconnect(struct usb_device **);
 
 /* exported to hub driver ONLY to support usb_reset_device () */
diff -Nru a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
--- a/drivers/usb/core/hub.c	Fri Aug  1 10:54:34 2003
+++ b/drivers/usb/core/hub.c	Fri Aug  1 10:54:34 2003
@@ -932,7 +932,7 @@
 		}
 
 		/* Find a new address for it */
-		usb_connect(dev);
+		usb_choose_address(dev);
 
 		/* Set up TT records, if needed  */
 		if (hub->tt) {
diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
--- a/drivers/usb/core/usb.c	Fri Aug  1 10:54:34 2003
+++ b/drivers/usb/core/usb.c	Fri Aug  1 10:54:34 2003
@@ -945,25 +945,21 @@
 }
 
 /**
- * usb_connect - pick device address (usbcore-internal)
+ * usb_choose_address - pick device address (usbcore-internal)
  * @dev: newly detected device (in DEFAULT state)
  *
  * Picks a device address.  It's up to the hub (or root hub) driver
  * to handle and manage enumeration, starting from the DEFAULT state.
- * Only hub drivers (including virtual root hub drivers for host
+ * Only hub drivers (but not virtual root hub drivers for host
  * controllers) should ever call this.
  */
-void usb_connect(struct usb_device *dev)
+void usb_choose_address(struct usb_device *dev)
 {
 	int devnum;
 	// FIXME needs locking for SMP!!
 	/* why? this is called only from the hub thread, 
 	 * which hopefully doesn't run on multiple CPU's simultaneously 8-)
-	 * ... it's also called from modprobe/rmmod/apmd threads as part
-	 * of virtual root hub init/reinit.  In the init case, the hub code 
-	 * won't have seen this, but not so for reinit ... 
 	 */
-	dev->descriptor.bMaxPacketSize0 = 8;  /* Start off at 8 bytes  */
 
 	/* 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);
@@ -1607,7 +1603,6 @@
 
 EXPORT_SYMBOL(usb_new_device);
 EXPORT_SYMBOL(usb_reset_device);
-EXPORT_SYMBOL(usb_connect);
 EXPORT_SYMBOL(usb_disconnect);
 
 EXPORT_SYMBOL(__usb_get_extra_descriptor);
diff -Nru a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
--- a/drivers/usb/host/ehci-hcd.c	Fri Aug  1 10:54:34 2003
+++ b/drivers/usb/host/ehci-hcd.c	Fri Aug  1 10:54:34 2003
@@ -497,7 +497,6 @@
 	 * Before this point the HC was idle/ready.  After, khubd
 	 * and device drivers may start it running.
 	 */
-	usb_connect (udev);
 	udev->speed = USB_SPEED_HIGH;
 	if (hcd_register_root (hcd) != 0) {
 		if (hcd->state == USB_STATE_RUNNING)
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	Fri Aug  1 10:54:34 2003
+++ b/drivers/usb/host/hc_sl811_rh.c	Fri Aug  1 10:54:34 2003
@@ -564,7 +564,10 @@
 		return -ENOMEM;
 
 	hci->bus->root_hub = usb_dev;
-	usb_connect (usb_dev);
+	usb_dev->devnum = 1;
+	usb_dev->bus->devnum_next = usb_dev->devnum + 1;
+	set_bit (usb_dev->devnum, usb_dev->bus->devmap.devicemap);
+
 	if (usb_new_device (usb_dev) != 0) {
 		usb_put_dev (usb_dev);
 		return -ENODEV;
diff -Nru a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
--- a/drivers/usb/host/ohci-hcd.c	Fri Aug  1 10:54:34 2003
+++ b/drivers/usb/host/ohci-hcd.c	Fri Aug  1 10:54:34 2003
@@ -538,7 +538,6 @@
 		return -ENOMEM;
 	}
 
-	usb_connect (udev);
 	udev->speed = USB_SPEED_FULL;
 	if (hcd_register_root (&ohci->hcd) != 0) {
 		usb_put_dev (udev);
diff -Nru a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
--- a/drivers/usb/host/uhci-hcd.c	Fri Aug  1 10:54:34 2003
+++ b/drivers/usb/host/uhci-hcd.c	Fri Aug  1 10:54:34 2003
@@ -2346,7 +2346,6 @@
 	/* disable legacy emulation */
 	pci_write_config_word(hcd->pdev, USBLEGSUP, USBLEGSUP_DEFAULT);
 
-	usb_connect(udev);
 	udev->speed = USB_SPEED_FULL;
 
 	if (usb_register_root_hub(udev, &hcd->pdev->dev) != 0) {
