]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
usb-storage: make freecom a separate module
authorAlan Stern <stern@rowland.harvard.edu>
Thu, 12 Feb 2009 19:48:11 +0000 (14:48 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 24 Mar 2009 23:20:34 +0000 (16:20 -0700)
This patch (as1212) converts usb-storage's freecom subdriver into a
separate module.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/storage/Kconfig
drivers/usb/storage/Makefile
drivers/usb/storage/freecom.c
drivers/usb/storage/unusual_devs.h
drivers/usb/storage/unusual_freecom.h [moved from drivers/usb/storage/freecom.h with 60% similarity]
drivers/usb/storage/usb.c
drivers/usb/storage/usual-tables.c

index 44c6b1940f775828c5123d1cf03f68e0ca525253..14508b8a55fb665c19ea243af5b07beef5bcaf31 100644 (file)
@@ -39,12 +39,14 @@ config USB_STORAGE_DATAFAB
          Datafab has a web page at <http://www.datafabusa.com/>.
 
 config USB_STORAGE_FREECOM
-       bool "Freecom USB/ATAPI Bridge support"
+       tristate "Freecom USB/ATAPI Bridge support"
        depends on USB_STORAGE
        help
          Support for the Freecom USB to IDE/ATAPI adaptor.
          Freecom has a web page at <http://www.freecom.de/>.
 
+         If this driver is compiled as a module, it will be named ums-freecom.
+
 config USB_STORAGE_ISD200
        tristate "ISD-200 USB/ATA Bridge support"
        depends on USB_STORAGE
index 2387368cb7aea93331fd47e724b7a58f89f289d0..93e91ec3a2d24b76aa1a6398857f3455c3507f83 100644 (file)
@@ -10,7 +10,6 @@ EXTRA_CFLAGS  := -Idrivers/scsi
 obj-$(CONFIG_USB_STORAGE)      += usb-storage.o
 
 usb-storage-obj-$(CONFIG_USB_STORAGE_DEBUG)    += debug.o
-usb-storage-obj-$(CONFIG_USB_STORAGE_FREECOM)  += freecom.o
 usb-storage-obj-$(CONFIG_USB_STORAGE_DATAFAB)  += datafab.o
 usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o
 usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA)   += alauda.o
@@ -27,12 +26,14 @@ else
 endif
 
 obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += ums-cypress.o
+obj-$(CONFIG_USB_STORAGE_FREECOM)      += ums-freecom.o
 obj-$(CONFIG_USB_STORAGE_ISD200)       += ums-isd200.o
 obj-$(CONFIG_USB_STORAGE_SDDR09)       += ums-sddr09.o
 obj-$(CONFIG_USB_STORAGE_SDDR55)       += ums-sddr55.o
 obj-$(CONFIG_USB_STORAGE_USBAT)                += ums-usbat.o
 
 ums-cypress-objs       := cypress_atacb.o
+ums-freecom-objs       := freecom.o
 ums-isd200-objs                := isd200.o
 ums-sddr09-objs                := sddr09.o
 ums-sddr55-objs                := sddr55.o
