- patches.fixes/patch-2.6.11-rc1: 2.6.11-rc1.
[linux-flexiantxendom0-3.2.10.git] / drivers / usb / core / usb.c
index 00f6caf..99268c2 100644 (file)
@@ -63,8 +63,7 @@ const char *usbcore_name = "usbcore";
 int nousb;             /* Disable USB when built into kernel image */
                        /* Not honored on modular build */
 
-DECLARE_RWSEM(usb_all_devices_rwsem);
-EXPORT_SYMBOL(usb_all_devices_rwsem);
+static DECLARE_RWSEM(usb_all_devices_rwsem);
 
 
 static int generic_probe (struct device *dev)
@@ -267,44 +266,6 @@ struct usb_host_interface *usb_altnum_to_altsetting(struct usb_interface *intf,
 }
 
 /**
- * usb_epnum_to_ep_desc - get the endpoint object with a given endpoint number
- * @dev: the device whose current configuration+altsettings is considered
- * @epnum: the desired endpoint, masked with USB_DIR_IN as appropriate.
- *
- * This walks the device descriptor for the currently active configuration,
- * and returns a pointer to the endpoint with that particular endpoint
- * number, or null.
- *
- * Note that interface descriptors are not required to list endpoint
- * numbers in any standardized order, so that it would be wrong to
- * assume that ep2in precedes either ep5in, ep2out, or even ep1out.
- * This routine helps device drivers avoid such mistakes.
- */
-struct usb_endpoint_descriptor *
-usb_epnum_to_ep_desc(struct usb_device *dev, unsigned epnum)
-{
-       struct usb_host_config *config = dev->actconfig;
-       int i, k;
-
-       if (!config)
-               return NULL;
-       for (i = 0; i < config->desc.bNumInterfaces; i++) {
-               struct usb_interface            *intf;
-               struct usb_host_interface       *alt;
-
-               /* only endpoints in current altsetting are active */
-               intf = config->interface[i];
-               alt = intf->cur_altsetting;
-
-               for (k = 0; k < alt->desc.bNumEndpoints; k++)
-                       if (epnum == alt->endpoint[k].desc.bEndpointAddress)
-                               return &alt->endpoint[k].desc;
-       }
-
-       return NULL;
-}
-
-/**
  * usb_driver_claim_interface - bind a driver to an interface
  * @driver: the driver to be bound
  * @iface: the interface to which it will be bound; must be in the
@@ -461,21 +422,21 @@ usb_match_id(struct usb_interface *interface, const struct usb_device_id *id)
               id->driver_info; id++) {
 
                if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
-                   id->idVendor != dev->descriptor.idVendor)
+                   id->idVendor != le16_to_cpu(dev->descriptor.idVendor))
                        continue;
 
                if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) &&
-                   id->idProduct != dev->descriptor.idProduct)
+                   id->idProduct != le16_to_cpu(dev->descriptor.idProduct))
                        continue;
 
                /* No need to test id->bcdDevice_lo != 0, since 0 is never
                   greater than any unsigned number. */
                if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) &&
-                   (id->bcdDevice_lo > dev->descriptor.bcdDevice))
+                   (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice)))
                        continue;
 
                if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) &&
-                   (id->bcdDevice_hi < dev->descriptor.bcdDevice))
+                   (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice)))
                        continue;
 
                if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) &&
@@ -626,9 +587,9 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp,
        if (add_hotplug_env_var(envp, num_envp, &i,
                                buffer, buffer_size, &length,
                                "PRODUCT=%x/%x/%x",
-                               usb_dev->descriptor.idVendor,
-                               usb_dev->descriptor.idProduct,
-                               usb_dev->descriptor.bcdDevice))
+                               le16_to_cpu(usb_dev->descriptor.idVendor),
+                               le16_to_cpu(usb_dev->descriptor.idProduct),
+                               le16_to_cpu(usb_dev->descriptor.bcdDevice)))
                return -ENOMEM;
 
        /* class-based driver binding models */
