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

index 43e1afeb7f8ca6669524ff6e03ff5a475cb8bda2..c56c2c6d37b734ac249326647bb73d86f19e1221 100644 (file)
@@ -119,7 +119,7 @@ config USB_STORAGE_JUMPSHOT
          If this driver is compiled as a module, it will be named ums-jumpshot.
 
 config USB_STORAGE_ALAUDA
          If this driver is compiled as a module, it will be named ums-jumpshot.
 
 config USB_STORAGE_ALAUDA
-       bool "Olympus MAUSB-10/Fuji DPC-R1 support"
+       tristate "Olympus MAUSB-10/Fuji DPC-R1 support"
        depends on USB_STORAGE
        help
          Say Y here to include additional code to support the Olympus MAUSB-10
        depends on USB_STORAGE
        help
          Say Y here to include additional code to support the Olympus MAUSB-10
@@ -128,6 +128,8 @@ config USB_STORAGE_ALAUDA
          These devices are based on the Alauda chip and support both
          XD and SmartMedia cards.
 
          These devices are based on the Alauda chip and support both
          XD and SmartMedia cards.
 
+         If this driver is compiled as a module, it will be named ums-alauda.
+
 config USB_STORAGE_ONETOUCH
        bool "Support OneTouch Button on Maxtor Hard Drives"
        depends on USB_STORAGE
 config USB_STORAGE_ONETOUCH
        bool "Support OneTouch Button on Maxtor Hard Drives"
        depends on USB_STORAGE
index 7b9d53563d34934cb2b9d5f104063beb0db13c27..fea05c0b67652bb3aeb60fd576120f4a8241a26e 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
 obj-$(CONFIG_USB_STORAGE)      += usb-storage.o
 
 usb-storage-obj-$(CONFIG_USB_STORAGE_DEBUG)    += debug.o
-usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA)   += alauda.o
 usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o
 usb-storage-obj-$(CONFIG_USB_STORAGE_KARMA)    += karma.o
 
 usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o
 usb-storage-obj-$(CONFIG_USB_STORAGE_KARMA)    += karma.o
 
@@ -23,6 +22,7 @@ else
        obj-$(CONFIG_USB)       += libusual.o usual-tables.o
 endif
 
        obj-$(CONFIG_USB)       += libusual.o usual-tables.o
 endif
 
+obj-$(CONFIG_USB_STORAGE_ALAUDA)       += ums-alauda.o
 obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += ums-cypress.o
 obj-$(CONFIG_USB_STORAGE_DATAFAB)      += ums-datafab.o
 obj-$(CONFIG_USB_STORAGE_FREECOM)      += ums-freecom.o
 obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += ums-cypress.o
 obj-$(CONFIG_USB_STORAGE_DATAFAB)      += ums-datafab.o
 obj-$(CONFIG_USB_STORAGE_FREECOM)      += ums-freecom.o
@@ -32,6 +32,7 @@ obj-$(CONFIG_USB_STORAGE_SDDR09)      += ums-sddr09.o
 obj-$(CONFIG_USB_STORAGE_SDDR55)       += ums-sddr55.o
 obj-$(CONFIG_USB_STORAGE_USBAT)                += ums-usbat.o
 
 obj-$(CONFIG_USB_STORAGE_SDDR55)       += ums-sddr55.o
 obj-$(CONFIG_USB_STORAGE_USBAT)                += ums-usbat.o
 
+ums-alauda-objs                := alauda.o
 ums-cypress-objs       := cypress_atacb.o
 ums-datafab-objs       := datafab.o
 ums-freecom-objs       := freecom.o
 ums-cypress-objs       := cypress_atacb.o
 ums-datafab-objs       := datafab.o
 ums-freecom-objs       := freecom.o
index 5407411e30e0628d9b175f0396a6ed281dfe152b..d3a88ebe690b9edff88532007855fc10bfaeafed 100644 (file)
@@ -31,6 +31,8 @@
  * 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
  * 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/module.h>
+
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_device.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_device.h>
 #include "transport.h"
 #include "protocol.h"
 #include "debug.h"
 #include "transport.h"
 #include "protocol.h"
 #include "debug.h"
