ChangeSet 1.2219, 2005/03/30 12:36:24-08:00, [EMAIL PROTECTED]

        Merge suse.de:/home/greg/linux/BK/bleed-2.6
        into suse.de:/home/greg/linux/BK/usb-2.6



 MAINTAINERS                    |   16 +-
 arch/arm/mach-omap/usb.c       |   83 +++++++------
 drivers/usb/core/hub.c         |   51 +++++++-
 drivers/usb/gadget/ether.c     |  252 ++++++++++++++++++++++++++---------------
 drivers/usb/host/sl811-hcd.c   |    8 -
 drivers/usb/media/pwc/pwc-if.c |    2 
 6 files changed, 268 insertions(+), 144 deletions(-)


diff -Nru a/MAINTAINERS b/MAINTAINERS
--- a/MAINTAINERS       2005-03-30 15:24:45 -08:00
+++ b/MAINTAINERS       2005-03-30 15:24:45 -08:00
@@ -984,11 +984,6 @@
 W:     http://artax.karlin.mff.cuni.cz/~mikulas/vyplody/hpfs/index-e.cgi
 S:     Maintained
 
-HPUSBSCSI
-P:     Oliver Neukum
-M:     [EMAIL PROTECTED]
-S:     Maintained
-
 HUGETLB FILESYSTEM
 P:     William Irwin
 M:     [EMAIL PROTECTED]
@@ -2314,6 +2309,13 @@
 L:     [email protected]
 S:     Maintained
 
+USB BLOCK DRIVER (UB ub)
+P:     Pete Zaitcev
+M:     [EMAIL PROTECTED]
+L:     [email protected]
+L:     [email protected]
+S:     Supported
+
 USB BLUETOOTH TTY CONVERTER DRIVER
 P:     Greg Kroah-Hartman
 M:     [EMAIL PROTECTED]
@@ -2663,11 +2665,11 @@
 L:     [email protected]
 S:     Maintained
 
-YMFPCI YAMAHA PCI SOUND
+YMFPCI YAMAHA PCI SOUND (Use ALSA instead)
 P:     Pete Zaitcev
 M:     [EMAIL PROTECTED]
 L:     [email protected]
-S:     Maintained
+S:     Obsolete
 
 Z8530 DRIVER FOR AX.25
 P:     Joerg Reuter
diff -Nru a/arch/arm/mach-omap/usb.c b/arch/arm/mach-omap/usb.c
--- a/arch/arm/mach-omap/usb.c  2005-03-30 15:24:45 -08:00
+++ b/arch/arm/mach-omap/usb.c  2005-03-30 15:24:45 -08:00
@@ -49,10 +49,13 @@
 
 /* TESTED ON:
  *  - 1611B H2 (with usb1 mini-AB) using standard Mini-B or OTG cables
+ *  - 5912 OSK OHCI (with usb0 standard-A), standard A-to-B cables
+ *  - 5912 OSK UDC, with *nonstandard* A-to-A cable
  *  - 1510 Innovator UDC with bundled usb0 cable
  *  - 1510 Innovator OHCI with bundled usb1/usb2 cable
  *  - 1510 Innovator OHCI with custom usb0 cable, feeding 5V VBUS
  *  - 1710 custom development board using alternate pin group
+ *  - 1710 H3 (with usb1 mini-AB) using standard Mini-B or OTG cables
  */
 
 /*-------------------------------------------------------------------------*/
@@ -101,50 +104,48 @@
                return 0;
        }
 
-       /*
-        * VP and VM are needed for all active usb0 configurations.
-        * USB0_VP and USB0_VM are always set on 1510, there's no muxing
-        * available for them.
-        */
-       if (nwires >= 2 && !cpu_is_omap15xx()) {
-               omap_cfg_reg(AA9_USB0_VP);
-               omap_cfg_reg(R9_USB0_VM);
-       }
        if (is_device)
                omap_cfg_reg(W4_USB_PUEN);
 
        /* internal transceiver */
        if (nwires == 2) {
+               // omap_cfg_reg(P9_USB_DP);
+               // omap_cfg_reg(R8_USB_DM);
+
                if (cpu_is_omap15xx()) {
-                       /* This works for OHCI on 1510-Innovator */
+                       /* This works on 1510-Innovator */
                        return 0;
                }
 
-               /* NOTE:  host OR device mode for now, no OTG */
+               /* NOTES:
+                *  - peripheral should configure VBUS detection!
+                *  - only peripherals may use the internal D+/D- pulldowns
+                *  - OTG support on this port not yet written
+                */
+
                USB_TRANSCEIVER_CTRL_REG &= ~(7 << 4);
-               if (is_device) {
-                       omap_cfg_reg(R18_1510_USB_GPIO0);
-                       // omap_cfg_reg(USB0_VBUS);
-                       // USB_TRANSCEIVER_CTRL_REG.CONF_USB0_PORT_R = 7
-               } else /* host mode needs D+ and D- pulldowns */
-                       USB_TRANSCEIVER_CTRL_REG &= ~(3 << 1);
+               if (!is_device)
+                       USB_TRANSCEIVER_CTRL_REG |= (3 << 1);
 
                return 3 << 16;
        }
 
        /* alternate pin config, external transceiver */
