Commit 11ba7acd authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

[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.
parent 7b680613
...@@ -734,14 +734,20 @@ EXPORT_SYMBOL (usb_deregister_bus); ...@@ -734,14 +734,20 @@ EXPORT_SYMBOL (usb_deregister_bus);
* The USB host controller calls this function to register the root hub * The USB host controller calls this function to register the root hub
* properly with the USB subsystem. It sets up the device properly in * properly with the USB subsystem. It sets up the device properly in
* the driverfs tree, and then calls usb_new_device() to register the * 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) int usb_register_root_hub (struct usb_device *usb_dev, struct device *parent_dev)
{ {
const int devnum = 1;
int retval; int retval;
sprintf (&usb_dev->dev.bus_id[0], "usb%d", usb_dev->bus->busnum); sprintf (&usb_dev->dev.bus_id[0], "usb%d", usb_dev->bus->busnum);
usb_dev->state = USB_STATE_DEFAULT; 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); retval = usb_new_device (usb_dev, parent_dev);
if (retval) if (retval)
dev_err (parent_dev, "can't register root hub for %s, %d\n", dev_err (parent_dev, "can't register root hub for %s, %d\n",
......
...@@ -246,7 +246,7 @@ extern void usb_hc_died (struct usb_hcd *hcd); ...@@ -246,7 +246,7 @@ extern void usb_hc_died (struct usb_hcd *hcd);
/* Enumeration is only for the hub driver, or HCD virtual root hubs */ /* 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 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 **); extern void usb_disconnect(struct usb_device **);
/* exported to hub driver ONLY to support usb_reset_device () */ /* exported to hub driver ONLY to support usb_reset_device () */
......
...@@ -932,7 +932,7 @@ static void hub_port_connect_change(struct usb_hub *hubstate, int port, ...@@ -932,7 +932,7 @@ static void hub_port_connect_change(struct usb_hub *hubstate, int port,
} }
/* Find a new address for it */ /* Find a new address for it */
usb_connect(dev); usb_choose_address(dev);
/* Set up TT records, if needed */ /* Set up TT records, if needed */
if (hub->tt) { if (hub->tt) {
......
...@@ -945,25 +945,21 @@ void usb_disconnect(struct usb_device **pdev) ...@@ -945,25 +945,21 @@ void usb_disconnect(struct usb_device **pdev)
} }
/** /**
* usb_connect - pick device address (usbcore-internal) * usb_choose_address - pick device address (usbcore-internal)
* @dev: newly detected device (in DEFAULT state) * @dev: newly detected device (in DEFAULT state)
* *
* Picks a device address. It's up to the hub (or root hub) driver * Picks a device address. It's up to the hub (or root hub) driver
* to handle and manage enumeration, starting from the DEFAULT state. * 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. * controllers) should ever call this.
*/ */
void usb_connect(struct usb_device *dev) void usb_choose_address(struct usb_device *dev)
{ {
int devnum; int devnum;
// FIXME needs locking for SMP!! // FIXME needs locking for SMP!!
/* why? this is called only from the hub thread, /* why? this is called only from the hub thread,
* which hopefully doesn't run on multiple CPU's simultaneously 8-) * 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. */ /* 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); devnum = find_next_zero_bit(dev->bus->devmap.devicemap, 128, dev->bus->devnum_next);
...@@ -1607,7 +1603,6 @@ EXPORT_SYMBOL(usb_ifnum_to_if); ...@@ -1607,7 +1603,6 @@ EXPORT_SYMBOL(usb_ifnum_to_if);
EXPORT_SYMBOL(usb_new_device); EXPORT_SYMBOL(usb_new_device);
EXPORT_SYMBOL(usb_reset_device); EXPORT_SYMBOL(usb_reset_device);
EXPORT_SYMBOL(usb_connect);
EXPORT_SYMBOL(usb_disconnect); EXPORT_SYMBOL(usb_disconnect);
EXPORT_SYMBOL(__usb_get_extra_descriptor); EXPORT_SYMBOL(__usb_get_extra_descriptor);
......
...@@ -497,7 +497,6 @@ static int ehci_start (struct usb_hcd *hcd) ...@@ -497,7 +497,6 @@ static int ehci_start (struct usb_hcd *hcd)
* Before this point the HC was idle/ready. After, khubd * Before this point the HC was idle/ready. After, khubd
* and device drivers may start it running. * and device drivers may start it running.
*/ */
usb_connect (udev);
udev->speed = USB_SPEED_HIGH; udev->speed = USB_SPEED_HIGH;
if (hcd_register_root (hcd) != 0) { if (hcd_register_root (hcd) != 0) {
if (hcd->state == USB_STATE_RUNNING) if (hcd->state == USB_STATE_RUNNING)
......
...@@ -564,7 +564,10 @@ static int rh_connect_rh (hci_t * hci) ...@@ -564,7 +564,10 @@ static int rh_connect_rh (hci_t * hci)
return -ENOMEM; return -ENOMEM;
hci->bus->root_hub = usb_dev; 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) { if (usb_new_device (usb_dev) != 0) {
usb_put_dev (usb_dev); usb_put_dev (usb_dev);
return -ENODEV; return -ENODEV;
......
...@@ -538,7 +538,6 @@ static int hc_start (struct ohci_hcd *ohci) ...@@ -538,7 +538,6 @@ static int hc_start (struct ohci_hcd *ohci)
return -ENOMEM; return -ENOMEM;
} }
usb_connect (udev);
udev->speed = USB_SPEED_FULL; udev->speed = USB_SPEED_FULL;
if (hcd_register_root (&ohci->hcd) != 0) { if (hcd_register_root (&ohci->hcd) != 0) {
usb_put_dev (udev); usb_put_dev (udev);
......
...@@ -2346,7 +2346,6 @@ static int __devinit uhci_start(struct usb_hcd *hcd) ...@@ -2346,7 +2346,6 @@ static int __devinit uhci_start(struct usb_hcd *hcd)
/* disable legacy emulation */ /* disable legacy emulation */
pci_write_config_word(hcd->pdev, USBLEGSUP, USBLEGSUP_DEFAULT); pci_write_config_word(hcd->pdev, USBLEGSUP, USBLEGSUP_DEFAULT);
usb_connect(udev);
udev->speed = USB_SPEED_FULL; udev->speed = USB_SPEED_FULL;
if (usb_register_root_hub(udev, &hcd->pdev->dev) != 0) { if (usb_register_root_hub(udev, &hcd->pdev->dev) != 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment