[PATCH] USB: usbnet (2/9) module for simple network links

This patch creates the first of several separate "minidriver" modules
for "usbnet".  This one handles only the very simplest hardware, which
can be handled almost entirely by the "usbnet" core.

    - Move device-specific bits into new "cdc_subset.c" driver,
      shrinking "usbnet" by a bunch;

    - Export the functions needed to support this minidriver
      (with EXPORT_SYMBOL_GPL);

    - Update Kconfig and kbuild accordingly.

This one handles about a dozen different device types, with the most
notable ones being Gumstix and most Linux-based PDAs (except Zaurus
running that ancient code from Sharp).

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index 3f2cad6..57b41fb 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -322,48 +322,6 @@
 }
 
 
-#ifdef	CONFIG_USB_ALI_M5632
-#define	HAVE_HARDWARE
-
-/*-------------------------------------------------------------------------
- *
- * ALi M5632 driver ... does high speed
- *
- *-------------------------------------------------------------------------*/
-
-static const struct driver_info	ali_m5632_info = {
-	.description =	"ALi M5632",
-};
-
-
-#endif
-
-
-#ifdef	CONFIG_USB_AN2720
-#define	HAVE_HARDWARE
-
-/*-------------------------------------------------------------------------
- *
- * AnchorChips 2720 driver ... http://www.cypress.com
- *
- * This doesn't seem to have a way to detect whether the peer is
- * connected, or need any reset handshaking.  It's got pretty big
- * internal buffers (handles most of a frame's worth of data).
- * Chip data sheets don't describe any vendor control messages.
- *
- *-------------------------------------------------------------------------*/
-
-static const struct driver_info	an2720_info = {
-	.description =	"AnchorChips/Cypress 2720",
-	// no reset available!
-	// no check_connect available!
-
-	.in = 2, .out = 2,		// direction distinguishes these
-};
-
-#endif	/* CONFIG_USB_AN2720 */
-
-
 #ifdef CONFIG_USB_AX8817X
 /* ASIX AX8817X based USB 2.0 Ethernet Devices */
 
@@ -1142,25 +1100,6 @@
 
 
 
-#ifdef	CONFIG_USB_BELKIN
-#define	HAVE_HARDWARE
-
-/*-------------------------------------------------------------------------
- *
- * Belkin F5U104 ... two NetChip 2280 devices + Atmel microcontroller
- *
- * ... also two eTEK designs, including one sold as "Advance USBNET"
- *
- *-------------------------------------------------------------------------*/
-
-static const struct driver_info	belkin_info = {
-	.description =	"Belkin, eTEK, or compatible",
-};
-
-#endif	/* CONFIG_USB_BELKIN */
-
-
-
 /*-------------------------------------------------------------------------
  *
  * Communications Device Class declarations.
@@ -1538,32 +1477,6 @@
 
 
 
-#ifdef	CONFIG_USB_EPSON2888
-#define	HAVE_HARDWARE
-
-/*-------------------------------------------------------------------------
- *
- * EPSON USB clients
- *
- * This is the same idea as Linux PDAs (below) except the firmware in the
- * device might not be Tux-powered.  Epson provides reference firmware that
- * implements this interface.  Product developers can reuse or modify that
- * code, such as by using their own product and vendor codes.
- *
- * Support was from Juro Bystricky <bystricky.juro@erd.epson.com>
- *
- *-------------------------------------------------------------------------*/
-
-static const struct driver_info	epson2888_info = {
-	.description =	"Epson USB Device",
-	.check_connect = always_connected,
-
-	.in = 4, .out = 3,
-};
-
-#endif	/* CONFIG_USB_EPSON2888 */
-
-
 #ifdef CONFIG_USB_GENESYS
 #define	HAVE_HARDWARE
 
@@ -2495,52 +2408,6 @@
 #endif /* CONFIG_USB_PL2301 */
 
 
