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);
* 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",
......
......@@ -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 */
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 () */
......
......@@ -932,7 +932,7 @@ static void hub_port_connect_change(struct usb_hub *hubstate, int port,
}
/* Find a new address for it */
usb_connect(dev);
usb_choose_address(dev);
/* Set up TT records, if needed */
if (hub->tt) {
......
......@@ -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)
*
* 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_ifnum_to_if);
EXPORT_SYMBOL(usb_new_device);
EXPORT_SYMBOL(usb_reset_device);
EXPORT_SYMBOL(usb_connect);
EXPORT_SYMBOL(usb_disconnect);
EXPORT_SYMBOL(__usb_get_extra_descriptor);
......
......@@ -497,7 +497,6 @@ static int ehci_start (struct usb_hcd *hcd)
* 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)
......
......@@ -564,7 +564,10 @@ static int rh_connect_rh (hci_t * hci)
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;
......
......@@ -538,7 +538,6 @@ static int hc_start (struct ohci_hcd *ohci)
return -ENOMEM;
}
usb_connect (udev);
udev->speed = USB_SPEED_FULL;
if (hcd_register_root (&ohci->hcd) != 0) {
usb_put_dev (udev);
......
......@@ -2346,7 +2346,6 @@ static int __devinit uhci_start(struct usb_hcd *hcd)
/* 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) {
......
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