usb-storage: make sddr55 a separate module
authorAlan Stern <stern@rowland.harvard.edu>
Thu, 12 Feb 2009 19:47:59 +0000 (14:47 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 24 Mar 2009 23:20:34 +0000 (16:20 -0700)
This patch (as1209) converts usb-storage's sddr55 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/sddr55.c
drivers/usb/storage/sddr55.h [deleted file]
drivers/usb/storage/unusual_devs.h
drivers/usb/storage/unusual_sddr55.h [new file with mode: 0644]
drivers/usb/storage/usb.c
drivers/usb/storage/usual-tables.c

index fc356a770a76dda81d947c6f22ee2a363819cb87..e6cc245257f8e694e214ba766040530c89492892 100644 (file)
@@ -95,12 +95,14 @@ config USB_STORAGE_SDDR09
          If this driver is compiled as a module, it will be named ums-sddr09.
 
 config USB_STORAGE_SDDR55
-       bool "SanDisk SDDR-55 SmartMedia support"
+       tristate "SanDisk SDDR-55 SmartMedia support"
        depends on USB_STORAGE
        help
          Say Y here to include additional code to support the Sandisk SDDR-55
          SmartMedia reader in the USB Mass Storage driver.
 
+         If this driver is compiled as a module, it will be named ums-sddr55.
+
 config USB_STORAGE_JUMPSHOT
        bool "Lexar Jumpshot Compact Flash Reader"
        depends on USB_STORAGE
index b47f94e59fdc258d5735c02b656ab887edcdec49..5fb7847e41a426b24c3762b1c072f953376d6156 100644 (file)
@@ -11,7 +11,6 @@ obj-$(CONFIG_USB_STORAGE)     += usb-storage.o
 
 usb-storage-obj-$(CONFIG_USB_STORAGE_DEBUG)    += debug.o
 usb-storage-obj-$(CONFIG_USB_STORAGE_USBAT)    += shuttle_usbat.o
-usb-storage-obj-$(CONFIG_USB_STORAGE_SDDR55)   += sddr55.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
@@ -31,6 +30,8 @@ endif
 
 obj-$(CONFIG_USB_STORAGE_ISD200)       += ums-isd200.o
 obj-$(CONFIG_USB_STORAGE_SDDR09)       += ums-sddr09.o
+obj-$(CONFIG_USB_STORAGE_SDDR55)       += ums-sddr55.o
 
 ums-isd200-objs                := isd200.o
 ums-sddr09-objs                := sddr09.o
+ums-sddr55-objs                := sddr55.o
index 5a0106ba256ce5105fdc33ffacdfe1061c939f3a..e97716f8eb025b5743c04288075fb227bfc0a76b 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <linux/jiffies.h>
 #include <linux/errno.h>
+#include <linux/module.h>
 #include <linux/slab.h>
 
 #include <scsi/scsi.h>
 #include "transport.h"
 #include "protocol.h"
 #include "debug.h"
-#include "sddr55.h"
+
+
+/*
+ * 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 sddr55_usb_ids[] = {
+#      include "unusual_sddr55.h"
+       { }             /* Terminating entry */
+};
+MODULE_DEVICE_TABLE(usb, sddr55_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 sddr55_unusual_dev_list[] = {
+#      include "unusual_sddr55.h"
+       { }             /* Terminating entry */
+};
+
+#undef UNUSUAL_DEV
 
 
 #define short_pack(lsb,msb) ( ((u16)(lsb)) | ( ((u16)(msb))<<8 ) )
@@ -513,7 +552,8 @@ static int sddr55_read_deviceID(struct us_data *us,
 }
 
 
-int sddr55_reset(struct us_data *us) {
+static int sddr55_reset(struct us_data *us)
+{
        return 0;
 }
 
@@ -734,7 +774,7 @@ static void sddr55_card_info_destructor(void *extra) {
 /*
  * Transport for the Sandisk SDDR-55
  */
-int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us)
+static int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us)
 {
        int result;
        static unsigned char inquiry_response[8] = {
@@ -931,3 +971,49 @@ int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us)
        return USB_STOR_TRANSPORT_FAILED; // FIXME: sense buffer?
 }
 
+
+static int sddr55_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 - sddr55_usb_ids) + sddr55_unusual_dev_list);
+       if (result)
+               return result;
+
+       us->transport_name = "SDDR55";
+       us->transport = sddr55_transport;
+       us->transport_reset = sddr55_reset;
+       us->max_lun = 0;
+
+       result = usb_stor_probe2(us);
+       return result;
+}
+
+static struct usb_driver sddr55_driver = {
+       .name =         "ums-sddr55",
+       .probe =        sddr55_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 =     sddr55_usb_ids,
+       .soft_unbind =  1,
+};
+
+static int __init sddr55_init(void)
+{
+       return usb_register(&sddr55_driver);
+}
+
+static void __exit sddr55_exit(void)
+{
+       usb_deregister(&sddr55_driver);
+}
+
+module_init(sddr55_init);
+module_exit(sddr55_exit);
diff --git a/drivers/usb/storage/sddr55.h b/drivers/usb/storage/sddr55.h
deleted file mode 100644 (file)
index a815a04..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Driver for SanDisk SDDR-55 SmartMedia reader
- * Header File
- *
- * Current development and maintenance by:
- *   (c) 2002 Simon Munton
- *
- * See sddr55.c for more explanation
- *
- * 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
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifndef _USB_SHUTTLE_EUSB_SDDR55_H
-#define _USB_SHUTTLE_EUSB_SDDR55_H
-
-/* Sandisk SDDR-55 stuff */
-
-extern int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us);
-extern int sddr55_reset(struct us_data *us);
-
-#endif
index 83ce1d33554a7b3ac2b72cdf160eaf3a21c02a1f..50034e141f94d487d6107132f60d6d85bc836eb0 100644 (file)
@@ -1098,15 +1098,6 @@ UNUSUAL_DEV( 0x07c4, 0xa006, 0x0000, 0xffff,
                US_SC_SCSI, US_PR_DATAFAB, NULL,
                0 ),
 #endif
