[ACPI] merge 3549 4320 4485 4588 4980 5483 5651 acpica asus fops pnpacpi branches...
[powerpc.git] / drivers / usb / net / usbnet.c
index d52480a..362d690 100644 (file)
@@ -1,7 +1,6 @@
 /*
- * USB Networking Links
+ * USB Network driver infrastructure
  * Copyright (C) 2000-2005 by David Brownell
- * Copyright (C) 2002 Pavel Machek <pavel@ucw.cz>
  * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com>
  *
  * This program is free software; you can redistribute it and/or modify
 
 /*
  * This is a generic "USB networking" framework that works with several
- * kinds of full and high speed networking devices:
+ * kinds of full and high speed networking devices:  host-to-host cables,
+ * smart usb peripherals, and actual Ethernet adapters.
  *
- *   + USB host-to-host "network cables", used for IP-over-USB links.
- *     These are often used for Laplink style connectivity products.
- *     - AnchorChip 2720
- *     - Belkin, eTEK (interops with Win32 drivers)
- *     - GeneSys GL620USB-A
- *     - NetChip 1080 (interoperates with NetChip Win32 drivers)
- *     - Prolific PL-2301/2302 (replaces "plusb" driver)
- *     - KC Technology KC2190
- *
- *   + Smart USB devices can support such links directly, using Internet
- *     standard protocols instead of proprietary host-to-device links.
- *     - Linux PDAs like iPaq, Yopy, and Zaurus
- *     - The BLOB boot loader (for diskless booting)
- *     - Linux "gadgets", perhaps using PXA-2xx or Net2280 controllers
- *     - Devices using EPSON's sample USB firmware
- *     - CDC-Ethernet class devices, such as many cable modems
- *
- *   + Adapters to networks such as Ethernet.
- *     - AX8817X based USB 2.0 products
- *
- * Links to these devices can be bridged using Linux Ethernet bridging.
- * With minor exceptions, these all use similar USB framing for network
- * traffic, but need different protocols for control traffic.
- *
- * USB devices can implement their side of this protocol at the cost
- * of two bulk endpoints; it's not restricted to "cable" applications.
- * See the SA1110, Zaurus, or EPSON device/client support in this driver;
- * slave/target drivers such as "usb-eth" (on most SA-1100 PDAs) or
- * "g_ether" (in the Linux "gadget" framework) implement that behavior
- * within devices.
- *
- *
- * CHANGELOG:
- *
- * 13-sep-2000 experimental, new
- * 10-oct-2000 usb_device_id table created. 
- * 28-oct-2000 misc fixes; mostly, discard more TTL-mangled rx packets.
- * 01-nov-2000 usb_device_id table and probing api update by
- *             Adam J. Richter <adam@yggdrasil.com>.
- * 18-dec-2000 (db) tx watchdog, "net1080" renaming to "usbnet", device_info
- *             and prolific support, isolate net1080-specific bits, cleanup.
- *             fix unlink_urbs oops in D3 PM resume code path.
- *
- * 02-feb-2001 (db) fix tx skb sharing, packet length, match_flags, ...
- * 08-feb-2001 stubbed in "linuxdev", maybe the SA-1100 folk can use it;
- *             AnchorChips 2720 support (from spec) for testing;
- *             fix bit-ordering problem with ethernet multicast addr
- * 19-feb-2001  Support for clearing halt conditions. SA1100 UDC support
- *             updates. Oleg Drokin (green@iXcelerator.com)
- * 25-mar-2001 More SA-1100 updates, including workaround for ip problem
- *             expecting cleared skb->cb and framing change to match latest
- *             handhelds.org version (Oleg).  Enable device IDs from the
- *             Win32 Belkin driver; other cleanups (db).
- * 16-jul-2001 Bugfixes for uhci oops-on-unplug, Belkin support, various
- *             cleanups for problems not yet seen in the field. (db)
- * 17-oct-2001 Handle "Advance USBNET" product, like Belkin/eTEK devices,
- *             from Ioannis Mavroukakis <i.mavroukakis@btinternet.com>;
- *             rx unlinks somehow weren't async; minor cleanup.
- * 03-nov-2001 Merged GeneSys driver; original code from Jiun-Jie Huang
- *             <huangjj@genesyslogic.com.tw>, updated by Stanislav Brabec
- *             <utx@penguin.cz>.  Made framing options (NetChip/GeneSys)
- *             tie mostly to (sub)driver info.  Workaround some PL-2302
- *             chips that seem to reject SET_INTERFACE requests.
- *
- * 06-apr-2002 Added ethtool support, based on a patch from Brad Hards.
- *             Level of diagnostics is more configurable; they use device
- *             location (usb_device->devpath) instead of address (2.5).
- *             For tx_fixup, memflags can't be NOIO.
- * 07-may-2002 Generalize/cleanup keventd support, handling rx stalls (mostly
- *             for USB 2.0 TTs) and memory shortages (potential) too. (db)
- *             Use "locally assigned" IEEE802 address space. (Brad Hards)
- * 18-oct-2002 Support for Zaurus (Pavel Machek), related cleanup (db).
- * 14-dec-2002 Remove Zaurus-private crc32 code (Pavel); 2.5 oops fix,
- *             cleanups and stubbed PXA-250 support (db), fix for framing
- *             issues on Z, net1080, and gl620a (Toby Milne)
- *
- * 31-mar-2003 Use endpoint descriptors:  high speed support, simpler sa1100
- *             vs pxa25x, and CDC Ethernet.  Throttle down log floods on
- *             disconnect; other cleanups. (db)  Flush net1080 fifos
- *             after several sequential framing errors. (Johannes Erdfelt)
- * 22-aug-2003 AX8817X support (Dave Hollis).
- * 14-jun-2004  Trivial patch for AX8817X based Buffalo LUA-U2-KTX in Japan
- *             (Neil Bortnak)
- * 03-nov-2004 Trivial patch for KC2190 (KC-190) chip. (Jonathan McDowell)
- *
- * 01-feb-2005 AX88772 support (Phil Chang & Dave Hollis)
- *-------------------------------------------------------------------------*/
+ * These devices usually differ in terms of control protocols (if they
+ * even have one!) and sometimes they define new framing to wrap or batch
+ * Ethernet packets.  Otherwise, they talk to USB pretty much the same,
+ * so interface (un)binding, endpoint I/O queues, fault handling, and other
+ * issues can usefully be addressed by this framework.
+ */
 
 // #define     DEBUG                   // error path messages, extra info
 // #define     VERBOSE                 // more; success messages
 
 #include <linux/config.h>