@@ -684,8 +645,6 @@ static void usb_release_dev(struct device *dev)
 
        udev = to_usb_device(dev);
 
-       if (udev->bus && udev->bus->op && udev->bus->op->deallocate)
-               udev->bus->op->deallocate(udev);
        usb_destroy_configuration(udev);
        usb_bus_put(udev->bus);
        kfree (udev);
@@ -695,7 +654,7 @@ static void usb_release_dev(struct device *dev)
  * usb_alloc_dev - usb device constructor (usbcore-internal)
  * @parent: hub to which device is connected; null to allocate a root hub
  * @bus: bus used to access the device
- * @port: zero based index of port; ignored for root hubs
+ * @port1: one-based index of port; ignored for root hubs
  * Context: !in_interrupt ()
  *
  * Only hub drivers (including virtual root hub drivers for host
@@ -704,7 +663,7 @@ static void usb_release_dev(struct device *dev)
  * This call may not be used in a non-sleeping context.
  */
 struct usb_device *
-usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port)
+usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1)
 {
        struct usb_device *dev;
 
@@ -728,6 +687,12 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port)
        dev->dev.release = usb_release_dev;
        dev->state = USB_STATE_ATTACHED;
 
+       INIT_LIST_HEAD(&dev->ep0.urb_list);
+       dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
+       dev->ep0.desc.bDescriptorType = USB_DT_ENDPOINT;
+       /* ep0 maxpacket comes later, from device descriptor */
+       dev->ep_in[0] = dev->ep_out[0] = &dev->ep0;
+
        /* Save readable and stable topology id, distinguishing devices
         * by location for diagnostics, tools, driver model, etc.  The
         * string is a path along hub ports, from the root.  Each device's
@@ -745,10 +710,10 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port)
                /* match any labeling on the hubs; it's one-based */
                if (parent->devpath [0] == '0')
                        snprintf (dev->devpath, sizeof dev->devpath,
-                               "%d", port + 1);
+                               "%d", port1);
                else
                        snprintf (dev->devpath, sizeof dev->devpath,
-                               "%s.%d", parent->devpath, port + 1);
+                               "%s.%d", parent->devpath, port1);
 
                dev->dev.parent = &parent->dev;
                sprintf (&dev->dev.bus_id[0], "%d-%s",
@@ -763,13 +728,6 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port)
 
        init_MUTEX(&dev->serialize);
 
-       if (dev->bus->op->allocate)
-               if (dev->bus->op->allocate(dev)) {
-                       usb_bus_put(bus);
-                       kfree(dev);
-                       return NULL;
-               }
-
        return dev;
 }
 
@@ -1000,12 +958,12 @@ static struct usb_device *match_device(struct usb_device *dev,
        int child;
 
        dev_dbg(&dev->dev, "check for vendor %04x, product %04x ...\n",
-           dev->descriptor.idVendor,
-           dev->descriptor.idProduct);
+           le16_to_cpu(dev->descriptor.idVendor),
+           le16_to_cpu(dev->descriptor.idProduct));
 
        /* see if this device matches */
-       if ((dev->descriptor.idVendor == vendor_id) &&
-           (dev->descriptor.idProduct == product_id)) {
+       if ((vendor_id == le16_to_cpu(dev->descriptor.idVendor)) &&
+           (product_id == le16_to_cpu(dev->descriptor.idProduct))) {
                dev_dbg (&dev->dev, "matched this device!\n");
                ret_dev = usb_get_dev(dev);
                goto exit;
@@ -1533,7 +1491,6 @@ module_exit(usb_exit);
  * These symbols are exported for device (or host controller)
  * driver modules to use.
  */
-EXPORT_SYMBOL(usb_epnum_to_ep_desc);
 
 EXPORT_SYMBOL(usb_register);
 EXPORT_SYMBOL(usb_deregister);