-#include "alauda.h"
+
+/*
+ * Status bytes
+ */
+#define ALAUDA_STATUS_ERROR            0x01
+#define ALAUDA_STATUS_READY            0x40
+
+/*
+ * Control opcodes (for request field)
+ */
+#define ALAUDA_GET_XD_MEDIA_STATUS     0x08
+#define ALAUDA_GET_SM_MEDIA_STATUS     0x98
+#define ALAUDA_ACK_XD_MEDIA_CHANGE     0x0a
+#define ALAUDA_ACK_SM_MEDIA_CHANGE     0x9a
+#define ALAUDA_GET_XD_MEDIA_SIG                0x86
+#define ALAUDA_GET_SM_MEDIA_SIG                0x96
+
+/*
+ * Bulk command identity (byte 0)
+ */
+#define ALAUDA_BULK_CMD                        0x40
+
+/*
+ * Bulk opcodes (byte 1)
+ */
+#define ALAUDA_BULK_GET_REDU_DATA      0x85
+#define ALAUDA_BULK_READ_BLOCK         0x94
+#define ALAUDA_BULK_ERASE_BLOCK                0xa3
+#define ALAUDA_BULK_WRITE_BLOCK                0xb4
+#define ALAUDA_BULK_GET_STATUS2                0xb7
+#define ALAUDA_BULK_RESET_MEDIA                0xe0
+
+/*
+ * Port to operate on (byte 8)
+ */
+#define ALAUDA_PORT_XD                 0x00
+#define ALAUDA_PORT_SM                 0x01
+
+/*
+ * LBA and PBA are unsigned ints. Special values.
+ */
+#define UNDEF    0xffff
+#define SPARE    0xfffe
+#define UNUSABLE 0xfffd
+
+struct alauda_media_info {
+       unsigned long capacity;         /* total media size in bytes */
+       unsigned int pagesize;          /* page size in bytes */
+       unsigned int blocksize;         /* number of pages per block */
+       unsigned int uzonesize;         /* number of usable blocks per zone */
+       unsigned int zonesize;          /* number of blocks per zone */
+       unsigned int blockmask;         /* mask to get page from address */
+
+       unsigned char pageshift;
+       unsigned char blockshift;
+       unsigned char zoneshift;
+
+       u16 **lba_to_pba;               /* logical to physical block map */
+       u16 **pba_to_lba;               /* physical to logical block map */
+};
+
+struct alauda_info {
+       struct alauda_media_info port[2];
+       int wr_ep;                      /* endpoint to write data out of */
+
+       unsigned char sense_key;
+       unsigned long sense_asc;        /* additional sense code */
+       unsigned long sense_ascq;       /* additional sense code qualifier */
+};
 
 #define short_pack(lsb,msb) ( ((u16)(lsb)) | ( ((u16)(msb))<<8 ) )
 #define LSB_of(s) ((s)&0xFF)
 
 #define short_pack(lsb,msb) ( ((u16)(lsb)) | ( ((u16)(msb))<<8 ) )
 #define LSB_of(s) ((s)&0xFF)
 #define PBA_HI(pba) (pba >> 3)
 #define PBA_ZONE(pba) (pba >> 11)
 
 #define PBA_HI(pba) (pba >> 3)
 #define PBA_ZONE(pba) (pba >> 11)
 