+       if (cpu_is_omap15xx()) {
+               printk(KERN_ERR "no usb0 alt pin config on 15xx\n");
+               return 0;
+       }
+
        omap_cfg_reg(V6_USB0_TXD);
        omap_cfg_reg(W9_USB0_TXEN);
        omap_cfg_reg(W5_USB0_SE0);
 
-#ifdef CONFIG_ARCH_OMAP_USB_SPEED
-       /* FIXME: there's good chance that pin V9 is used for MMC2 port cmddir 
*/
-       omap_cfg_reg(V9_USB0_SPEED);
-       // omap_cfg_reg(V9_USB0_SUSP);
-#endif
+       /* NOTE:  SPEED and SUSP aren't configured here */
 
        if (nwires != 3)
                omap_cfg_reg(Y5_USB0_RCV);
+       if (nwires != 6)
+               USB_TRANSCEIVER_CTRL_REG &= ~CONF_USB2_UNI_R;
 
        switch (nwires) {
        case 3:
@@ -155,7 +156,8 @@
                break;
        case 6:
                syscon1 = 3;
-               /* REVISIT: Is CONF_USB2_UNI_R only needed when nwires = 6? */
+               omap_cfg_reg(AA9_USB0_VP);
+               omap_cfg_reg(R9_USB0_VM);
                USB_TRANSCEIVER_CTRL_REG |= CONF_USB2_UNI_R;
                break;
        default:
@@ -181,10 +183,13 @@
                omap_cfg_reg(USB1_SEO);
                omap_cfg_reg(USB1_SPEED);
                // SUSP
-       } else if (cpu_is_omap16xx()) {
+       } else if (cpu_is_omap1610() || cpu_is_omap5912()) {
                omap_cfg_reg(W13_1610_USB1_SE0);
                omap_cfg_reg(R13_1610_USB1_SPEED);
                // SUSP
+       } else if (cpu_is_omap1710()) {
+               omap_cfg_reg(R13_1710_USB1_SE0);
+               // SUSP
        } else {
                pr_debug("usb unrecognized\n");
        }