-#ifdef CONFIG_USB_KC2190
-#define HAVE_HARDWARE
-static const struct driver_info kc2190_info = {
-	.description =  "KC Technology KC-190",
-};
-#endif /* CONFIG_USB_KC2190 */
-
-
-#ifdef	CONFIG_USB_ARMLINUX
-#define	HAVE_HARDWARE
-
-/*-------------------------------------------------------------------------
- *
- * Intel's SA-1100 chip integrates basic USB support, and is used
- * in PDAs like some iPaqs, the Yopy, some Zaurus models, and more.
- * When they run Linux, arch/arm/mach-sa1100/usb-eth.c may be used to
- * network using minimal USB framing data.
- *
- * This describes the driver currently in standard ARM Linux kernels.
- * The Zaurus uses a different driver (see later).
- *
- * PXA25x and PXA210 use XScale cores (ARM v5TE) with better USB support
- * and different USB endpoint numbering than the SA1100 devices.  The
- * mach-pxa/usb-eth.c driver re-uses the device ids from mach-sa1100
- * so we rely on the endpoint descriptors.
- *
- *-------------------------------------------------------------------------*/
-
-static const struct driver_info	linuxdev_info = {
-	.description =	"Linux Device",
-	.check_connect = always_connected,
-};
-
-static const struct driver_info	yopy_info = {
-	.description =	"Yopy",
-	.check_connect = always_connected,
-};
-
-static const struct driver_info	blob_info = {
-	.description =	"Boot Loader OBject",
-	.check_connect = always_connected,
-};
-
-#endif	/* CONFIG_USB_ARMLINUX */
-
-
 #ifdef CONFIG_USB_ZAURUS
 #define	HAVE_HARDWARE
 
@@ -3575,7 +3442,7 @@
  
 // precondition: never called in_interrupt
 