index 73ac7262239e510ad9af1ec62883b4d588ca0332..393047b3890d2fe7e635888f9af93664f5dd2c8c 100644 (file)
@@ -26,6 +26,7 @@
  * (http://www.freecom.de/)
  */
 
+#include <linux/module.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
 
@@ -33,7 +34,6 @@
 #include "transport.h"
 #include "protocol.h"
 #include "debug.h"
-#include "freecom.h"
 
 #ifdef CONFIG_USB_STORAGE_DEBUG
 static void pdump (void *, int);
@@ -103,6 +103,47 @@ struct freecom_status {
 #define FCM_PACKET_LENGTH              64
 #define FCM_STATUS_PACKET_LENGTH       4
 
+static int init_freecom(struct us_data *us);
+
+
+/*
+ * The table of devices
+ */
+#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
+                   vendorName, productName, useProtocol, useTransport, \
+                   initFunction, flags) \
+{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
+  .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
+
+struct usb_device_id freecom_usb_ids[] = {
+#      include "unusual_freecom.h"
+       { }             /* Terminating entry */
+};
+MODULE_DEVICE_TABLE(usb, freecom_usb_ids);
+
+#undef UNUSUAL_DEV
+
+/*
+ * The flags table
+ */
+#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
+                   vendor_name, product_name, use_protocol, use_transport, \
+                   init_function, Flags) \
+{ \
+       .vendorName = vendor_name,      \
+       .productName = product_name,    \
+       .useProtocol = use_protocol,    \
+       .useTransport = use_transport,  \
+       .initFunction = init_function,  \
+}
+
+static struct us_unusual_dev freecom_unusual_dev_list[] = {
+#      include "unusual_freecom.h"
+       { }             /* Terminating entry */
+};
+
+#undef UNUSUAL_DEV
+
 static int
 freecom_readdata (struct scsi_cmnd *srb, struct us_data *us,
                unsigned int ipipe, unsigned int opipe, int count)
@@ -173,7 +214,7 @@ freecom_writedata (struct scsi_cmnd *srb, struct us_data *us,
  * Transport for the Freecom USB/IDE adaptor.
  *
  */
-int freecom_transport(struct scsi_cmnd *srb, struct us_data *us)
+static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us)
 {
        struct freecom_cb_wrap *fcb;
        struct freecom_status  *fst;
@@ -377,8 +418,7 @@ int freecom_transport(struct scsi_cmnd *srb, struct us_data *us)
        return USB_STOR_TRANSPORT_GOOD;
 }
 
-int
-freecom_init (struct us_data *us)
+static int init_freecom(struct us_data *us)
 {
        int result;
        char *buffer = us->iobuf;
@@ -417,7 +457,7 @@ freecom_init (struct us_data *us)
        return USB_STOR_TRANSPORT_GOOD;
 }
 
-int usb_stor_freecom_reset(struct us_data *us)
+static int usb_stor_freecom_reset(struct us_data *us)
 {
        printk (KERN_CRIT "freecom reset called\n");
 
@@ -479,3 +519,48 @@ static void pdump (void *ibuffer, int length)
 }
 #endif
 
+static int freecom_probe(struct usb_interface *intf,
+                        const struct usb_device_id *id)
+{
+       struct us_data *us;
+       int result;
+
+       result = usb_stor_probe1(&us, intf, id,
+                       (id - freecom_usb_ids) + freecom_unusual_dev_list);
+       if (result)
+               return result;
+
+       us->transport_name = "Freecom";
+       us->transport = freecom_transport;
+       us->transport_reset = usb_stor_freecom_reset;
+       us->max_lun = 0;
+
+       result = usb_stor_probe2(us);
+       return result;
+}
+
+static struct usb_driver freecom_driver = {
+       .name =         "ums-freecom",
+       .probe =        freecom_probe,
+       .disconnect =   usb_stor_disconnect,
+       .suspend =      usb_stor_suspend,
+       .resume =       usb_stor_resume,
+       .reset_resume = usb_stor_reset_resume,
+       .pre_reset =    usb_stor_pre_reset,
+       .post_reset =   usb_stor_post_reset,
+       .id_table =     freecom_usb_ids,
+       .soft_unbind =  1,
+};
+
+static int __init freecom_init(void)
+{
+       return usb_register(&freecom_driver);
+}
+
+static void __exit freecom_exit(void)
+{
+       usb_deregister(&freecom_driver);
+}
+
+module_init(freecom_init);
+module_exit(freecom_exit);
index 6462c4c54dc0e94e63285cd8e32f3782f5c495bf..eef2075cf2eb239a4007461082f67c557a081c5d 100644 (file)
@@ -958,13 +958,6 @@ UNUSUAL_DEV(  0x0781, 0x0100, 0x0100, 0x0100,
                US_SC_SCSI, US_PR_CB, NULL,
                US_FL_SINGLE_LUN ),
 
-#ifdef CONFIG_USB_STORAGE_FREECOM
-UNUSUAL_DEV(  0x07ab, 0xfc01, 0x0000, 0x9999,
-               "Freecom",
-               "USB-IDE",
-               US_SC_QIC, US_PR_FREECOM, freecom_init, 0),
-#endif
-
 /* Reported by Eero Volotinen <eero@ping-viini.org> */
 UNUSUAL_DEV(  0x07ab, 0xfccd, 0x0000, 0x9999,
                "Freecom Technologies",
similarity index 60%
rename from drivers/usb/storage/freecom.h
rename to drivers/usb/storage/unusual_freecom.h
index 20d0fe6ba0c89f4c3af6fed1032767522a6cac33..3758679423918d9879906b492243600f3115c637 100644 (file)
@@ -1,13 +1,4 @@
-/* Driver for Freecom USB/IDE adaptor
- *
- * Freecom v0.1:
- *
- * First release
- *
- * Current development and maintenance by:
- *   (c) 2000 David Brown <usb-storage@davidb.org>
- *
- * See freecom.c for more explanation
+/* Unusual Devices File for the Freecom USB/IDE adaptor
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
  * 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#ifndef _FREECOM_USB_H
-#define _FREECOM_USB_H
+#if defined(CONFIG_USB_STORAGE_FREECOM) || \
+               defined(CONFIG_USB_STORAGE_FREECOM_MODULE)
 
-extern int freecom_transport(struct scsi_cmnd *srb, struct us_data *us);
-extern int usb_stor_freecom_reset(struct us_data *us);
-extern int freecom_init (struct us_data *us);
+UNUSUAL_DEV(  0x07ab, 0xfc01, 0x0000, 0x9999,
+               "Freecom",
+               "USB-IDE",
+               US_SC_QIC, US_PR_FREECOM, init_freecom, 0),
 
-#endif
+#endif /* defined(CONFIG_USB_STORAGE_FREECOM) || ... */
index 3ad22a8142cc144e8f2de6d603ae8d21b0d304af..985275d5d4c5637a3f39a56788936d1eab4a399d 100644 (file)
@@ -66,9 +66,6 @@
 #include "debug.h"
 #include "initializers.h"
 
-#ifdef CONFIG_USB_STORAGE_FREECOM
-#include "freecom.h"
-#endif
 #ifdef CONFIG_USB_STORAGE_DATAFAB
 #include "datafab.h"
 #endif
@@ -607,15 +604,6 @@ static void get_transport(struct us_data *us)
                us->transport_reset = usb_stor_Bulk_reset;
                break;
 
-#ifdef CONFIG_USB_STORAGE_FREECOM
-       case US_PR_FREECOM:
-               us->transport_name = "Freecom";
-               us->transport = freecom_transport;
-               us->transport_reset = usb_stor_freecom_reset;
-               us->max_lun = 0;
-               break;
-#endif
-
 #ifdef CONFIG_USB_STORAGE_DATAFAB
        case US_PR_DATAFAB:
                us->transport_name  = "Datafab Bulk-Only";
index 899a8c8da712d4064d6f87795438b7be5cc58ca0..a50f0eefb7393dd666d423fa6f7657b1094c2dcc 100644 (file)
@@ -78,6 +78,7 @@ struct ignore_entry {
 
 static struct ignore_entry ignore_ids[] = {
 #      include "unusual_cypress.h"
+#      include "unusual_freecom.h"
 #      include "unusual_isd200.h"
 #      include "unusual_sddr09.h"
 #      include "unusual_sddr55.h"