@@ -216,12 +221,11 @@
 {
        u32     syscon1 = 0;
 
+       /* NOTE erratum: must leave USB2_UNI_R set if usb0 in use */
        if (alt_pingroup || nwires == 0)
                return 0;
        if (nwires != 6 && !cpu_is_omap15xx())
                USB_TRANSCEIVER_CTRL_REG &= ~CONF_USB2_UNI_R;
-       if (nwires == 0)
-               return 0;
 
        /* external transceiver */
        if (cpu_is_omap15xx()) {
@@ -374,6 +378,10 @@
 
 /*-------------------------------------------------------------------------*/
 
+#define ULPD_CLOCK_CTRL_REG    __REG16(ULPD_CLOCK_CTRL)
+#define ULPD_SOFT_REQ_REG      __REG16(ULPD_SOFT_REQ)
+
+
 // FIXME correct answer depends on hmc_mode,
 // as does any nonzero value for config->otg port number
 #ifdef CONFIG_USB_GADGET_OMAP
@@ -412,12 +420,11 @@
 
        syscon = config->hmc_mode;
        syscon |= USBX_SYNCHRO | (4 << 16) /* B_ASE0_BRST */;
-       if (config->otg || config->register_host)
-               syscon |= UHOST_EN;
 #ifdef CONFIG_USB_OTG
        if (config->otg)
                syscon |= OTG_EN;
 #endif
+       pr_debug("USB_TRANSCEIVER_CTRL_REG = %03x\n", USB_TRANSCEIVER_CTRL_REG);
        pr_debug("OTG_SYSCON_2_REG = %08x\n", syscon);
        OTG_SYSCON_2_REG = syscon;
 
@@ -435,7 +442,10 @@
                printk(", Mini-AB on usb%d", config->otg - 1);
        printk("\n");
 
-       /* don't clock unused USB controllers  */
+       /* leave USB clocks/controllers off until needed */
+       ULPD_SOFT_REQ_REG &= ~SOFT_USB_CLK_REQ;
+       ULPD_CLOCK_CTRL_REG &= ~USB_MCLK_EN;
+       ULPD_CLOCK_CTRL_REG |= DIS_USB_PVCI_CLK;
        syscon = OTG_SYSCON_1_REG;
        syscon |= HST_IDLE_EN|DEV_IDLE_EN|OTG_IDLE_EN;
 
@@ -443,6 +453,7 @@
        if (config->otg || config->register_dev) {
                syscon &= ~DEV_IDLE_EN;
                udc_device.dev.platform_data = config;
+               /* FIXME patch IRQ numbers for omap730 */
                status = platform_device_register(&udc_device);
                if (status)
                        pr_debug("can't register UDC device, %d\n", status);
@@ -453,6 +464,8 @@
        if (config->otg || config->register_host) {
                syscon &= ~HST_IDLE_EN;
                ohci_device.dev.platform_data = config;
+               if (cpu_is_omap730())
+                       ohci_resources[1].start = INT_730_USB_HHC_1;
                status = platform_device_register(&ohci_device);
                if (status)
                        pr_debug("can't register OHCI device, %d\n", status);
@@ -462,10 +475,12 @@
 #ifdef CONFIG_USB_OTG
        if (config->otg) {
                syscon &= ~OTG_IDLE_EN;
+               otg_device.dev.platform_data = config;
                if (cpu_is_omap730())
                        otg_resources[1].start = INT_730_USB_OTG;
                status = platform_device_register(&otg_device);
-               // ...
+               if (status)
+                       pr_debug("can't register OTG device, %d\n", status);
        }
 #endif
        pr_debug("OTG_SYSCON_1_REG = %08x\n", syscon);
@@ -482,10 +497,6 @@
 
 #ifdef CONFIG_ARCH_OMAP1510
 
-#define ULPD_SOFT_REQ_REG      __REG16(ULPD_SOFT_REQ)
-#define SOFT_UDC_REQ           (1 << 4)
-#define SOFT_DPLL_REQ          (1 << 0)
-
 #define ULPD_DPLL_CTRL_REG     __REG16(ULPD_DPLL_CTRL)
 #define DPLL_IOB               (1 << 13)
 #define DPLL_PLL_ENABLE                (1 << 4)
@@ -546,7 +557,6 @@
                /* hcd explicitly gates 48MHz */
        }
 #endif
-
 }
 
 #else
@@ -564,7 +574,8 @@
 
        config = omap_get_config(OMAP_TAG_USB, struct omap_usb_config);
        if (config == NULL) {
-               printk(KERN_ERR "USB: No board-specific platform config 
found\n");
+               printk(KERN_ERR "USB: No board-specific "
+                               "platform config found\n");
                return -ENODEV;
        }
        platform_data = *config;
diff -Nru a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
--- a/drivers/usb/core/hub.c    2005-03-30 15:24:45 -08:00
+++ b/drivers/usb/core/hub.c    2005-03-30 15:24:45 -08:00
@@ -289,6 +289,11 @@
        spin_unlock_irqrestore(&hub_event_lock, flags);
 }
 
+void usb_kick_khubd(struct usb_device *hdev)
+{
+       kick_khubd(hdev_to_hub(hdev));
+}
+
 
 /* completion function, fires on port status changes and various faults */
 static void hub_irq(struct urb *urb, struct pt_regs *regs)
@@ -1383,8 +1388,13 @@
                        dev_err(hub->intfdev,
                                        "cannot reset port %d (err = %d)\n",
                                        port1, status);
-               else
+               else {
                        status = hub_port_wait_reset(hub, port1, udev, delay);
+                       if (status)
+                               dev_dbg(hub->intfdev,
+                                               "port_wait_reset: err = %d\n",
+                                               status);
+               }
 
                /* return on disconnect or reset */
                switch (status) {
@@ -1533,7 +1543,8 @@
  * Linux (2.6) currently has NO mechanisms to initiate that:  no khubd
  * timer, no SRP, no requests through sysfs.
  */
-int __usb_suspend_device (struct usb_device *udev, int port1, pm_message_t 
state)
+static int __usb_suspend_device (struct usb_device *udev, int port1,
+                                pm_message_t state)
 {
        int     status;
 
@@ -1614,9 +1625,11 @@
                struct usb_bus  *bus = udev->bus;
                if (bus && bus->op->hub_suspend) {
                        status = bus->op->hub_suspend (bus);
-                       if (status == 0)
+                       if (status == 0) {
+                               dev_dbg(&udev->dev, "usb suspend\n");
                                usb_set_device_state(udev,
                                                USB_STATE_SUSPENDED);
+                       }
                } else
                        status = -EOPNOTSUPP;
        } else
@@ -1834,9 +1847,11 @@
                } else
                        status = -EOPNOTSUPP;
                if (status == 0) {
+                       dev_dbg(&udev->dev, "usb resume\n");
                        /* TRSMRCY = 10 msec */
                        msleep(10);
                        usb_set_device_state (udev, USB_STATE_CONFIGURED);
+                       udev->dev.power.power_state = PMSG_ON;
                        status = hub_resume (udev
                                        ->actconfig->interface[0]);
                }
@@ -1955,10 +1970,19 @@
        }
        intf->dev.power.power_state = PMSG_ON;
 
+       hub->resume_root_hub = 0;
        hub_activate(hub);
        return 0;
 }
 
+void usb_resume_root_hub(struct usb_device *hdev)
+{
+       struct usb_hub *hub = hdev_to_hub(hdev);
+
+       hub->resume_root_hub = 1;
+       kick_khubd(hub);
+}
+
 #else  /* !CONFIG_USB_SUSPEND */
 
 int usb_suspend_device(struct usb_device *udev, pm_message_t state)