+static int init_alauda(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 alauda_usb_ids[] = {
+#      include "unusual_alauda.h"
+       { }             /* Terminating entry */
+};
+MODULE_DEVICE_TABLE(usb, alauda_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 alauda_unusual_dev_list[] = {
+#      include "unusual_alauda.h"
+       { }             /* Terminating entry */
+};
+
+#undef UNUSUAL_DEV
+
+
 /*
  * Media handling
  */
 /*
  * Media handling
  */
@@ -998,7 +1110,7 @@ static void alauda_info_destructor(void *extra)
 /*
  * Initialize alauda_info struct and find the data-write endpoint
  */
 /*
  * Initialize alauda_info struct and find the data-write endpoint
  */
-int init_alauda(struct us_data *us)
+static int init_alauda(struct us_data *us)
 {
        struct alauda_info *info;
        struct usb_host_interface *altsetting = us->pusb_intf->cur_altsetting;
 {
        struct alauda_info *info;
        struct usb_host_interface *altsetting = us->pusb_intf->cur_altsetting;
@@ -1020,7 +1132,7 @@ int init_alauda(struct us_data *us)
        return USB_STOR_TRANSPORT_GOOD;
 }
 
        return USB_STOR_TRANSPORT_GOOD;
 }
 
-int alauda_transport(struct scsi_cmnd *srb, struct us_data *us)
+static int alauda_transport(struct scsi_cmnd *srb, struct us_data *us)
 {
        int rc;
        struct alauda_info *info = (struct alauda_info *) us->extra;
 {
        int rc;
        struct alauda_info *info = (struct alauda_info *) us->extra;
@@ -1128,3 +1240,48 @@ int alauda_transport(struct scsi_cmnd *srb, struct us_data *us)
        return USB_STOR_TRANSPORT_FAILED;
 }
 
        return USB_STOR_TRANSPORT_FAILED;
 }
 
+static int alauda_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 - alauda_usb_ids) + alauda_unusual_dev_list);
+       if (result)
+               return result;
+
+       us->transport_name  = "Alauda Control/Bulk";
+       us->transport = alauda_transport;
+       us->transport_reset = usb_stor_Bulk_reset;
+       us->max_lun = 1;
+
+       result = usb_stor_probe2(us);
+       return result;
+}
+
+static struct usb_driver alauda_driver = {
+       .name =         "ums-alauda",
+       .probe =        alauda_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 =     alauda_usb_ids,
+       .soft_unbind =  1,
+};
+
+static int __init alauda_init(void)
+{
+       return usb_register(&alauda_driver);
+}
+
+static void __exit alauda_exit(void)
+{
+       usb_deregister(&alauda_driver);
+}
+
+module_init(alauda_init);
+module_exit(alauda_exit);
diff --git a/drivers/usb/storage/alauda.h b/drivers/usb/storage/alauda.h
deleted file mode 100644 (file)
index a700f87..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Driver for Alauda-based card readers
- *
- * Current development and maintenance by:
- *    (c) 2005 Daniel Drake <dsd@gentoo.org>
- *
- * See alauda.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_ALAUDA_H
-#define _USB_ALAUDA_H
-
-/*
- * Status bytes
- */
-#define ALAUDA_STATUS_ERROR            0x01
-#define ALAUDA_STATUS_READY            0x40
-
-/*
- * Control opcodes (for request field)
- */
-#define ALAUDA_GET_XD_MEDIA_STATUS     0x08
-#define ALAUDA_GET_SM_MEDIA_STATUS     0x98
-#define ALAUDA_ACK_XD_MEDIA_CHANGE     0x0a
-#define ALAUDA_ACK_SM_MEDIA_CHANGE     0x9a
-#define ALAUDA_GET_XD_MEDIA_SIG                0x86
-#define ALAUDA_GET_SM_MEDIA_SIG                0x96
-
-/*
- * Bulk command identity (byte 0)
- */
-#define ALAUDA_BULK_CMD                        0x40
-
-/*
- * Bulk opcodes (byte 1)
- */
-#define ALAUDA_BULK_GET_REDU_DATA      0x85
-#define ALAUDA_BULK_READ_BLOCK         0x94
-#define ALAUDA_BULK_ERASE_BLOCK                0xa3
-#define ALAUDA_BULK_WRITE_BLOCK                0xb4
-#define ALAUDA_BULK_GET_STATUS2                0xb7
-#define ALAUDA_BULK_RESET_MEDIA                0xe0
-
-/*
- * Port to operate on (byte 8)
- */
-#define ALAUDA_PORT_XD                 0x00
-#define ALAUDA_PORT_SM                 0x01
-
-/*
- * LBA and PBA are unsigned ints. Special values.
- */
-#define UNDEF    0xffff
-#define SPARE    0xfffe
-#define UNUSABLE 0xfffd
-
-int init_alauda(struct us_data *us);
-int alauda_transport(struct scsi_cmnd *srb, struct us_data *us);
-
-struct alauda_media_info {
-       unsigned long capacity;         /* total media size in bytes */
-       unsigned int pagesize;          /* page size in bytes */
-       unsigned int blocksize;         /* number of pages per block */
-       unsigned int uzonesize;         /* number of usable blocks per zone */
-       unsigned int zonesize;          /* number of blocks per zone */
-       unsigned int blockmask;         /* mask to get page from address */
-
-       unsigned char pageshift;
-       unsigned char blockshift;
-       unsigned char zoneshift;
-
-       u16 **lba_to_pba;               /* logical to physical block map */
-       u16 **pba_to_lba;               /* physical to logical block map */
-};
-
-struct alauda_info {
-       struct alauda_media_info port[2];
-       int wr_ep;                      /* endpoint to write data out of */
-
-       unsigned char sense_key;
-       unsigned long sense_asc;        /* additional sense code */
-       unsigned long sense_ascq;       /* additional sense code qualifier */
-};
-
-#endif
-
diff --git a/drivers/usb/storage/unusual_alauda.h b/drivers/usb/storage/unusual_alauda.h
new file mode 100644 (file)
index 0000000..8c412f8
--- /dev/null
@@ -0,0 +1,31 @@
+/* Unusual Devices File for the Alauda-based card readers
+ *
+ * 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_ALAUDA) || \
+               defined(CONFIG_USB_STORAGE_ALAUDA_MODULE)
+
+UNUSUAL_DEV(  0x0584, 0x0008, 0x0102, 0x0102,
+               "Fujifilm",
+               "DPC-R1 (Alauda)",
+               US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0),
+
+UNUSUAL_DEV(  0x07b4, 0x010a, 0x0102, 0x0102,
+               "Olympus",
+               "MAUSB-10 (Alauda)",
+               US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0),
+
+#endif /* defined(CONFIG_USB_STORAGE_ALAUDA) || ... */
index 24e23c29d292cf542693ed3be0f905502b5b8d3a..bcdb74dfa3db64e3f7ce2119ccab631eb34a000a 100644 (file)
@@ -692,13 +692,6 @@ UNUSUAL_DEV(  0x057b, 0x0022, 0x0000, 0x9999,
                "Silicon Media R/W",
                US_SC_DEVICE, US_PR_DEVICE, NULL, 0),
 
                "Silicon Media R/W",
                US_SC_DEVICE, US_PR_DEVICE, NULL, 0),
 
