Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 16 Jun 2009 20:06:10 +0000 (13:06 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 16 Jun 2009 20:06:10 +0000 (13:06 -0700)
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6: (143 commits)
  USB: xhci depends on PCI.
  USB: xhci: Add Makefile, MAINTAINERS, and Kconfig entries.
  USB: xhci: Respect critical sections.
  USB: xHCI: Fix interrupt moderation.
  USB: xhci: Remove packed attribute from structures.
  usb; xhci: Fix TRB offset calculations.
  USB: xhci: replace if-elseif-else with switch-case
  USB: xhci: Make xhci-mem.c include linux/dmapool.h
  USB: xhci: drop spinlock in xhci_urb_enqueue() error path.
  USB: Change names of SuperSpeed ep companion descriptor structs.
  USB: xhci: Avoid compiler reordering in Link TRB giveback.
  USB: xhci: Clean up xhci_irq() function.
  USB: xhci: Avoid global namespace pollution.
  USB: xhci: Fix Link TRB handoff bit twiddling.
  USB: xhci: Fix register write order.
  USB: xhci: fix some compiler warnings in xhci.h
  USB: xhci: fix lots of compiler warnings.
  USB: xhci: use xhci_handle_event instead of handle_event
  USB: xhci: URB cancellation support.
  USB: xhci: Scatter gather list support for bulk transfers.
  ...

1  2 
MAINTAINERS
drivers/usb/core/usb.c
drivers/usb/gadget/at91_udc.c
drivers/usb/host/ehci-ps3.c
fs/fat/dir.c
fs/fat/namei_vfat.c
include/linux/usb.h

diff --combined MAINTAINERS
@@@ -157,10 -157,9 +157,10 @@@ S:       Maintaine
  F:    drivers/net/r8169.c
  
  8250/16?50 (AND CLONE UARTS) SERIAL DRIVER
 +P:    Alan Cox
 +M:    alan@lxorguk.ukuu.org.uk
  L:    linux-serial@vger.kernel.org
  W:    http://serial.sourceforge.net
 -M:    alan@lxorguk.ukuu.org.uk
  S:    Odd Fixes
  F:    drivers/serial/8250*
  F:    include/linux/serial_8250.h
@@@ -6165,6 -6164,12 +6165,12 @@@ L:    linux-wireless@vger.kernel.or
  S:    Maintained
  F:    drivers/net/wireless/rndis_wlan.c
  
+ USB XHCI DRIVER
+ P:    Sarah Sharp
+ M:    sarah.a.sharp@intel.com
+ L:    linux-usb@vger.kernel.org
+ S:    Supported
  USB ZC0301 DRIVER
  P:    Luca Risolia
  M:    luca.risolia@studio.unibo.it
diff --combined drivers/usb/core/usb.c
@@@ -34,6 -34,7 +34,7 @@@
  #include <linux/usb.h>
  #include <linux/mutex.h>
  #include <linux/workqueue.h>
+ #include <linux/debugfs.h>
  
  #include <asm/io.h>
  #include <linux/scatterlist.h>
@@@ -139,8 -140,7 +140,7 @@@ static int __find_interface(struct devi
        struct find_interface_arg *arg = data;
        struct usb_interface *intf;
  
-       /* can't look at usb devices, only interfaces */
-       if (is_usb_device(dev))
+       if (!is_usb_interface(dev))
                return 0;
  
        intf = to_usb_interface(dev);
@@@ -184,11 -184,16 +184,16 @@@ EXPORT_SYMBOL_GPL(usb_find_interface)
  static void usb_release_dev(struct device *dev)
  {
        struct usb_device *udev;
+       struct usb_hcd *hcd;
  
        udev = to_usb_device(dev);
+       hcd = bus_to_hcd(udev->bus);
  
        usb_destroy_configuration(udev);
-       usb_put_hcd(bus_to_hcd(udev->bus));
+       /* Root hubs aren't real devices, so don't free HCD resources */
+       if (hcd->driver->free_dev && udev->parent)
+               hcd->driver->free_dev(hcd, udev);
+       usb_put_hcd(hcd);
        kfree(udev->product);
        kfree(udev->manufacturer);
        kfree(udev->serial);
@@@ -305,21 -310,10 +310,21 @@@ static struct dev_pm_ops usb_device_pm_
  
  #endif        /* CONFIG_PM */
  
 +
 +static char *usb_nodename(struct device *dev)
 +{
 +      struct usb_device *usb_dev;
 +
 +      usb_dev = to_usb_device(dev);
 +      return kasprintf(GFP_KERNEL, "bus/usb/%03d/%03d",
 +                       usb_dev->bus->busnum, usb_dev->devnum);
 +}
 +
  struct device_type usb_device_type = {
        .name =         "usb_device",
        .release =      usb_release_dev,
        .uevent =       usb_dev_uevent,
 +      .nodename =     usb_nodename,
        .pm =           &usb_device_pm_ops,
  };
  
@@@ -359,6 -353,13 +364,13 @@@ struct usb_device *usb_alloc_dev(struc
                kfree(dev);
                return NULL;
        }
+       /* Root hubs aren't true devices, so don't allocate HCD resources */
+       if (usb_hcd->driver->alloc_dev && parent &&
+               !usb_hcd->driver->alloc_dev(usb_hcd, dev)) {
+               usb_put_hcd(bus_to_hcd(bus));
+               kfree(dev);
+               return NULL;
+       }
  
        device_initialize(&dev->dev);
        dev->dev.bus = &usb_bus_type;
         */
        if (unlikely(!parent)) {
                dev->devpath[0] = '0';
+               dev->route = 0;
  
                dev->dev.parent = bus->controller;
                dev_set_name(&dev->dev, "usb%d", bus->busnum);
                root_hub = 1;
        } else {
                /* match any labeling on the hubs; it's one-based */
-               if (parent->devpath[0] == '0')
+               if (parent->devpath[0] == '0') {
                        snprintf(dev->devpath, sizeof dev->devpath,
                                "%d", port1);
-               else
+                       /* Root ports are not counted in route string */
+                       dev->route = 0;
+               } else {
                        snprintf(dev->devpath, sizeof dev->devpath,
                                "%s.%d", parent->devpath, port1);
+                       dev->route = parent->route +
+                               (port1 << ((parent->level - 1)*4));
+               }
  
                dev->dev.parent = &parent->dev;
                dev_set_name(&dev->dev, "%d-%s", bus->busnum, dev->devpath);
@@@ -810,12 -817,12 +828,12 @@@ void usb_buffer_dmasync(struct urb *urb
                return;
  
        if (controller->dma_mask) {
-               dma_sync_single(controller,
+               dma_sync_single_for_cpu(controller,
                        urb->transfer_dma, urb->transfer_buffer_length,
                        usb_pipein(urb->pipe)
                                ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
                if (usb_pipecontrol(urb->pipe))
-                       dma_sync_single(controller,
+                       dma_sync_single_for_cpu(controller,
                                        urb->setup_dma,
                                        sizeof(struct usb_ctrlrequest),
                                        DMA_TO_DEVICE);
@@@ -933,8 -940,8 +951,8 @@@ void usb_buffer_dmasync_sg(const struc
                        || !controller->dma_mask)
                return;
  
-       dma_sync_sg(controller, sg, n_hw_ents,
-                       is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
+       dma_sync_sg_for_cpu(controller, sg, n_hw_ents,
+                           is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
  }
  EXPORT_SYMBOL_GPL(usb_buffer_dmasync_sg);
  #endif
@@@ -1012,6 -1019,35 +1030,35 @@@ static struct notifier_block usb_bus_n
        .notifier_call = usb_bus_notify,
  };
  
+ struct dentry *usb_debug_root;
+ EXPORT_SYMBOL_GPL(usb_debug_root);
+ struct dentry *usb_debug_devices;
+ static int usb_debugfs_init(void)
+ {
+       usb_debug_root = debugfs_create_dir("usb", NULL);
+       if (!usb_debug_root)
+               return -ENOENT;
+       usb_debug_devices = debugfs_create_file("devices", 0444,
+                                               usb_debug_root, NULL,
+                                               &usbfs_devices_fops);
+       if (!usb_debug_devices) {
+               debugfs_remove(usb_debug_root);
+               usb_debug_root = NULL;
+               return -ENOENT;
+       }
+       return 0;
+ }
+ static void usb_debugfs_cleanup(void)
+ {
+       debugfs_remove(usb_debug_devices);
+       debugfs_remove(usb_debug_root);
+ }
  /*
   * Init
   */
@@@ -1023,6 -1059,10 +1070,10 @@@ static int __init usb_init(void
                return 0;
        }
  
+       retval = usb_debugfs_init();
+       if (retval)
+               goto out;
        retval = ksuspend_usb_init();
        if (retval)
                goto out;
        retval = bus_register_notifier(&usb_bus_type, &usb_bus_nb);
        if (retval)
                goto bus_notifier_failed;
-       retval = usb_host_init();
-       if (retval)
-               goto host_init_failed;
        retval = usb_major_init();
        if (retval)
                goto major_init_failed;
@@@ -1064,8 -1101,6 +1112,6 @@@ usb_devio_init_failed
  driver_register_failed:
        usb_major_cleanup();
  major_init_failed:
-       usb_host_cleanup();
- host_init_failed:
        bus_unregister_notifier(&usb_bus_type, &usb_bus_nb);
  bus_notifier_failed:
        bus_unregister(&usb_bus_type);
@@@ -1090,10 -1125,10 +1136,10 @@@ static void __exit usb_exit(void
        usb_deregister(&usbfs_driver);
        usb_devio_cleanup();
        usb_hub_cleanup();
-       usb_host_cleanup();
        bus_unregister_notifier(&usb_bus_type, &usb_bus_nb);
        bus_unregister(&usb_bus_type);
        ksuspend_usb_cleanup();
+       usb_debugfs_cleanup();
  }
  
  subsys_initcall(usb_init);
@@@ -485,7 -485,7 +485,7 @@@ static int at91_ep_enable(struct usb_e
                return -ESHUTDOWN;
        }
  
-       tmp = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
+       tmp = usb_endpoint_type(desc);
        switch (tmp) {
        case USB_ENDPOINT_XFER_CONTROL:
                DBG("only one control endpoint\n");
@@@ -517,7 -517,7 +517,7 @@@ ok
        local_irq_save(flags);
  
        /* initialize endpoint to match this descriptor */
-       ep->is_in = (desc->bEndpointAddress & USB_DIR_IN) != 0;
+       ep->is_in = usb_endpoint_dir_in(desc);
        ep->is_iso = (tmp == USB_ENDPOINT_XFER_ISOC);
        ep->stopped = 0;
        if (ep->is_in)
@@@ -1574,7 -1574,7 +1574,7 @@@ int usb_gadget_register_driver (struct 
  
        udc->driver = driver;
        udc->gadget.dev.driver = &driver->driver;
 -      udc->gadget.dev.driver_data = &driver->driver;
 +      dev_set_drvdata(&udc->gadget.dev, &driver->driver);
        udc->enabled = 1;
        udc->selfpowered = 1;
  
                DBG("driver->bind() returned %d\n", retval);
                udc->driver = NULL;
                udc->gadget.dev.driver = NULL;
 -              udc->gadget.dev.driver_data = NULL;
 +              dev_set_drvdata(&udc->gadget.dev, NULL);
                udc->enabled = 0;
                udc->selfpowered = 0;
                return retval;
@@@ -1613,7 -1613,7 +1613,7 @@@ int usb_gadget_unregister_driver (struc
  
        driver->unbind(&udc->gadget);
        udc->gadget.dev.driver = NULL;
 -      udc->gadget.dev.driver_data = NULL;
 +      dev_set_drvdata(&udc->gadget.dev, NULL);
        udc->driver = NULL;
  
        DBG("unbound from %s\n", driver->driver.name);
@@@ -65,6 -65,7 +65,7 @@@ static const struct hc_driver ps3_ehci_
        .urb_enqueue            = ehci_urb_enqueue,
        .urb_dequeue            = ehci_urb_dequeue,
        .endpoint_disable       = ehci_endpoint_disable,
+       .endpoint_reset         = ehci_endpoint_reset,
        .get_frame_number       = ehci_get_frame,
        .hub_status_data        = ehci_hub_status_data,
        .hub_control            = ehci_hub_control,
@@@ -162,7 -163,7 +163,7 @@@ static int ps3_ehci_probe(struct ps3_sy
        dev_dbg(&dev->core, "%s:%d: virq            %lu\n", __func__, __LINE__,
                (unsigned long)virq);
  
 -      ps3_system_bus_set_driver_data(dev, hcd);
 +      ps3_system_bus_set_drvdata(dev, hcd);
  
        result = usb_add_hcd(hcd, virq, IRQF_DISABLED);
  
@@@ -195,7 -196,8 +196,7 @@@ fail_start
  static int ps3_ehci_remove(struct ps3_system_bus_device *dev)
  {
        unsigned int tmp;
 -      struct usb_hcd *hcd =
 -              (struct usb_hcd *)ps3_system_bus_get_driver_data(dev);
 +      struct usb_hcd *hcd = ps3_system_bus_get_drvdata(dev);
  
        BUG_ON(!hcd);
  
        ehci_shutdown(hcd);
        usb_remove_hcd(hcd);
  
 -      ps3_system_bus_set_driver_data(dev, NULL);
 +      ps3_system_bus_set_drvdata(dev, NULL);
  
        BUG_ON(!hcd->regs);
        iounmap(hcd->regs);
diff --combined fs/fat/dir.c
  #include <asm/uaccess.h>
  #include "fat.h"
  
+ /*
+  * Maximum buffer size of short name.
+  * [(MSDOS_NAME + '.') * max one char + nul]
+  * For msdos style, ['.' (hidden) + MSDOS_NAME + '.' + nul]
+  */
+ #define FAT_MAX_SHORT_SIZE    ((MSDOS_NAME + 1) * NLS_MAX_CHARSET_SIZE + 1)
+ /*
+  * Maximum buffer size of unicode chars from slots.
+  * [(max longname slots * 13 (size in a slot) + nul) * sizeof(wchar_t)]
+  */
+ #define FAT_MAX_UNI_CHARS     ((MSDOS_SLOTS - 1) * 13 + 1)
+ #define FAT_MAX_UNI_SIZE      (FAT_MAX_UNI_CHARS * sizeof(wchar_t))
  static inline loff_t fat_make_i_pos(struct super_block *sb,
                                    struct buffer_head *bh,
                                    struct msdos_dir_entry *de)
@@@ -171,7 -184,8 +184,8 @@@ static inline int fat_uni_to_x8(struct 
                                unsigned char *buf, int size)
  {
        if (sbi->options.utf8)
-               return utf8_wcstombs(buf, uni, size);
+               return utf16s_to_utf8s(uni, FAT_MAX_UNI_CHARS,
+                               UTF16_HOST_ENDIAN, buf, size);
        else
                return uni16_to_x8(buf, uni, size, sbi->options.unicode_xlate,
                                   sbi->nls_io);
@@@ -325,19 -339,6 +339,6 @@@ parse_long
  }
  
  /*
-  * Maximum buffer size of short name.
-  * [(MSDOS_NAME + '.') * max one char + nul]
-  * For msdos style, ['.' (hidden) + MSDOS_NAME + '.' + nul]
-  */
- #define FAT_MAX_SHORT_SIZE    ((MSDOS_NAME + 1) * NLS_MAX_CHARSET_SIZE + 1)
- /*
-  * Maximum buffer size of unicode chars from slots.
-  * [(max longname slots * 13 (size in a slot) + nul) * sizeof(wchar_t)]
-  */
- #define FAT_MAX_UNI_CHARS     ((MSDOS_SLOTS - 1) * 13 + 1)
- #define FAT_MAX_UNI_SIZE      (FAT_MAX_UNI_CHARS * sizeof(wchar_t))
- /*
   * Return values: negative -> error, 0 -> not found, positive -> found,
   * value is the total amount of slots, including the shortname entry.
   */
@@@ -1334,7 -1335,7 +1335,7 @@@ found
                        goto error_remove;
                }
                if (dir->i_size & (sbi->cluster_size - 1)) {
 -                      fat_fs_panic(sb, "Odd directory size");
 +                      fat_fs_error(sb, "Odd directory size");
                        dir->i_size = (dir->i_size + sbi->cluster_size - 1)
                                & ~((loff_t)sbi->cluster_size - 1);
                }
diff --combined fs/fat/namei_vfat.c
@@@ -502,11 -502,11 +502,11 @@@ xlate_to_uni(const unsigned char *name
        if (utf8) {
                int name_len = strlen(name);
  
-               *outlen = utf8_mbstowcs((wchar_t *)outname, name, PATH_MAX);
+               *outlen = utf8s_to_utf16s(name, PATH_MAX, (wchar_t *) outname);
  
                /*
                 * We stripped '.'s before and set len appropriately,
-                * but utf8_mbstowcs doesn't care about len
+                * but utf8s_to_utf16s doesn't care about len
                 */
                *outlen -= (name_len - len);
  
@@@ -1030,7 -1030,7 +1030,7 @@@ error_inode
                sinfo.bh = NULL;
        }
        if (corrupt < 0) {
 -              fat_fs_panic(new_dir->i_sb,
 +              fat_fs_error(new_dir->i_sb,
                             "%s: Filesystem corrupted (i_pos %lld)",
                             __func__, sinfo.i_pos);
        }
diff --combined include/linux/usb.h
@@@ -36,6 -36,7 +36,7 @@@ struct wusb_dev
   *  - configs have one (often) or more interfaces;
   *  - interfaces have one (usually) or more settings;
   *  - each interface setting has zero or (usually) more endpoints.
+  *  - a SuperSpeed endpoint has a companion descriptor
   *
   * And there might be other descriptors mixed in with those.
   *
  
  struct ep_device;
  
+ /* For SS devices */
+ /**
+  * struct usb_host_ss_ep_comp - Valid for SuperSpeed devices only
+  * @desc: endpoint companion descriptor, wMaxPacketSize in native byteorder
+  * @extra: descriptors following this endpoint companion descriptor
+  * @extralen: how many bytes of "extra" are valid
+  */
+ struct usb_host_ss_ep_comp {
+       struct usb_ss_ep_comp_descriptor        desc;
+       unsigned char                           *extra;   /* Extra descriptors */
+       int                                     extralen;
+ };
  /**
   * struct usb_host_endpoint - host-side endpoint descriptor and queue
   * @desc: descriptor for this endpoint, wMaxPacketSize in native byteorder
@@@ -51,6 -65,7 +65,7 @@@
   * @hcpriv: for use by HCD; typically holds hardware dma queue head (QH)
   *    with one or more transfer descriptors (TDs) per urb
   * @ep_dev: ep_device for sysfs info
+  * @ss_ep_comp: companion descriptor information for this endpoint
   * @extra: descriptors following this endpoint in the configuration
   * @extralen: how many bytes of "extra" are valid
   * @enabled: URBs may be submitted to this endpoint
@@@ -63,6 -78,7 +78,7 @@@ struct usb_host_endpoint 
        struct list_head                urb_list;
        void                            *hcpriv;
        struct ep_device                *ep_dev;        /* For sysfs info */
+       struct usb_host_ss_ep_comp      *ss_ep_comp;    /* For SS devices */
  
        unsigned char *extra;   /* Extra descriptors */
        int extralen;
@@@ -336,7 -352,6 +352,6 @@@ struct usb_bus 
  #ifdef CONFIG_USB_DEVICEFS
        struct dentry *usbfs_dentry;    /* usbfs dentry entry for the bus */
  #endif
-       struct device *dev;             /* device for this bus */
  
  #if defined(CONFIG_USB_MON) || defined(CONFIG_USB_MON_MODULE)
        struct mon_bus *mon_bus;        /* non-null when associated */
@@@ -363,6 -378,7 +378,7 @@@ struct usb_tt
   * struct usb_device - kernel's representation of a USB device
   * @devnum: device number; address on a USB bus
   * @devpath: device ID string for use in messages (e.g., /port/...)
+  * @route: tree topology hex string for use with xHCI
   * @state: device state: configured, not attached, etc.
   * @speed: device speed: high/full/low (or error)
   * @tt: Transaction Translator info; used with low/full speed dev, highspeed hub
   * @skip_sys_resume: skip the next system resume
   * @wusb_dev: if this is a Wireless USB device, link to the WUSB
   *    specific data for the device.
+  * @slot_id: Slot ID assigned by xHCI
   *
   * Notes:
   * Usbcore drivers should not set usbdev->state directly.  Instead use
  struct usb_device {
        int             devnum;
        char            devpath [16];
+       u32             route;
        enum usb_device_state   state;
        enum usb_device_speed   speed;
  
        unsigned skip_sys_resume:1;
  #endif
        struct wusb_dev *wusb_dev;
+       int slot_id;
  };
  #define       to_usb_device(d) container_of(d, struct usb_device, dev)
  
@@@ -869,8 -888,6 +888,8 @@@ struct usb_driver 
   * struct usb_device_driver - identifies USB device driver to usbcore
   * @name: The driver name should be unique among USB drivers,
   *    and should normally be the same as the module name.
 + * @nodename: Callback to provide a naming hint for a possible
 + *    device node to create.
   * @probe: Called to see if the driver is willing to manage a particular
   *    device.  If it is, probe returns zero and uses dev_set_drvdata()
   *    to associate driver-specific data with the device.  If unwilling
@@@ -914,7 -931,6 +933,7 @@@ extern struct bus_type usb_bus_type
   */
  struct usb_class_driver {
        char *name;
 +      char *(*nodename)(struct device *dev);
        const struct file_operations *fops;
        int minor_base;
  };
@@@ -1044,7 -1060,9 +1063,9 @@@ typedef void (*usb_complete_t)(struct u
   * @setup_dma: For control transfers with URB_NO_SETUP_DMA_MAP set, the
   *    device driver has provided this DMA address for the setup packet.
   *    The host controller driver should use this in preference to
-  *    setup_packet.
+  *    setup_packet, but the HCD may chose to ignore the address if it must
+  *    copy the setup packet into internal structures.  Therefore, setup_packet
+  *    must always point to a valid buffer.
   * @start_frame: Returns the initial frame for isochronous transfers.
   * @number_of_packets: Lists the number of ISO transfer buffers.
   * @interval: Specifies the polling interval for interrupt or isochronous
@@@ -1180,6 -1198,8 +1201,8 @@@ struct urb 
        unsigned int transfer_flags;    /* (in) URB_SHORT_NOT_OK | ...*/
        void *transfer_buffer;          /* (in) associated data buffer */
        dma_addr_t transfer_dma;        /* (in) dma addr for transfer_buffer */
+       struct usb_sg_request *sg;      /* (in) scatter gather buffer list */
+       int num_sgs;                    /* (in) number of entries in the sg list */
        u32 transfer_buffer_length;     /* (in) data buffer length */
        u32 actual_length;              /* (return) actual transfer length */
        unsigned char *setup_packet;    /* (in) setup packet (control only) */
@@@ -1425,8 -1445,8 +1448,8 @@@ struct usb_sg_request 
        int                     status;
        size_t                  bytes;
  
-       /*
-        * members below are private: to usbcore,
+       /* private:
+        * members below are private to usbcore,
         * and are not provided for driver access!
         */
        spinlock_t              lock;
@@@ -1561,6 -1581,9 +1584,9 @@@ extern void usb_unregister_notify(struc
  #define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \
        format "\n" , ## arg)
  
+ /* debugfs stuff */
+ extern struct dentry *usb_debug_root;
  #endif  /* __KERNEL__ */
  
  #endif