@@ -2615,15 +2639,30 @@
                                (u16) hub->event_bits[0]);
 
                usb_get_intf(intf);
+               i = hub->resume_root_hub;
                spin_unlock_irq(&hub_event_lock);
 
+               /* Is this is a root hub wanting to be resumed? */
+               if (i)
+                       usb_resume_device(hdev);
+
                /* Lock the device, then check to see if we were
                 * disconnected while waiting for the lock to succeed. */
                if (locktree(hdev) < 0) {
                        usb_put_intf(intf);
                        continue;
                }
-               if (hub != usb_get_intfdata(intf) || hub->quiescing)
+               if (hub != usb_get_intfdata(intf))
+                       goto loop;
+
+               /* If the hub has died, clean up after it */
+               if (hdev->state == USB_STATE_NOTATTACHED) {
+                       hub_pre_reset(hub);
+                       goto loop;
+               }
+
+               /* If this is an inactive or suspended hub, do nothing */
+               if (hub->quiescing)
                        goto loop;
 
                if (hub->error) {
@@ -2643,6 +2682,8 @@
 
                /* deal with port status changes */
                for (i = 1; i <= hub->descriptor->bNbrPorts; i++) {
+                       if (test_bit(i, hub->busy_bits))
+                               continue;
                        connect_change = test_bit(i, hub->change_bits);
                        if (!test_and_clear_bit(i, hub->event_bits) &&
                                        !connect_change && !hub->activating)
@@ -2948,6 +2989,7 @@
                hub_pre_reset(hub);
        }
 
+       set_bit(port1, parent_hub->busy_bits);
        for (i = 0; i < SET_CONFIG_TRIES; ++i) {
 
                /* ep0 maxpacket size may change; let the HCD know about it.
@@ -2957,6 +2999,7 @@
                if (ret >= 0)
                        break;
        }
+       clear_bit(port1, parent_hub->busy_bits);
        if (ret < 0)
                goto re_enumerate;
  
diff -Nru a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
--- a/drivers/usb/gadget/ether.c        2005-03-30 15:24:45 -08:00
+++ b/drivers/usb/gadget/ether.c        2005-03-30 15:24:45 -08:00
@@ -1,7 +1,7 @@
 /*
  * ether.c -- Ethernet gadget driver, with CDC and non-CDC options
  *
- * Copyright (C) 2003-2004 David Brownell
+ * Copyright (C) 2003-2005 David Brownell
  * Copyright (C) 2003-2004 Robert Schwebel, Benedikt Spranger
  *
  * This program is free software; you can redistribute it and/or modify
@@ -98,12 +98,18 @@
 #define rndis_exit() do{}while(0)
 #endif
 
+/* CDC and RNDIS support the same host-chosen outgoing packet filters. */
+#define        DEFAULT_FILTER  (USB_CDC_PACKET_TYPE_BROADCAST \
+                       |USB_CDC_PACKET_TYPE_DIRECTED)
+
+
 /*-------------------------------------------------------------------------*/
 
 struct eth_dev {
        spinlock_t              lock;
        struct usb_gadget       *gadget;
        struct usb_request      *req;           /* for control responses */
+       struct usb_request      *stat_req;      /* for cdc & rndis status */
 
        u8                      config;
        struct usb_ep           *in_ep, *out_ep, *status_ep;
@@ -243,6 +249,10 @@
 #define DEV_CONFIG_CDC
 #endif
 
+#ifdef CONFIG_USB_GADGET_AT91
+#define DEV_CONFIG_CDC
+#endif
+
 
 /* For CDC-incapable hardware, choose the simple cdc subset.
  * Anything that talks bulk (without notable bugs) can do this.
@@ -266,8 +276,39 @@
 
 /*-------------------------------------------------------------------------*/
 
+/* "main" config is either CDC, or its simple subset */
+static inline int is_cdc(struct eth_dev *dev)
+{
+#if    !defined(DEV_CONFIG_SUBSET)
+       return 1;               /* only cdc possible */
+#elif  !defined (DEV_CONFIG_CDC)
+       return 0;               /* only subset possible */
+#else
+       return dev->cdc;        /* depends on what hardware we found */
+#endif
+}
+
+/* "secondary" RNDIS config may sometimes be activated */
+static inline int rndis_active(struct eth_dev *dev)
+{
+#ifdef CONFIG_USB_ETH_RNDIS
+       return dev->rndis;
+#else
+       return 0;
+#endif
+}
+
+#define        subset_active(dev)      (!is_cdc(dev) && !rndis_active(dev))
+#define        cdc_active(dev)         ( is_cdc(dev) && !rndis_active(dev))
+
+
+
 #define DEFAULT_QLEN   2       /* double buffering by default */
 
+/* peak bulk transfer bits-per-second */
+#define        HS_BPS          (13 * 512 * 8 * 1000 * 8)
+#define        FS_BPS          (19 *  64 * 1 * 1000 * 8)
+
 #ifdef CONFIG_USB_GADGET_DUALSPEED
 
 static unsigned qmult = 5;
@@ -281,12 +322,12 @@
 /* also defer IRQs on highspeed TX */
 #define TX_DELAY       qmult
 
-#define        BITRATE(g) ((g->speed == USB_SPEED_HIGH) ? 4800000 : 120000)
+#define        BITRATE(g)      (((g)->speed == USB_SPEED_HIGH) ? HS_BPS : 
FS_BPS)
 
 #else  /* full speed (low speed doesn't do bulk) */
 #define qlen(gadget) DEFAULT_QLEN
 
-#define        BITRATE(g)      (12000)
+#define        BITRATE(g)      FS_BPS
 #endif
 
 
@@ -519,9 +560,8 @@
 #if defined(DEV_CONFIG_CDC) || defined(CONFIG_USB_ETH_RNDIS)
 
 /* include the status endpoint if we can, even where it's optional.
- * use small wMaxPacketSize, since many "interrupt" endpoints have
- * very small fifos and it's no big deal if CDC_NOTIFY_SPEED_CHANGE
- * takes two packets.  also default to a big transfer interval, to
+ * use wMaxPacketSize big enough to fit CDC_NOTIFY_SPEED_CHANGE in one
+ * packet, to simplify cancelation; and a big transfer interval, to
  * waste less bandwidth.
  *
  * some drivers (like Linux 2.4 cdc-ether!) "need" it to exist even
@@ -534,7 +574,7 @@
  */
  
 #define LOG2_STATUS_INTERVAL_MSEC      5       /* 1 << 5 == 32 msec */
-#define STATUS_BYTECOUNT               8       /* 8 byte header + data */
+#define STATUS_BYTECOUNT               16      /* 8 byte header + data */
 
 static struct usb_endpoint_descriptor
 fs_status_desc = {
@@ -916,14 +956,12 @@
        if (strcmp (ep->name, EP_IN_NAME) == 0) {
                d = ep_desc (dev->gadget, &hs_source_desc, &fs_source_desc);
                ep->driver_data = dev;
-               dev->in_ep = ep;
                dev->in = d;
 
        /* one endpoint just reads OUT packets */
        } else if (strcmp (ep->name, EP_OUT_NAME) == 0) {
                d = ep_desc (dev->gadget, &hs_sink_desc, &fs_sink_desc);
                ep->driver_data = dev;
-               dev->out_ep = ep;
                dev->out = d;
 
        /* optional status/notification endpoint */
@@ -937,7 +975,6 @@
                        return result;
 
                ep->driver_data = dev;
-               dev->status_ep = ep;
                dev->status = d;
        }
        return 0;
@@ -964,7 +1001,6 @@
                        return result;
 
                ep->driver_data = dev;
-               dev->in_ep = ep;
                dev->in = d;
 
        /* one endpoint just reads OUT packets */
@@ -975,7 +1011,6 @@
                        return result;
 
                ep->driver_data = dev;
-               dev->out_ep = ep;
                dev->out = d;
        }
 
@@ -1006,7 +1041,6 @@
                        result = usb_ep_enable (ep, d);
                        if (result == 0) {
                                ep->driver_data = dev;
-                               dev->status_ep = ep;
                                dev->status = d;
                                continue;
                        }
@@ -1034,22 +1068,19 @@
        /* on error, disable any endpoints  */
        if (result < 0) {
 #if defined(DEV_CONFIG_CDC) || defined(CONFIG_USB_ETH_RNDIS)
-               if (dev->status_ep)
+               if (dev->status)
                        (void) usb_ep_disable (dev->status_ep);
 #endif
-               dev->status_ep = NULL;
                dev->status = NULL;
 #if defined(DEV_CONFIG_SUBSET) || defined(CONFIG_USB_ETH_RNDIS)
                if (dev->rndis || !dev->cdc) {
-                       if (dev->in_ep)
+                       if (dev->in)
                                (void) usb_ep_disable (dev->in_ep);
-                       if (dev->out_ep)
+                       if (dev->out)
                                (void) usb_ep_disable (dev->out_ep);
                }
 #endif
-               dev->in_ep = NULL;
                dev->in = NULL;
-               dev->out_ep = NULL;
                dev->out = NULL;
        } else
 
@@ -1089,7 +1120,7 @@
        /* disable endpoints, forcing (synchronous) completion of
         * pending i/o.  then free the requests.
         */
-       if (dev->in_ep) {
+       if (dev->in) {
                usb_ep_disable (dev->in_ep);
                while (likely (!list_empty (&dev->tx_reqs))) {
                        req = container_of (dev->tx_reqs.next,
@@ -1097,9 +1128,8 @@
                        list_del (&req->list);
                        usb_ep_free_request (dev->in_ep, req);
                }
-               dev->in_ep = NULL;
        }
-       if (dev->out_ep) {
+       if (dev->out) {
                usb_ep_disable (dev->out_ep);
                while (likely (!list_empty (&dev->rx_reqs))) {
                        req = container_of (dev->rx_reqs.next,
@@ -1107,12 +1137,10 @@
                        list_del (&req->list);
                        usb_ep_free_request (dev->out_ep, req);
                }
-               dev->out_ep = NULL;
        }
 
-       if (dev->status_ep) {
+       if (dev->status) {
                usb_ep_disable (dev->status_ep);
-               dev->status_ep = NULL;
        }
        dev->config = 0;
 }
@@ -1213,28 +1241,22 @@
                event->wLength = __constant_cpu_to_le16 (8);
 
                /* SPEED_CHANGE data is up/down speeds in bits/sec */
-               data [0] = data [1] = cpu_to_le32(
-                       (dev->gadget->speed == USB_SPEED_HIGH)
-                               ? (13 * 512 * 8 * 1000 * 8)
-                               : (19 *  64 * 1 * 1000 * 8));
+               data [0] = data [1] = cpu_to_le32 (BITRATE (dev->gadget));
 
-               req->length = 16;
+               req->length = STATUS_BYTECOUNT;
                value = usb_ep_queue (ep, req, GFP_ATOMIC);
                DEBUG (dev, "send SPEED_CHANGE --> %d\n", value);
                if (value == 0)
                        return;
-       } else
+       } else if (value != -ECONNRESET)
                DEBUG (dev, "event %02x --> %d\n",
                        event->bNotificationType, value);
-
-       /* free when done */
-       usb_ep_free_buffer (ep, req->buf, req->dma, 16);
-       usb_ep_free_request (ep, req);
+       event->bmRequestType = 0xff;
 }
 
 static void issue_start_status (struct eth_dev *dev)
 {
-       struct usb_request              *req;
+       struct usb_request              *req = dev->stat_req;
        struct usb_cdc_notification     *event;
        int                             value;
  
@@ -1250,21 +1272,6 @@
        usb_ep_disable (dev->status_ep);
        usb_ep_enable (dev->status_ep, dev->status);
 
-       /* FIXME make these allocations static like dev->req */
-       req = usb_ep_alloc_request (dev->status_ep, GFP_ATOMIC);
-       if (req == 0) {
-               DEBUG (dev, "status ENOMEM\n");
-               return;
-       }
-       req->buf = usb_ep_alloc_buffer (dev->status_ep, 16,
-                               &dev->req->dma, GFP_ATOMIC);
-       if (req->buf == 0) {
-               DEBUG (dev, "status buf ENOMEM\n");
-free_req:
-               usb_ep_free_request (dev->status_ep, req);
-               return;
-       }
-
        /* 3.8.1 says to issue first NETWORK_CONNECTION, then
         * a SPEED_CHANGE.  could be useful in some configs.
         */
@@ -1275,15 +1282,11 @@
        event->wIndex = __constant_cpu_to_le16 (1);
        event->wLength = 0;
 
-       req->length = 8;
+       req->length = sizeof *event;
        req->complete = eth_status_complete;
        value = usb_ep_queue (dev->status_ep, req, GFP_ATOMIC);
-       if (value < 0) {
+       if (value < 0)
                DEBUG (dev, "status buf queue --> %d\n", value);
-               usb_ep_free_buffer (dev->status_ep,
-                               req->buf, dev->req->dma, 16);
-               goto free_req;
-       }
 }
 
 #endif
@@ -1431,7 +1434,7 @@
                case 0:         /* control/master intf */
                        if (wValue != 0)
                                break;
-                       if (dev->status_ep) {
+                       if (dev->status) {
                                usb_ep_disable (dev->status_ep);
                                usb_ep_enable (dev->status_ep, dev->status);
                        }
@@ -1450,8 +1453,9 @@
                        if (wValue == 1) {
                                usb_ep_enable (dev->in_ep, dev->in);
                                usb_ep_enable (dev->out_ep, dev->out);
+                               dev->cdc_filter = DEFAULT_FILTER;
                                netif_carrier_on (dev->net);
-                               if (dev->status_ep)
+                               if (dev->status)
                                        issue_start_status (dev);
                                if (netif_running (dev->net)) {
                                        spin_unlock (&dev->lock);
@@ -1502,14 +1506,18 @@
                                || wLength != 0
                                || wIndex > 1)
                        break;
-               DEBUG (dev, "NOP packet filter %04x\n", wValue);
-               /* NOTE: table 62 has 5 filter bits to reduce traffic,
-                * and we "must" support multicast and promiscuous.
-                * this NOP implements a bad filter (always promisc)
-                */
+               DEBUG (dev, "packet filter %02x\n", wValue);
                dev->cdc_filter = wValue;
                value = 0;
                break;
+
+       /* and potentially:
+        * case USB_CDC_SET_ETHERNET_MULTICAST_FILTERS:
+        * case USB_CDC_SET_ETHERNET_PM_PATTERN_FILTER:
+        * case USB_CDC_GET_ETHERNET_PM_PATTERN_FILTER:
+        * case USB_CDC_GET_ETHERNET_STATISTIC:
+        */
+
 #endif /* DEV_CONFIG_CDC */
 
 #ifdef CONFIG_USB_ETH_RNDIS            
@@ -1904,6 +1912,14 @@
                netif_wake_queue (dev->net);
 }
 
+static inline int eth_is_promisc (struct eth_dev *dev)
+{
+       /* no filters for the CDC subset; always promisc */
+       if (subset_active (dev))
+               return 1;
+       return dev->cdc_filter & USB_CDC_PACKET_TYPE_PROMISCUOUS;
+}
+
 static int eth_start_xmit (struct sk_buff *skb, struct net_device *net)
 {
        struct eth_dev          *dev = netdev_priv(net);
@@ -1912,10 +1928,27 @@
        struct usb_request      *req = NULL;
        unsigned long           flags;
 
-       /* FIXME check dev->cdc_filter to decide whether to send this,
-        * instead of acting as if USB_CDC_PACKET_TYPE_PROMISCUOUS were
-        * always set.  RNDIS has the same kind of outgoing filter.
-        */
+       /* apply outgoing CDC or RNDIS filters */
+       if (!eth_is_promisc (dev)) {
+               u8              *dest = skb->data;
+
+               if (dest [0] & 0x01) {
+                       u16     type;
+
+                       /* ignores USB_CDC_PACKET_TYPE_MULTICAST and host
+                        * SET_ETHERNET_MULTICAST_FILTERS requests
+                        */
+                       if (memcmp (dest, net->broadcast, ETH_ALEN) == 0)
+                               type = USB_CDC_PACKET_TYPE_BROADCAST;
+                       else
+                               type = USB_CDC_PACKET_TYPE_ALL_MULTICAST;
+                       if (!(dev->cdc_filter & type)) {
+                               dev_kfree_skb_any (skb);
+                               return 0;
+                       }
+               }
+               /* ignores USB_CDC_PACKET_TYPE_DIRECTED */
+       }
 
        spin_lock_irqsave (&dev->lock, flags);
        req = container_of (dev->tx_reqs.next, struct usb_request, list);
@@ -2137,6 +2170,30 @@
 
 /*-------------------------------------------------------------------------*/
 
+static struct usb_request *eth_req_alloc (struct usb_ep *ep, unsigned size)
+{
+       struct usb_request      *req;
+
+       req = usb_ep_alloc_request (ep, GFP_KERNEL);
+       if (!req)
+               return NULL;
+
+       req->buf = kmalloc (size, GFP_KERNEL);
+       if (!req->buf) {
+               usb_ep_free_request (ep, req);
+               req = NULL;
+       }
+       return req;
+}
+
+static void
+eth_req_free (struct usb_ep *ep, struct usb_request *req)
+{
+       kfree (req->buf);
+       usb_ep_free_request (ep, req);
+}
+
+
 static void
 eth_unbind (struct usb_gadget *gadget)
 {
@@ -2150,12 +2207,13 @@
 
        /* we've already been disconnected ... no i/o is active */
        if (dev->req) {
-               usb_ep_free_buffer (gadget->ep0,
-                               dev->req->buf, dev->req->dma,
-                               USB_BUFSIZ);
-               usb_ep_free_request (gadget->ep0, dev->req);
+               eth_req_free (gadget->ep0, dev->req);
                dev->req = NULL;
        }
+       if (dev->stat_req) {
+               eth_req_free (dev->status_ep, dev->stat_req);
+               dev->stat_req = NULL;
+       }
 
        unregister_netdev (dev->net);
        free_netdev(dev->net);
@@ -2201,7 +2259,7 @@
        struct eth_dev          *dev;
        struct net_device       *net;
        u8                      cdc = 1, zlp = 1, rndis = 1;
-       struct usb_ep           *ep;
+       struct usb_ep           *in_ep, *out_ep, *status_ep = NULL;
        int                     status = -ENOMEM;
 
        /* these flags are only ever cleared; compiler take note */
@@ -2251,6 +2309,8 @@
                device_desc.bcdDevice = __constant_cpu_to_le16 (0x0211);
        } else if (gadget_is_s3c2410(gadget)) {
                device_desc.bcdDevice = __constant_cpu_to_le16 (0x0212);
+       } else if (gadget_is_at91(gadget)) {
+               device_desc.bcdDevice = __constant_cpu_to_le16 (0x0213);
        } else {
                /* can't assume CDC works.  don't want to default to
                 * anything less functional on CDC-capable hardware,
@@ -2308,32 +2368,32 @@
 
        /* all we really need is bulk IN/OUT */
        usb_ep_autoconfig_reset (gadget);
-       ep = usb_ep_autoconfig (gadget, &fs_source_desc);
-       if (!ep) {
+       in_ep = usb_ep_autoconfig (gadget, &fs_source_desc);
+       if (!in_ep) {
 autoconf_fail:
                dev_err (&gadget->dev,
                        "can't autoconfigure on %s\n",
                        gadget->name);
                return -ENODEV;
        }
-       EP_IN_NAME = ep->name;
-       ep->driver_data = ep;   /* claim */
+       EP_IN_NAME = in_ep->name;
+       in_ep->driver_data = in_ep;     /* claim */
        
-       ep = usb_ep_autoconfig (gadget, &fs_sink_desc);
-       if (!ep)
+       out_ep = usb_ep_autoconfig (gadget, &fs_sink_desc);
+       if (!out_ep)
                goto autoconf_fail;
-       EP_OUT_NAME = ep->name;
-       ep->driver_data = ep;   /* claim */
+       EP_OUT_NAME = out_ep->name;
+       out_ep->driver_data = out_ep;   /* claim */
 
 #if defined(DEV_CONFIG_CDC) || defined(CONFIG_USB_ETH_RNDIS)
        /* CDC Ethernet control interface doesn't require a status endpoint.
         * Since some hosts expect one, try to allocate one anyway.
         */
        if (cdc || rndis) {
-               ep = usb_ep_autoconfig (gadget, &fs_status_desc);
-               if (ep) {
-                       EP_STATUS_NAME = ep->name;
-                       ep->driver_data = ep;   /* claim */
+               status_ep = usb_ep_autoconfig (gadget, &fs_status_desc);
+               if (status_ep) {
+                       EP_STATUS_NAME = status_ep->name;
+                       status_ep->driver_data = status_ep;     /* claim */
                } else if (rndis) {
                        dev_err (&gadget->dev,
                                "can't run RNDIS on %s\n",
@@ -2409,6 +2469,10 @@
        dev->cdc = cdc;
        dev->zlp = zlp;
 
+       dev->in_ep = in_ep;
+       dev->out_ep = out_ep;
+       dev->status_ep = status_ep;
+
        /* Module params for these addresses should come from ID proms.
         * The host side address is used with CDC and RNDIS, and commonly
         * ends up in a persistent config database.
@@ -2442,16 +2506,20 @@
        // set_multicast_list
        SET_ETHTOOL_OPS(net, &ops);
 
-       /* preallocate control response and buffer */
-       dev->req = usb_ep_alloc_request (gadget->ep0, GFP_KERNEL);
+       /* preallocate control message data and buffer */
+       dev->req = eth_req_alloc (gadget->ep0, USB_BUFSIZ);
        if (!dev->req)
                goto fail;
        dev->req->complete = eth_setup_complete;
-       dev->req->buf = usb_ep_alloc_buffer (gadget->ep0, USB_BUFSIZ,
-                               &dev->req->dma, GFP_KERNEL);
-       if (!dev->req->buf) {
-               usb_ep_free_request (gadget->ep0, dev->req);
-               goto fail;
+
+       /* ... and maybe likewise for status transfer */
+       if (dev->status_ep) {
+               dev->stat_req = eth_req_alloc (dev->status_ep,
+                                       STATUS_BYTECOUNT);
+               if (!dev->stat_req) {
+                       eth_req_free (gadget->ep0, dev->req);
+                       goto fail;
+               }
        }
 
        /* finish hookup to lower layer ... */
diff -Nru a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
--- a/drivers/usb/host/sl811-hcd.c      2005-03-30 15:24:45 -08:00
+++ b/drivers/usb/host/sl811-hcd.c      2005-03-30 15:24:45 -08:00
@@ -105,7 +105,7 @@
        } else {
                sl811->port1 = 0;
                sl811->irq_enable = 0;
-               hcd->state = USB_STATE_HALT;
+               hcd->state = HC_STATE_HALT;
                hcd->self.controller->power.power_state = PMSG_SUSPEND;
        }
        sl811->ctrl1 = 0;
@@ -834,7 +834,7 @@
 
        /* don't submit to a dead or disabled port */
        if (!(sl811->port1 & (1 << USB_PORT_FEAT_ENABLE))
-                       || !HCD_IS_RUNNING(hcd->state)) {
+                       || !HC_IS_RUNNING(hcd->state)) {
                retval = -ENODEV;
                goto fail;
        }
@@ -1562,12 +1562,12 @@
                return -ENOMEM;
 
        udev->speed = USB_SPEED_FULL;
-       hcd->state = USB_STATE_RUNNING;
+       hcd->state = HC_STATE_RUNNING;
 
        if (sl811->board)
                hcd->can_wakeup = sl811->board->can_wakeup;
 
-       if (hcd_register_root(udev, hcd) != 0) {
+       if (usb_hcd_register_root_hub(udev, hcd) != 0) {
                usb_put_dev(udev);
                sl811h_stop(hcd);
                return -ENODEV;
diff -Nru a/drivers/usb/media/pwc/pwc-if.c b/drivers/usb/media/pwc/pwc-if.c
--- a/drivers/usb/media/pwc/pwc-if.c    2005-03-30 15:24:45 -08:00
+++ b/drivers/usb/media/pwc/pwc-if.c    2005-03-30 15:24:45 -08:00
@@ -1897,7 +1897,7 @@
        }
 
        init_MUTEX(&pdev->modlock);
-       pdev->ptrlock = SPIN_LOCK_UNLOCKED;
+       spin_lock_init(&pdev->ptrlock);
 
        pdev->udev = udev;
        init_waitqueue_head(&pdev->frameq);
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to