-               
-#ifdef CONFIG_USB_STORAGE_SDDR55
-/* Contributed by Peter Waechtler */
-UNUSUAL_DEV( 0x07c4, 0xa103, 0x0000, 0x9999,
-               "Datafab",
-               "MDSM-B reader",
-               US_SC_SCSI, US_PR_SDDR55, NULL,
-               US_FL_FIX_INQUIRY ),
-#endif
 
 #ifdef CONFIG_USB_STORAGE_DATAFAB
 /* Submitted by Olaf Hering <olh@suse.de> */
@@ -1116,14 +1107,6 @@ UNUSUAL_DEV(  0x07c4, 0xa109, 0x0000, 0xffff,
                US_SC_SCSI, US_PR_DATAFAB, NULL,
                0 ),
 #endif
-#ifdef CONFIG_USB_STORAGE_SDDR55
-/* SM part - aeb <Andries.Brouwer@cwi.nl> */
-UNUSUAL_DEV(  0x07c4, 0xa109, 0x0000, 0xffff,
-               "Datafab Systems, Inc.",
-               "USB to CF + SM Combo (LC1)",
-               US_SC_SCSI, US_PR_SDDR55, NULL,
-               US_FL_SINGLE_LUN ),
-#endif
 
 #ifdef CONFIG_USB_STORAGE_DATAFAB
 /* Reported by Felix Moeller <felix@derklecks.de>
@@ -1348,13 +1331,6 @@ UNUSUAL_DEV( 0x0c0b, 0xa109, 0x0000, 0xffff,
                US_SC_SCSI, US_PR_DATAFAB, NULL,
                US_FL_SINGLE_LUN ),
 #endif
-#ifdef CONFIG_USB_STORAGE_SDDR55
-UNUSUAL_DEV( 0x0c0b, 0xa109, 0x0000, 0xffff,
-               "Acomdata",
-               "SM",
-               US_SC_SCSI, US_PR_SDDR55, NULL,
-               US_FL_SINGLE_LUN ),
-#endif
 
 UNUSUAL_DEV(  0x0d49, 0x7310, 0x0000, 0x9999,
                "Maxtor",
@@ -2041,14 +2017,6 @@ UNUSUAL_DEV(  0x4146, 0xba01, 0x0100, 0x0100,
                "Micro Mini 1GB",
                US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ),
 
-#ifdef CONFIG_USB_STORAGE_SDDR55
-UNUSUAL_DEV(  0x55aa, 0xa103, 0x0000, 0x9999, 
-               "Sandisk",
-               "ImageMate SDDR55",
-               US_SC_SCSI, US_PR_SDDR55, NULL,
-               US_FL_SINGLE_LUN),
-#endif
-
 /* Reported by Andrew Simmons <andrew.simmons@gmail.com> */
 UNUSUAL_DEV(  0xed06, 0x4500, 0x0001, 0x0001,
                "DataStor",
diff --git a/drivers/usb/storage/unusual_sddr55.h b/drivers/usb/storage/unusual_sddr55.h
new file mode 100644 (file)
index 0000000..ae81ef7
--- /dev/null
@@ -0,0 +1,44 @@
+/* Unusual Devices File for SanDisk SDDR-55 SmartMedia reader
+ *
+ * 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
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#if defined(CONFIG_USB_STORAGE_SDDR55) || \
+               defined(CONFIG_USB_STORAGE_SDDR55_MODULE)
+
+/* Contributed by Peter Waechtler */
+UNUSUAL_DEV( 0x07c4, 0xa103, 0x0000, 0x9999,
+               "Datafab",
+               "MDSM-B reader",
+               US_SC_SCSI, US_PR_SDDR55, NULL,
+               US_FL_FIX_INQUIRY),
+
+/* SM part - aeb <Andries.Brouwer@cwi.nl> */
+UNUSUAL_DEV(  0x07c4, 0xa109, 0x0000, 0xffff,
+               "Datafab Systems, Inc.",
+               "USB to CF + SM Combo (LC1)",
+               US_SC_SCSI, US_PR_SDDR55, NULL, 0),
+
+UNUSUAL_DEV( 0x0c0b, 0xa109, 0x0000, 0xffff,
+               "Acomdata",
+               "SM",
+               US_SC_SCSI, US_PR_SDDR55, NULL, 0),
+
+UNUSUAL_DEV(  0x55aa, 0xa103, 0x0000, 0x9999,
+               "Sandisk",
+               "ImageMate SDDR55",
+               US_SC_SCSI, US_PR_SDDR55, NULL, 0),
+
+#endif /* defined(CONFIG_USB_STORAGE_SDDR55) || ... */
index e65cbba452b070c4fdbb2a18ad0895bca38835eb..238f271d8171c60a6dc2724f991673e2cfb0fea5 100644 (file)
@@ -69,9 +69,6 @@
 #ifdef CONFIG_USB_STORAGE_USBAT
 #include "shuttle_usbat.h"
 #endif
-#ifdef CONFIG_USB_STORAGE_SDDR55
-#include "sddr55.h"
-#endif
 #ifdef CONFIG_USB_STORAGE_FREECOM
 #include "freecom.h"
 #endif
@@ -625,15 +622,6 @@ static void get_transport(struct us_data *us)
                break;
 #endif
 
-#ifdef CONFIG_USB_STORAGE_SDDR55
-       case US_PR_SDDR55:
-               us->transport_name = "SDDR55";
-               us->transport = sddr55_transport;
-               us->transport_reset = sddr55_reset;
-               us->max_lun = 0;
-               break;
-#endif
-
 #ifdef CONFIG_USB_STORAGE_FREECOM
        case US_PR_FREECOM:
                us->transport_name = "Freecom";
index 61ebddcc9ae0b195ae21b7834a33c80437038fb3..5f2703fa48e62f0fb7a8add95ec8e442cf4c23c3 100644 (file)
@@ -79,6 +79,7 @@ struct ignore_entry {
 static struct ignore_entry ignore_ids[] = {
 #      include "unusual_isd200.h"
 #      include "unusual_sddr09.h"
+#      include "unusual_sddr55.h"
        { }             /* Terminating entry */
 };