-static void usbnet_disconnect (struct usb_interface *intf)
+void usbnet_disconnect (struct usb_interface *intf)
 {
 	struct usbnet		*dev;
 	struct usb_device	*xdev;
@@ -3589,7 +3456,8 @@
 	xdev = interface_to_usbdev (intf);
 
 	if (netif_msg_probe (dev))
-		devinfo (dev, "unregister usbnet usb-%s-%s, %s",
+		devinfo (dev, "unregister '%s' usb-%s-%s, %s",
+			intf->dev.driver->name,
 			xdev->bus->bus_name, xdev->devpath,
 			dev->driver_info->description);
 	
@@ -3605,6 +3473,7 @@
 	free_netdev(net);
 	usb_put_dev (xdev);
 }
+EXPORT_SYMBOL_GPL(usbnet_disconnect);
 
 
 /*-------------------------------------------------------------------------*/
@@ -3613,7 +3482,7 @@
 
 // precondition: never called in_interrupt
 
-static int
+int
 usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
 {
 	struct usbnet			*dev;
@@ -3719,8 +3588,9 @@
 	if (status)
 		goto out3;
 	if (netif_msg_probe (dev))
-		devinfo (dev, "register usbnet at usb-%s-%s, %s, "
+		devinfo (dev, "register '%s' at usb-%s-%s, %s, "
 				"%02x:%02x:%02x:%02x:%02x:%02x",
+			udev->dev.driver->name,
 			xdev->bus->bus_name, xdev->devpath,
 			dev->driver_info->description,
 			net->dev_addr [0], net->dev_addr [1],
@@ -3744,12 +3614,15 @@
 	usb_put_dev(xdev);
 	return status;
 }
+EXPORT_SYMBOL_GPL(usbnet_probe);
 
 /*-------------------------------------------------------------------------*/
 
-#ifdef	CONFIG_PM
+/* FIXME these suspend/resume methods assume non-CDC style
+ * devices, with only one interface.
+ */
 
-static int usbnet_suspend (struct usb_interface *intf, pm_message_t message)
+int usbnet_suspend (struct usb_interface *intf, pm_message_t message)
 {
 	struct usbnet		*dev = usb_get_intfdata(intf);
 	
@@ -3762,8 +3635,9 @@
 	intf->dev.power.power_state = PMSG_SUSPEND;
 	return 0;
 }
+EXPORT_SYMBOL_GPL(usbnet_suspend);
 
-static int usbnet_resume (struct usb_interface *intf)
+int usbnet_resume (struct usb_interface *intf)
 {
 	struct usbnet		*dev = usb_get_intfdata(intf);
 
@@ -3772,13 +3646,8 @@
 	tasklet_schedule (&dev->bh);
 	return 0;
 }
+EXPORT_SYMBOL_GPL(usbnet_resume);
 
-#else	/* !CONFIG_PM */
-
-#define	usbnet_suspend	NULL
-#define	usbnet_resume	NULL
-
-#endif	/* CONFIG_PM */
 
 /*-------------------------------------------------------------------------*/
 
@@ -3793,36 +3662,6 @@
 
 static const struct usb_device_id	products [] = {
 
-#ifdef	CONFIG_USB_ALI_M5632
-{
-	USB_DEVICE (0x0402, 0x5632),	// ALi defaults
-	.driver_info =	(unsigned long) &ali_m5632_info,
-},
-#endif
-
-#ifdef	CONFIG_USB_AN2720
-{
-	USB_DEVICE (0x0547, 0x2720),	// AnchorChips defaults
-	.driver_info =	(unsigned long) &an2720_info,
-}, {
-	USB_DEVICE (0x0547, 0x2727),	// Xircom PGUNET
-	.driver_info =	(unsigned long) &an2720_info,
-},
-#endif
-
-#ifdef	CONFIG_USB_BELKIN
-{
-	USB_DEVICE (0x050d, 0x0004),	// Belkin
-	.driver_info =	(unsigned long) &belkin_info,
-}, {
-	USB_DEVICE (0x056c, 0x8100),	// eTEK
-	.driver_info =	(unsigned long) &belkin_info,
-}, {
-	USB_DEVICE (0x0525, 0x9901),	// Advance USBNET (eTEK)
-	.driver_info =	(unsigned long) &belkin_info,
-},
-#endif
-
 #ifdef CONFIG_USB_AX8817X
 {
 	// Linksys USB200M
@@ -3879,13 +3718,6 @@
 },
 #endif
 
-#ifdef	CONFIG_USB_EPSON2888
-{
-	USB_DEVICE (0x0525, 0x2888),	// EPSON USB client
-	.driver_info	= (unsigned long) &epson2888_info,
-},
-#endif
-
 #ifdef	CONFIG_USB_GENESYS
 {
 	USB_DEVICE (0x05e3, 0x0502),	// GL620USB-A
@@ -3916,13 +3748,6 @@
 },
 #endif
 
-#ifdef CONFIG_USB_KC2190
-{
-	USB_DEVICE (0x050f, 0x0190),	// KC-190
-	.driver_info =	(unsigned long) &kc2190_info,
-},
-#endif
-
 #ifdef	CONFIG_USB_RNDIS
 {
 	/* RNDIS is MSFT's un-official variant of CDC ACM */
@@ -3931,41 +3756,6 @@
 },
 #endif
 
-#ifdef	CONFIG_USB_ARMLINUX
-/*
- * SA-1100 using standard ARM Linux kernels, or compatible.
- * Often used when talking to Linux PDAs (iPaq, Yopy, etc).
- * The sa-1100 "usb-eth" driver handles the basic framing.
- *
- * PXA25x or PXA210 ...  these use a "usb-eth" driver much like
- * the sa1100 one, but hardware uses different endpoint numbers.
- *
- * Or the Linux "Ethernet" gadget on hardware that can't talk
- * CDC Ethernet (e.g., no altsettings), in either of two modes:
- *  - acting just like the old "usb-eth" firmware, though
- *    the implementation is different 
- *  - supporting RNDIS as the first/default configuration for
- *    MS-Windows interop; Linux needs to use the other config
- */
-{
-	// 1183 = 0x049F, both used as hex values?
-	// Compaq "Itsy" vendor/product id
-	USB_DEVICE (0x049F, 0x505A),	// usb-eth, or compatible
-	.driver_info =	(unsigned long) &linuxdev_info,
-}, {
-	USB_DEVICE (0x0E7E, 0x1001),	// G.Mate "Yopy"
-	.driver_info =	(unsigned long) &yopy_info,
-}, {
-	USB_DEVICE (0x8086, 0x07d3),	// "blob" bootloader
-	.driver_info =	(unsigned long) &blob_info,
-}, {
-	// Linux Ethernet/RNDIS gadget on pxa210/25x/26x
-	// e.g. Gumstix, current OpenZaurus, ...
-	USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203),
-	.driver_info =	(unsigned long) &linuxdev_info,
-}, 
-#endif
-
 #if	defined(CONFIG_USB_ZAURUS) || defined(CONFIG_USB_CDCETHER)
 /*
  * SA-1100 based Sharp Zaurus ("collie"), or compatible.