-#ifdef CONFIG_USB_STORAGE_ALAUDA
-UNUSUAL_DEV(  0x0584, 0x0008, 0x0102, 0x0102,
-               "Fujifilm",
-               "DPC-R1 (Alauda)",
-               US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0 ),
-#endif
-
 /* Reported by RTE <raszilki@yandex.ru> */
 UNUSUAL_DEV(  0x058f, 0x6387, 0x0141, 0x0141,
                "JetFlash",
 /* Reported by RTE <raszilki@yandex.ru> */
 UNUSUAL_DEV(  0x058f, 0x6387, 0x0141, 0x0141,
                "JetFlash",
@@ -977,13 +970,6 @@ UNUSUAL_DEV(  0x07af, 0x0006, 0x0100, 0x0100,
                US_FL_SINGLE_LUN ),
 #endif
 
                US_FL_SINGLE_LUN ),
 #endif
 
-#ifdef CONFIG_USB_STORAGE_ALAUDA
-UNUSUAL_DEV(  0x07b4, 0x010a, 0x0102, 0x0102,
-               "Olympus",
-               "MAUSB-10 (Alauda)",
-               US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0 ),
-#endif
-
 /* Datafab KECF-USB / Sagatek DCS-CF / Simpletech Flashlink UCF-100
  * Only revision 1.13 tested (same for all of the above devices,
  * based on the Datafab DF-UG-07 chip).  Needed for US_FL_FIX_INQUIRY.
 /* Datafab KECF-USB / Sagatek DCS-CF / Simpletech Flashlink UCF-100
  * Only revision 1.13 tested (same for all of the above devices,
  * based on the Datafab DF-UG-07 chip).  Needed for US_FL_FIX_INQUIRY.
index 2ea57691a7ba319ee67faa251695e492676a2fab..cd039c008462bb3aec7527404f1f719e7351137a 100644 (file)
@@ -69,9 +69,6 @@
 #ifdef CONFIG_USB_STORAGE_ONETOUCH
 #include "onetouch.h"
 #endif
 #ifdef CONFIG_USB_STORAGE_ONETOUCH
 #include "onetouch.h"
 #endif
-#ifdef CONFIG_USB_STORAGE_ALAUDA
-#include "alauda.h"
-#endif
 #ifdef CONFIG_USB_STORAGE_KARMA
 #include "karma.h"
 #endif
 #ifdef CONFIG_USB_STORAGE_KARMA
 #include "karma.h"
 #endif
@@ -598,15 +595,6 @@ static void get_transport(struct us_data *us)
                us->transport_reset = usb_stor_Bulk_reset;
                break;
 
                us->transport_reset = usb_stor_Bulk_reset;
                break;
 
-#ifdef CONFIG_USB_STORAGE_ALAUDA
-       case US_PR_ALAUDA:
-               us->transport_name  = "Alauda Control/Bulk";
-               us->transport = alauda_transport;
-               us->transport_reset = usb_stor_Bulk_reset;
-               us->max_lun = 1;
-               break;
-#endif
-
 #ifdef CONFIG_USB_STORAGE_KARMA
        case US_PR_KARMA:
                us->transport_name = "Rio Karma/Bulk";
 #ifdef CONFIG_USB_STORAGE_KARMA
        case US_PR_KARMA:
                us->transport_name = "Rio Karma/Bulk";
index 182a097e07670498b5f5361bbfe2f91c7b8b8407..ad102e8e191b628070225e425d3f516c96ba59cc 100644 (file)
@@ -77,6 +77,7 @@ struct ignore_entry {
 }
 
 static struct ignore_entry ignore_ids[] = {
 }
 
 static struct ignore_entry ignore_ids[] = {
+#      include "unusual_alauda.h"
 #      include "unusual_cypress.h"
 #      include "unusual_datafab.h"
 #      include "unusual_freecom.h"
 #      include "unusual_cypress.h"
 #      include "unusual_datafab.h"
 #      include "unusual_freecom.h"
This page took 0.036971 seconds and 5 git commands to generate.