-#ifdef CONFIG_USB_DEBUG
-#   define DEBUG
-#endif
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/init.h>
@@ -173,14 +89,6 @@ MODULE_PARM_DESC (msg_level, "Override default message level");
 
 /*-------------------------------------------------------------------------*/
 
-static u32 usbnet_get_link (struct net_device *);
-
-/* mostly for PDA style devices, which are always connected if present */
-static int always_connected (struct usbnet *dev)
-{
-       return 0;
-}
-
 /* handles CDC Ethernet and many other network "bulk data" interfaces */
 int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf)
 {
@@ -310,687 +218,6 @@ void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb)
 EXPORT_SYMBOL_GPL(usbnet_skb_return);
 
 \f
-/*-------------------------------------------------------------------------
- *
- * Communications Device Class declarations.
- * Used by CDC Ethernet, and some CDC variants
- *
- *-------------------------------------------------------------------------*/
-
-#ifdef CONFIG_USB_CDCETHER
-#define NEED_GENERIC_CDC
-#endif
-
-#ifdef CONFIG_USB_ZAURUS
-/* Ethernet variant uses funky framing, broken ethernet addressing */
-#define NEED_GENERIC_CDC
-#endif
-
-#ifdef CONFIG_USB_RNDIS
-/* ACM variant uses even funkier framing, complex control RPC scheme */
-#define NEED_GENERIC_CDC
-#endif
-
-
-#ifdef NEED_GENERIC_CDC
-
-#include <linux/usb_cdc.h>
-
-struct cdc_state {
-       struct usb_cdc_header_desc      *header;
-       struct usb_cdc_union_desc       *u;
-       struct usb_cdc_ether_desc       *ether;
-       struct usb_interface            *control;
-       struct usb_interface            *data;
-};
-
-static struct usb_driver usbnet_driver;
-
-/*
- * probes control interface, claims data interface, collects the bulk
- * endpoints, activates data interface (if needed), maybe sets MTU.
- * all pure cdc, except for certain firmware workarounds.
- */
-static int generic_cdc_bind (struct usbnet *dev, struct usb_interface *intf)
-{
-       u8                              *buf = intf->cur_altsetting->extra;
-       int                             len = intf->cur_altsetting->extralen;
-       struct usb_interface_descriptor *d;
-       struct cdc_state                *info = (void *) &dev->data;
-       int                             status;
-       int                             rndis;
-
-       if (sizeof dev->data < sizeof *info)
-               return -EDOM;
-
-       /* expect strict spec conformance for the descriptors, but
-        * cope with firmware which stores them in the wrong place
-        */
-       if (len == 0 && dev->udev->actconfig->extralen) {
-               /* Motorola SB4100 (and others: Brad Hards says it's
-                * from a Broadcom design) put CDC descriptors here
-                */
-               buf = dev->udev->actconfig->extra;
-               len = dev->udev->actconfig->extralen;
-               if (len)
-                       dev_dbg (&intf->dev,
-                               "CDC descriptors on config\n");
-       }
-
-       /* this assumes that if there's a non-RNDIS vendor variant
-        * of cdc-acm, it'll fail RNDIS requests cleanly.
-        */
-       rndis = (intf->cur_altsetting->desc.bInterfaceProtocol == 0xff);
-
-       memset (info, 0, sizeof *info);
-       info->control = intf;
-       while (len > 3) {
-               if (buf [1] != USB_DT_CS_INTERFACE)
-                       goto next_desc;
-
-               /* use bDescriptorSubType to identify the CDC descriptors.
-                * We expect devices with CDC header and union descriptors.
-                * For CDC Ethernet we need the ethernet descriptor.
-                * For RNDIS, ignore two (pointless) CDC modem descriptors
-                * in favor of a complicated OID-based RPC scheme doing what
-                * CDC Ethernet achieves with a simple descriptor.
-                */
-               switch (buf [2]) {
-               case USB_CDC_HEADER_TYPE:
-                       if (info->header) {
-                               dev_dbg (&intf->dev, "extra CDC header\n");
-                               goto bad_desc;
-                       }
-                       info->header = (void *) buf;
-                       if (info->header->bLength != sizeof *info->header) {
-                               dev_dbg (&intf->dev, "CDC header len %u\n",
-                                       info->header->bLength);
-                               goto bad_desc;
-                       }
-                       break;
-               case USB_CDC_UNION_TYPE:
-                       if (info->u) {
-                               dev_dbg (&intf->dev, "extra CDC union\n");
-                               goto bad_desc;
-                       }
-                       info->u = (void *) buf;
-                       if (info->u->bLength != sizeof *info->u) {
-                               dev_dbg (&intf->dev, "CDC union len %u\n",
-                                       info->u->bLength);
-                               goto bad_desc;
-                       }
-
-                       /* we need a master/control interface (what we're
-                        * probed with) and a slave/data interface; union
-                        * descriptors sort this all out.
-                        */
-                       info->control = usb_ifnum_to_if(dev->udev,
-                                               info->u->bMasterInterface0);
-                       info->data = usb_ifnum_to_if(dev->udev,
-                                               info->u->bSlaveInterface0);
-                       if (!info->control || !info->data) {
-                               dev_dbg (&intf->dev,
-                                       "master #%u/%p slave #%u/%p\n",
-                                       info->u->bMasterInterface0,
-                                       info->control,
-                                       info->u->bSlaveInterface0,
-                                       info->data);
-                               goto bad_desc;
-                       }
-                       if (info->control != intf) {
-                               dev_dbg (&intf->dev, "bogus CDC Union\n");
-                               /* Ambit USB Cable Modem (and maybe others)
-                                * interchanges master and slave interface.
-                                */
-                               if (info->data == intf) {
-                                       info->data = info->control;
-                                       info->control = intf;
-                               } else
-                                       goto bad_desc;
-                       }
-
-                       /* a data interface altsetting does the real i/o */
-                       d = &info->data->cur_altsetting->desc;
-                       if (d->bInterfaceClass != USB_CLASS_CDC_DATA) {
-                               dev_dbg (&intf->dev, "slave class %u\n",
-                                       d->bInterfaceClass);
-                               goto bad_desc;
-                       }
-                       break;
-               case USB_CDC_ETHERNET_TYPE:
-                       if (info->ether) {
-                               dev_dbg (&intf->dev, "extra CDC ether\n");
-                               goto bad_desc;
-                       }
-                       info->ether = (void *) buf;
-                       if (info->ether->bLength != sizeof *info->ether) {
-                               dev_dbg (&intf->dev, "CDC ether len %u\n",
-                                       info->ether->bLength);
-                               goto bad_desc;
-                       }
-                       dev->hard_mtu = le16_to_cpu(
-                                               info->ether->wMaxSegmentSize);
-                       /* because of Zaurus, we may be ignoring the host
-                        * side link address we were given.
-                        */
-                       break;
-               }
-next_desc:
-               len -= buf [0]; /* bLength */
-               buf += buf [0];
-       }
-
-       if (!info->header || !info->u || (!rndis && !info->ether)) {
-               dev_dbg (&intf->dev, "missing cdc %s%s%sdescriptor\n",
-                       info->header ? "" : "header ",
-                       info->u ? "" : "union ",
-                       info->ether ? "" : "ether ");
-               goto bad_desc;
-       }
-
-       /* claim data interface and set it up ... with side effects.
-        * network traffic can't flow until an altsetting is enabled.
-        */
-       status = usb_driver_claim_interface (&usbnet_driver, info->data, dev);
-       if (status < 0)
-               return status;
-       status = usbnet_get_endpoints (dev, info->data);
-       if (status < 0) {
-               /* ensure immediate exit from usbnet_disconnect */
-               usb_set_intfdata(info->data, NULL);
-               usb_driver_release_interface (&usbnet_driver, info->data);
-               return status;
-       }
-
-       /* status endpoint: optional for CDC Ethernet, not RNDIS (or ACM) */
-       dev->status = NULL;
-       if (info->control->cur_altsetting->desc.bNumEndpoints == 1) {
-               struct usb_endpoint_descriptor  *desc;
-
-               dev->status = &info->control->cur_altsetting->endpoint [0];
-               desc = &dev->status->desc;
-               if (desc->bmAttributes != USB_ENDPOINT_XFER_INT
-                               || !(desc->bEndpointAddress & USB_DIR_IN)
-                               || (le16_to_cpu(desc->wMaxPacketSize)
-                                       < sizeof (struct usb_cdc_notification))
-                               || !desc->bInterval) {
-                       dev_dbg (&intf->dev, "bad notification endpoint\n");
-                       dev->status = NULL;
-               }
-       }
-       if (rndis && !dev->status) {
-               dev_dbg (&intf->dev, "missing RNDIS status endpoint\n");
-               usb_set_intfdata(info->data, NULL);
-               usb_driver_release_interface (&usbnet_driver, info->data);
-               return -ENODEV;
-       }
-       return 0;
-
-bad_desc:
-       dev_info (&dev->udev->dev, "bad CDC descriptors\n");
-       return -ENODEV;
-}
-
-static void cdc_unbind (struct usbnet *dev, struct usb_interface *intf)
-{
-       struct cdc_state                *info = (void *) &dev->data;
-
-       /* disconnect master --> disconnect slave */
-       if (intf == info->control && info->data) {
-               /* ensure immediate exit from usbnet_disconnect */
-               usb_set_intfdata(info->data, NULL);
-               usb_driver_release_interface (&usbnet_driver, info->data);
-               info->data = NULL;
-       }
-
-       /* and vice versa (just in case) */
-       else if (intf == info->data && info->control) {
-               /* ensure immediate exit from usbnet_disconnect */
-               usb_set_intfdata(info->control, NULL);
-               usb_driver_release_interface (&usbnet_driver, info->control);
-               info->control = NULL;
-       }
-}
-
-#endif /* NEED_GENERIC_CDC */
-
-\f
-#ifdef CONFIG_USB_CDCETHER
-#define        HAVE_HARDWARE
-
-/*-------------------------------------------------------------------------
- *
- * Communications Device Class, Ethernet Control model
- *
- * Takes two interfaces.  The DATA interface is inactive till an altsetting
- * is selected.  Configuration data includes class descriptors.
- *
- * This should interop with whatever the 2.4 "CDCEther.c" driver
- * (by Brad Hards) talked with.
- *
- *-------------------------------------------------------------------------*/
-
-#include <linux/ctype.h>
-
-
-static void dumpspeed (struct usbnet *dev, __le32 *speeds)
-{
-       if (netif_msg_timer (dev))
-               devinfo (dev, "link speeds: %u kbps up, %u kbps down",
-                       __le32_to_cpu(speeds[0]) / 1000,
-               __le32_to_cpu(speeds[1]) / 1000);
-}
-
-static void cdc_status (struct usbnet *dev, struct urb *urb)
-{
-       struct usb_cdc_notification     *event;
-
-       if (urb->actual_length < sizeof *event)
-               return;
-       
-       /* SPEED_CHANGE can get split into two 8-byte packets */
-       if (test_and_clear_bit (EVENT_STS_SPLIT, &dev->flags)) {
-               dumpspeed (dev, (__le32 *) urb->transfer_buffer);
-               return;
-       }
-
-       event = urb->transfer_buffer;
-       switch (event->bNotificationType) {
-       case USB_CDC_NOTIFY_NETWORK_CONNECTION:
-               if (netif_msg_timer (dev))
-                       devdbg (dev, "CDC: carrier %s",
-                                       event->wValue ? "on" : "off");
-               if (event->wValue)
-                       netif_carrier_on(dev->net);
-               else
-                       netif_carrier_off(dev->net);
-               break;
-       case USB_CDC_NOTIFY_SPEED_CHANGE:       /* tx/rx rates */
-               if (netif_msg_timer (dev))
-                       devdbg (dev, "CDC: speed change (len %d)",
-                                       urb->actual_length);
-               if (urb->actual_length != (sizeof *event + 8))
-                       set_bit (EVENT_STS_SPLIT, &dev->flags);
-               else
-                       dumpspeed (dev, (__le32 *) &event[1]);
-               break;
-       // case USB_CDC_NOTIFY_RESPONSE_AVAILABLE:      /* RNDIS; or unsolicited */
-       default:
-               deverr (dev, "CDC: unexpected notification %02x!",
-                                event->bNotificationType);
-               break;
-       }
-}
-
-static u8 nibble (unsigned char c)
-{
-       if (likely (isdigit (c)))
-               return c - '0';
-       c = toupper (c);
-       if (likely (isxdigit (c)))
-               return 10 + c - 'A';
-       return 0;
-}
-
-static inline int
-get_ethernet_addr (struct usbnet *dev, struct usb_cdc_ether_desc *e)
-{
-       int             tmp, i;
-       unsigned char   buf [13];
-
-       tmp = usb_string (dev->udev, e->iMACAddress, buf, sizeof buf);
-       if (tmp != 12) {
-               dev_dbg (&dev->udev->dev,
-                       "bad MAC string %d fetch, %d\n", e->iMACAddress, tmp);
-               if (tmp >= 0)
-                       tmp = -EINVAL;
-               return tmp;
-       }
-       for (i = tmp = 0; i < 6; i++, tmp += 2)
-               dev->net->dev_addr [i] =
-                        (nibble (buf [tmp]) << 4) + nibble (buf [tmp + 1]);
-       return 0;
-}
-
-static int cdc_bind (struct usbnet *dev, struct usb_interface *intf)
-{
-       int                             status;
-       struct cdc_state                *info = (void *) &dev->data;
-
-       status = generic_cdc_bind (dev, intf);
-       if (status < 0)
-               return status;
-
-       status = get_ethernet_addr (dev, info->ether);
-       if (status < 0) {
-               usb_set_intfdata(info->data, NULL);
-               usb_driver_release_interface (&usbnet_driver, info->data);
-               return status;
-       }
-
-       /* FIXME cdc-ether has some multicast code too, though it complains
-        * in routine cases.  info->ether describes the multicast support.
-        */
-       return 0;
-}
-
-static const struct driver_info        cdc_info = {
-       .description =  "CDC Ethernet Device",
-       .flags =        FLAG_ETHER,
-       // .check_connect = cdc_check_connect,
-       .bind =         cdc_bind,
-       .unbind =       cdc_unbind,
-       .status =       cdc_status,
-};
-
-#endif /* CONFIG_USB_CDCETHER */
-
-
-\f
-#ifdef CONFIG_USB_PL2301
-#define        HAVE_HARDWARE
-
-/*-------------------------------------------------------------------------
- *
- * Prolific PL-2301/PL-2302 driver ... http://www.prolifictech.com
- *
- * The protocol and handshaking used here should be bug-compatible
- * with the Linux 2.2 "plusb" driver, by Deti Fliegl.
- *
- *-------------------------------------------------------------------------*/
-
-/*
- * Bits 0-4 can be used for software handshaking; they're set from
- * one end, cleared from the other, "read" with the interrupt byte.
- */
-#define        PL_S_EN         (1<<7)          /* (feature only) suspend enable */
-/* reserved bit -- rx ready (6) ? */
-#define        PL_TX_READY     (1<<5)          /* (interrupt only) transmit ready */
-#define        PL_RESET_OUT    (1<<4)          /* reset output pipe */
-#define        PL_RESET_IN     (1<<3)          /* reset input pipe */
-#define        PL_TX_C         (1<<2)          /* transmission complete */
-#define        PL_TX_REQ       (1<<1)          /* transmission received */
-#define        PL_PEER_E       (1<<0)          /* peer exists */
-
-static inline int
-pl_vendor_req (struct usbnet *dev, u8 req, u8 val, u8 index)
-{
-       return usb_control_msg (dev->udev,
-               usb_rcvctrlpipe (dev->udev, 0),
-               req,
-               USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
-               val, index,
-               NULL, 0,
-               USB_CTRL_GET_TIMEOUT);
-}
-
-static inline int
-pl_clear_QuickLink_features (struct usbnet *dev, int val)
-{
-       return pl_vendor_req (dev, 1, (u8) val, 0);
-}
-
-static inline int
-pl_set_QuickLink_features (struct usbnet *dev, int val)
-{
-       return pl_vendor_req (dev, 3, (u8) val, 0);
-}
-
-/*-------------------------------------------------------------------------*/
-
-static int pl_reset (struct usbnet *dev)
-{
-       /* some units seem to need this reset, others reject it utterly.
-        * FIXME be more like "naplink" or windows drivers.
-        */
-       (void) pl_set_QuickLink_features (dev,
-               PL_S_EN|PL_RESET_OUT|PL_RESET_IN|PL_PEER_E);
-       return 0;
-}
-
-static const struct driver_info        prolific_info = {
-       .description =  "Prolific PL-2301/PL-2302",
-       .flags =        FLAG_NO_SETINT,
-               /* some PL-2302 versions seem to fail usb_set_interface() */
-       .reset =        pl_reset,
-};
-
-#endif /* CONFIG_USB_PL2301 */
-
-\f
-#ifdef CONFIG_USB_ZAURUS
-#define        HAVE_HARDWARE
-
-#include <linux/crc32.h>
-
-/*-------------------------------------------------------------------------
- *
- * Zaurus is also a SA-1110 based PDA, but one using a different driver
- * (and framing) for its USB slave/gadget controller than the case above.
- *
- * For the current version of that driver, the main way that framing is
- * nonstandard (also from perspective of the CDC ethernet model!) is a
- * crc32, added to help detect when some sa1100 usb-to-memory DMA errata
- * haven't been fully worked around.  Also, all Zaurii use the same
- * default Ethernet address.
- *
- * PXA based models use the same framing, and also can't implement
- * set_interface properly.
- *
- * All known Zaurii lie about their standards conformance.  Most lie by
- * saying they support CDC Ethernet.  Some lie and say they support CDC
- * MDLM (as if for access to cell phone modems).  Someone, please beat 
- * on Sharp (and other such vendors) for a while with a cluestick.
- *
- *-------------------------------------------------------------------------*/
-
-static struct sk_buff *
-zaurus_tx_fixup (struct usbnet *dev, struct sk_buff *skb, unsigned flags)
-{
-       int                     padlen;
-       struct sk_buff          *skb2;
-
-       padlen = 2;
-       if (!skb_cloned (skb)) {
-               int     tailroom = skb_tailroom (skb);
-               if ((padlen + 4) <= tailroom)
-                       goto done;
-       }
-       skb2 = skb_copy_expand (skb, 0, 4 + padlen, flags);
-       dev_kfree_skb_any (skb);
-       skb = skb2;
-       if (skb) {
-               u32             fcs;
-done:
-               fcs = crc32_le (~0, skb->data, skb->len);
-               fcs = ~fcs;
-
-               *skb_put (skb, 1) = fcs       & 0xff;
-               *skb_put (skb, 1) = (fcs>> 8) & 0xff;
-               *skb_put (skb, 1) = (fcs>>16) & 0xff;
-               *skb_put (skb, 1) = (fcs>>24) & 0xff;
-       }
-       return skb;
-}
-
-static int zaurus_bind (struct usbnet *dev, struct usb_interface *intf)
-{
-       /* Belcarra's funky framing has other options; mostly
-        * TRAILERS (!) with 4 bytes CRC, and maybe 2 pad bytes.
-        */
-       dev->net->hard_header_len += 6;
-       return generic_cdc_bind(dev, intf);
-}
-
-static const struct driver_info        zaurus_sl5x00_info = {
-       .description =  "Sharp Zaurus SL-5x00",
-       .flags =        FLAG_FRAMING_Z,
-       .check_connect = always_connected,
-       .bind =         zaurus_bind,
-       .unbind =       cdc_unbind,
-       .tx_fixup =     zaurus_tx_fixup,
-};
-#define        ZAURUS_STRONGARM_INFO   ((unsigned long)&zaurus_sl5x00_info)
-
-static const struct driver_info        zaurus_pxa_info = {
-       .description =  "Sharp Zaurus, PXA-2xx based",
-       .flags =        FLAG_FRAMING_Z,
-       .check_connect = always_connected,
-       .bind =         zaurus_bind,
-       .unbind =       cdc_unbind,
-       .tx_fixup =     zaurus_tx_fixup,
-};
-#define        ZAURUS_PXA_INFO         ((unsigned long)&zaurus_pxa_info)
-
-static const struct driver_info        olympus_mxl_info = {
-       .description =  "Olympus R1000",
-       .flags =        FLAG_FRAMING_Z,
-       .check_connect = always_connected,
-       .bind =         zaurus_bind,
-       .unbind =       cdc_unbind,
-       .tx_fixup =     zaurus_tx_fixup,
-};
-#define        OLYMPUS_MXL_INFO        ((unsigned long)&olympus_mxl_info)
-
-
-/* Some more recent products using Lineo/Belcarra code will wrongly claim
- * CDC MDLM conformance.  They aren't conformant:  data endpoints live
- * in the control interface, there's no data interface, and it's not used
- * to talk to a cell phone radio.  But at least we can detect these two
- * pseudo-classes, rather than growing this product list with entries for
- * each new nonconformant product (sigh).
- */
-static const u8 safe_guid[16] = {
-       0x5d, 0x34, 0xcf, 0x66, 0x11, 0x18, 0x11, 0xd6,
-       0xa2, 0x1a, 0x00, 0x01, 0x02, 0xca, 0x9a, 0x7f,
-};
-static const u8 blan_guid[16] = {
-       0x74, 0xf0, 0x3d, 0xbd, 0x1e, 0xc1, 0x44, 0x70,
-       0xa3, 0x67, 0x71, 0x34, 0xc9, 0xf5, 0x54, 0x37,
-};
-
-static int blan_mdlm_bind (struct usbnet *dev, struct usb_interface *intf)
-{
-       u8                              *buf = intf->cur_altsetting->extra;
-       int                             len = intf->cur_altsetting->extralen;
-       struct usb_cdc_mdlm_desc        *desc = NULL;
-       struct usb_cdc_mdlm_detail_desc *detail = NULL;
-
-       while (len > 3) {
-               if (buf [1] != USB_DT_CS_INTERFACE)
-                       goto next_desc;
-
-               /* use bDescriptorSubType, and just verify that we get a
-                * "BLAN" (or "SAFE") descriptor.
-                */
-               switch (buf [2]) {
-               case USB_CDC_MDLM_TYPE:
-                       if (desc) {
-                               dev_dbg (&intf->dev, "extra MDLM\n");
-                               goto bad_desc;
-                       }
-                       desc = (void *) buf;
-                       if (desc->bLength != sizeof *desc) {
-                               dev_dbg (&intf->dev, "MDLM len %u\n",
-                                       desc->bLength);
-                               goto bad_desc;
-                       }
-                       /* expect bcdVersion 1.0, ignore */
-                       if (memcmp(&desc->bGUID, blan_guid, 16)
-                                   && memcmp(&desc->bGUID, safe_guid, 16) ) {
-                               /* hey, this one might _really_ be MDLM! */
-                               dev_dbg (&intf->dev, "MDLM guid\n");
-                               goto bad_desc;
-                       }
-                       break;
-               case USB_CDC_MDLM_DETAIL_TYPE:
-                       if (detail) {
-                               dev_dbg (&intf->dev, "extra MDLM detail\n");
-                               goto bad_desc;
-                       }
-                       detail = (void *) buf;
-                       switch (detail->bGuidDescriptorType) {
-                       case 0:                 /* "SAFE" */
-                               if (detail->bLength != (sizeof *detail + 2))
-                                       goto bad_detail;
-                               break;
-                       case 1:                 /* "BLAN" */
-                               if (detail->bLength != (sizeof *detail + 3))
-                                       goto bad_detail;
-                               break;
-                       default:
-                               goto bad_detail;
-                       }
-
-                       /* assuming we either noticed BLAN already, or will
-                        * find it soon, there are some data bytes here:
-                        *  - bmNetworkCapabilities (unused)
-                        *  - bmDataCapabilities (bits, see below)
-                        *  - bPad (ignored, for PADAFTER -- BLAN-only)
-                        * bits are:
-                        *  - 0x01 -- Zaurus framing (add CRC)
-                        *  - 0x02 -- PADBEFORE (CRC includes some padding)
-                        *  - 0x04 -- PADAFTER (some padding after CRC)
-                        *  - 0x08 -- "fermat" packet mangling (for hw bugs)
-                        * the PADBEFORE appears not to matter; we interop
-                        * with devices that use it and those that don't.
-                        */
-                       if ((detail->bDetailData[1] & ~02) != 0x01) {
-                               /* bmDataCapabilites == 0 would be fine too,
-                                * but framing is minidriver-coupled for now.
-                                */
-bad_detail:
-                               dev_dbg (&intf->dev,
-                                               "bad MDLM detail, %d %d %d\n",
-                                               detail->bLength,
-                                               detail->bDetailData[0],
-                                               detail->bDetailData[2]);
-                               goto bad_desc;
-                       }
-                       break;
-               }
-next_desc:
-               len -= buf [0]; /* bLength */
-               buf += buf [0];
-       }
-
-       if (!desc || !detail) {
-               dev_dbg (&intf->dev, "missing cdc mdlm %s%sdescriptor\n",
-                       desc ? "" : "func ",
-                       detail ? "" : "detail ");
-               goto bad_desc;
-       }
-
-       /* There's probably a CDC Ethernet descriptor there, but we can't
-        * rely on the Ethernet address it provides since not all vendors
-        * bother to make it unique.  Likewise there's no point in tracking
-        * of the CDC event notifications.
-        */
-       return usbnet_get_endpoints (dev, intf);
-
-bad_desc:
-       dev_info (&dev->udev->dev, "unsupported MDLM descriptors\n");
-       return -ENODEV;
-}
-
-static const struct driver_info        bogus_mdlm_info = {
-       .description =  "pseudo-MDLM (BLAN) device",
-       .flags =        FLAG_FRAMING_Z,
-       .check_connect = always_connected,
-       .tx_fixup =     zaurus_tx_fixup,
-       .bind =         blan_mdlm_bind,
-};
-
-#else
-
-/* blacklist all those devices */
-#define        ZAURUS_STRONGARM_INFO   0
-#define        ZAURUS_PXA_INFO         0
-#define        OLYMPUS_MXL_INFO        0
-
-#endif
-
-\f
 /*-------------------------------------------------------------------------
  *
  * Network Device Driver (peer link to "Host Device", from USB host)
@@ -1058,7 +285,7 @@ EXPORT_SYMBOL_GPL(usbnet_defer_kevent);
 
 static void rx_complete (struct urb *urb, struct pt_regs *regs);
 
-static void rx_submit (struct usbnet *dev, struct urb *urb, unsigned flags)
+static void rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
 {
        struct sk_buff          *skb;
        struct skb_data         *entry;
@@ -1955,7 +1182,6 @@ int usbnet_suspend (struct usb_interface *intf, pm_message_t message)
        netif_device_detach (dev->net);
        (void) unlink_urbs (dev, &dev->rxq);
        (void) unlink_urbs (dev, &dev->txq);
-       intf->dev.power.power_state = PMSG_SUSPEND;
        return 0;
 }
 EXPORT_SYMBOL_GPL(usbnet_suspend);
@@ -1964,7 +1190,6 @@ int usbnet_resume (struct usb_interface *intf)
 {
        struct usbnet           *dev = usb_get_intfdata(intf);
 
-       intf->dev.power.power_state = PMSG_ON;
        netif_device_attach (dev->net);
        tasklet_schedule (&dev->bh);
        return 0;
@@ -1972,186 +1197,24 @@ int usbnet_resume (struct usb_interface *intf)
 EXPORT_SYMBOL_GPL(usbnet_resume);
 
 
-/*-------------------------------------------------------------------------*/
-
-#ifndef        HAVE_HARDWARE
-#error You need to configure some hardware for this driver
-#endif
-
-/*
- * chip vendor names won't normally be on the cables, and
- * may not be on the device.
- */
-
-static const struct usb_device_id      products [] = {
-
-#ifdef CONFIG_USB_PL2301
-{
-       USB_DEVICE (0x067b, 0x0000),    // PL-2301
-       .driver_info =  (unsigned long) &prolific_info,
-}, {
-       USB_DEVICE (0x067b, 0x0001),    // PL-2302
-       .driver_info =  (unsigned long) &prolific_info,
-},
-#endif
-
-#ifdef CONFIG_USB_RNDIS
-{
-       /* RNDIS is MSFT's un-official variant of CDC ACM */
-       USB_INTERFACE_INFO (USB_CLASS_COMM, 2 /* ACM */, 0x0ff),
-       .driver_info = (unsigned long) &rndis_info,
-},
-#endif
-
-#if    defined(CONFIG_USB_ZAURUS) || defined(CONFIG_USB_CDCETHER)
-/*
- * SA-1100 based Sharp Zaurus ("collie"), or compatible.
- * Same idea as above, but different framing.
- *
- * PXA-2xx based models are also lying-about-cdc.
- * Some models don't even tell the same lies ...
- *
- * NOTE:  OpenZaurus versions with 2.6 kernels won't use these entries,
- * unlike the older ones with 2.4 "embedix" kernels.
- *
- * NOTE:  These entries do double-duty, serving as blacklist entries
- * whenever Zaurus support isn't enabled, but CDC Ethernet is.
- */
-#define        ZAURUS_MASTER_INTERFACE \
-       .bInterfaceClass        = USB_CLASS_COMM, \
-       .bInterfaceSubClass     = USB_CDC_SUBCLASS_ETHERNET, \
-       .bInterfaceProtocol     = USB_CDC_PROTO_NONE
-{
-       .match_flags    =   USB_DEVICE_ID_MATCH_INT_INFO
-                         | USB_DEVICE_ID_MATCH_DEVICE, 
-       .idVendor               = 0x04DD,
-       .idProduct              = 0x8004,
-       ZAURUS_MASTER_INTERFACE,
-       .driver_info = ZAURUS_STRONGARM_INFO,
-}, {
-       .match_flags    =   USB_DEVICE_ID_MATCH_INT_INFO
-                         | USB_DEVICE_ID_MATCH_DEVICE, 
-       .idVendor               = 0x04DD,
-       .idProduct              = 0x8005,       /* A-300 */
-       ZAURUS_MASTER_INTERFACE,
-       .driver_info = ZAURUS_PXA_INFO,
-}, {
-       .match_flags    =   USB_DEVICE_ID_MATCH_INT_INFO
-                         | USB_DEVICE_ID_MATCH_DEVICE, 
-       .idVendor               = 0x04DD,
-       .idProduct              = 0x8006,       /* B-500/SL-5600 */
-       ZAURUS_MASTER_INTERFACE,
-       .driver_info = ZAURUS_PXA_INFO,
-}, {
-       .match_flags    =   USB_DEVICE_ID_MATCH_INT_INFO
-                 | USB_DEVICE_ID_MATCH_DEVICE,
-       .idVendor               = 0x04DD,
-       .idProduct              = 0x8007,       /* C-700 */
-       ZAURUS_MASTER_INTERFACE,
-       .driver_info = ZAURUS_PXA_INFO,
-}, {
-       .match_flags    =   USB_DEVICE_ID_MATCH_INT_INFO
-                | USB_DEVICE_ID_MATCH_DEVICE,
-       .idVendor               = 0x04DD,
-       .idProduct              = 0x9031,       /* C-750 C-760 */
-       ZAURUS_MASTER_INTERFACE,
-       .driver_info = ZAURUS_PXA_INFO,
-}, {
-       .match_flags    =   USB_DEVICE_ID_MATCH_INT_INFO
-                | USB_DEVICE_ID_MATCH_DEVICE,
-       .idVendor               = 0x04DD,
-       .idProduct              = 0x9032,       /* SL-6000 */
-       ZAURUS_MASTER_INTERFACE,
-       .driver_info = ZAURUS_PXA_INFO,
-}, {
-       .match_flags    =   USB_DEVICE_ID_MATCH_INT_INFO
-                | USB_DEVICE_ID_MATCH_DEVICE,
-       .idVendor               = 0x04DD,
-       /* reported with some C860 units */
-       .idProduct              = 0x9050,       /* C-860 */
-       ZAURUS_MASTER_INTERFACE,
-       .driver_info = ZAURUS_PXA_INFO,
-},
-
-#ifdef CONFIG_USB_ZAURUS
-       /* At least some (reports vary) PXA units have very different lies
-        * about their standards support:  they claim to be cell phones with
-        * direct access to their radios.  (They don't conform to CDC MDLM.)
-        */
-{
-       USB_INTERFACE_INFO (USB_CLASS_COMM, USB_CDC_SUBCLASS_MDLM,
-                       USB_CDC_PROTO_NONE),
-       .driver_info = (unsigned long) &bogus_mdlm_info,
-},
-#endif
-
-/* Olympus has some models with a Zaurus-compatible option.
- * R-1000 uses a FreeScale i.MXL cpu (ARMv4T)
- */
-{
-       .match_flags    =   USB_DEVICE_ID_MATCH_INT_INFO
-                | USB_DEVICE_ID_MATCH_DEVICE,
-       .idVendor               = 0x07B4,
-       .idProduct              = 0x0F02,       /* R-1000 */
-       ZAURUS_MASTER_INTERFACE,
-       .driver_info = OLYMPUS_MXL_INFO,
-},
-#endif
-
-#ifdef CONFIG_USB_CDCETHER
-{
-       /* CDC Ether uses two interfaces, not necessarily consecutive.
-        * We match the main interface, ignoring the optional device
-        * class so we could handle devices that aren't exclusively
-        * CDC ether.
-        *
-        * NOTE:  this match must come AFTER entries working around
-        * bugs/quirks in a given product (like Zaurus, above).
-        */
-       USB_INTERFACE_INFO (USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET,
-                       USB_CDC_PROTO_NONE),
-       .driver_info = (unsigned long) &cdc_info,
-},
-#endif
-
-       { },            // END
-};
-MODULE_DEVICE_TABLE (usb, products);
-
-static struct usb_driver usbnet_driver = {
-       .owner =        THIS_MODULE,
-       .name =         driver_name,
-       .id_table =     products,
-       .probe =        usbnet_probe,
-       .disconnect =   usbnet_disconnect,
-       .suspend =      usbnet_suspend,
-       .resume =       usbnet_resume,
-};
-
 /*-------------------------------------------------------------------------*/
 
 static int __init usbnet_init(void)
 {
-       // compiler should optimize these out
+       /* compiler should optimize this out */
        BUG_ON (sizeof (((struct sk_buff *)0)->cb)
                        < sizeof (struct skb_data));
-#ifdef CONFIG_USB_CDCETHER
-       BUG_ON ((sizeof (((struct usbnet *)0)->data)
-                       < sizeof (struct cdc_state)));
-#endif
 
        random_ether_addr(node_id);
-
-       return usb_register(&usbnet_driver);
+       return 0;
 }
 module_init(usbnet_init);
 
 static void __exit usbnet_exit(void)
 {
-       usb_deregister(&usbnet_driver);
 }
 module_exit(usbnet_exit);
 
 MODULE_AUTHOR("David Brownell");
-MODULE_DESCRIPTION("USB Host-to-Host Link Drivers (numerous vendors)");
+MODULE_DESCRIPTION("USB network driver framework");
 MODULE_LICENSE("GPL");