]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
usb-storage: make cypress_atacb a separate module
authorAlan Stern <stern@rowland.harvard.edu>
Thu, 12 Feb 2009 19:48:04 +0000 (14:48 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 24 Mar 2009 23:20:34 +0000 (16:20 -0700)
This patch (as1210) converts usb-storage's cypress_atacb 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/cypress_atacb.c
drivers/usb/storage/unusual_cypress.h [moved from drivers/usb/storage/cypress_atacb.h with 54% similarity]
drivers/usb/storage/unusual_devs.h
drivers/usb/storage/usb.c
drivers/usb/storage/usual-tables.c

index e6cc245257f8e694e214ba766040530c89492892..2c73fa97d94ddc7a8b6cf84ce81bf1c685da241b 100644 (file)
@@ -146,7 +146,7 @@ config USB_STORAGE_KARMA
          operation.
 
 config USB_STORAGE_CYPRESS_ATACB
-       bool "SAT emulation on Cypress USB/ATA Bridge with ATACB"
+       tristate "SAT emulation on Cypress USB/ATA Bridge with ATACB"
        depends on USB_STORAGE
        ---help---
          Say Y here if you want to use SAT (ata pass through) on devices based
@@ -156,6 +156,8 @@ config USB_STORAGE_CYPRESS_ATACB
          If you say no here your device will still work with the standard usb
          mass storage class.
 
+         If this driver is compiled as a module, it will be named ums-cypress.
+
 config USB_LIBUSUAL
        bool "The shared table of common (or usual) storage devices"
        depends on USB
index 5fb7847e41a426b24c3762b1c072f953376d6156..0650f022e5611f8ce3a3149d03e71cf96ed026b3 100644 (file)
@@ -17,7 +17,6 @@ usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT)        += jumpshot.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_CYPRESS_ATACB) += cypress_atacb.o
 
 usb-storage-objs :=    scsiglue.o protocol.o transport.o usb.o \
                        initializers.o sierra_ms.o option_ms.o $(usb-storage-obj-y)
@@ -28,10 +27,12 @@ else
        obj-$(CONFIG_USB)       += libusual.o usual-tables.o
 endif
 
+obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += ums-cypress.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
 
+ums-cypress-objs       := cypress_atacb.o
 ums-isd200-objs                := isd200.o
 ums-sddr09-objs                := sddr09.o
 ums-sddr55-objs                := sddr55.o
index 9466a99baab635755d540acc754c057aef4fb4bd..19306f7b1dae25a6e513b2641a62713083681dc8 100644 (file)
@@ -19,6 +19,7 @@
  * 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/module.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_eh.h>
 #include "scsiglue.h"
 #include "debug.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 cypress_usb_ids[] = {
+#      include "unusual_cypress.h"
+       { }             /* Terminating entry */
+};
+MODULE_DEVICE_TABLE(usb, cypress_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 cypress_unusual_dev_list[] = {
+#      include "unusual_cypress.h"
+       { }             /* Terminating entry */
+};
+
+#undef UNUSUAL_DEV
+
+
 /*
  * ATACB is a protocol used on cypress usb<->ata bridge to
  * send raw ATA command over mass storage
@@ -36,7 +77,7 @@
  * More info that be found on cy7c68310_8.pdf and cy7c68300c_8.pdf
  * datasheet from cypress.com.
  */
-void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us)
+static void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us)
 {
        unsigned char save_cmnd[MAX_COMMAND_SIZE];
 
@@ -197,3 +238,48 @@ end:
        if (srb->cmnd[0] == ATA_12)
                srb->cmd_len = 12;
 }
+
+
+static int cypress_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 - cypress_usb_ids) + cypress_unusual_dev_list);
+       if (result)
+               return result;
+
+       us->protocol_name = "Transparent SCSI with Cypress ATACB";
+       us->proto_handler = cypress_atacb_passthrough;
+
+       result = usb_stor_probe2(us);
+       return result;
+}
+
+static struct usb_driver cypress_driver = {
+       .name =         "ums-cypress",
+       .probe =        cypress_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 =     cypress_usb_ids,
+       .soft_unbind =  1,
+};
+
+static int __init cypress_init(void)
+{
+       return usb_register(&cypress_driver);
+}
+
+static void __exit cypress_exit(void)
+{
+       usb_deregister(&cypress_driver);
+}
+
+module_init(cypress_init);
+module_exit(cypress_exit);
similarity index 54%
rename from drivers/usb/storage/cypress_atacb.h
rename to drivers/usb/storage/unusual_cypress.h
index fbada898d56b371255687727cb7762ae4ea22021..44be6d75dab6ec7cec3519b9abf1b616f10f8b3e 100644 (file)
@@ -1,8 +1,5 @@
-/*
- * Support for emulating SAT (ata pass through) on devices based
- *       on the Cypress USB/ATA bridge supporting ATACB.
- *
- * Copyright (c) 2008 Matthieu Castet (castet.matthieu@free.fr)
+/* Unusual Devices File for devices based on the Cypress USB/ATA bridge
+ *     with support for ATACB
  *
  * 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 _CYPRESS_ATACB_H_
-#define _CYPRESS_ATACB_H_
-extern void cypress_atacb_passthrough(struct scsi_cmnd*, struct us_data*);
-#endif
+#if defined(CONFIG_USB_STORAGE_CYPRESS_ATACB) || \
+               defined(CONFIG_USB_STORAGE_CYPRESS_ATACB_MODULE)
+
+/* CY7C68300 : support atacb */
+UNUSUAL_DEV(  0x04b4, 0x6830, 0x0000, 0x9999,
+               "Cypress",
+               "Cypress AT2LP",
+               US_SC_CYP_ATACB, US_PR_DEVICE, NULL, 0),
+
+/* CY7C68310 : support atacb and atacb2 */
+UNUSUAL_DEV(  0x04b4, 0x6831, 0x0000, 0x9999,
+               "Cypress",
+               "Cypress ISD-300LP",
+               US_SC_CYP_ATACB, US_PR_DEVICE, NULL, 0),
+
+#endif /* defined(CONFIG_USB_STORAGE_CYPRESS_ATACB) || ... */
index 50034e141f94d487d6107132f60d6d85bc836eb0..eff97aed7bfea18619346c4d63d045af1d70b0ca 100644 (file)
@@ -375,22 +375,6 @@ UNUSUAL_DEV(  0x04b3, 0x4001, 0x0110, 0x0110,
                US_SC_DEVICE, US_PR_CB, NULL,
                US_FL_MAX_SECTORS_MIN),
 
-#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
-/* CY7C68300 : support atacb */
-UNUSUAL_DEV(  0x04b4, 0x6830, 0x0000, 0x9999,
-               "Cypress",
-               "Cypress AT2LP",
-               US_SC_CYP_ATACB, US_PR_DEVICE, NULL,
-               0),
-
-/* CY7C68310 : support atacb and atacb2 */
-UNUSUAL_DEV(  0x04b4, 0x6831, 0x0000, 0x9999,
-               "Cypress",
-               "Cypress ISD-300LP",
-               US_SC_CYP_ATACB, US_PR_DEVICE, NULL,
-               0),
-#endif
-
 /* Reported by Simon Levitt <simon@whattf.com>
  * This entry needs Sub and Proto fields */
 UNUSUAL_DEV(  0x04b8, 0x0601, 0x0100, 0x0100,
index 238f271d8171c60a6dc2724f991673e2cfb0fea5..241e1944cf101c11d409401b119aa5ecc1212f92 100644 (file)
@@ -87,9 +87,6 @@
 #ifdef CONFIG_USB_STORAGE_KARMA
 #include "karma.h"
 #endif
-#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
-#include "cypress_atacb.h"
-#endif
 #include "sierra_ms.h"
 #include "option_ms.h"
 
@@ -705,14 +702,6 @@ static void get_protocol(struct us_data *us)
                us->protocol_name = "Uniform Floppy Interface (UFI)";
                us->proto_handler = usb_stor_ufi_command;
                break;
-
-#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
-       case US_SC_CYP_ATACB:
-               us->protocol_name = "Transparent SCSI with Cypress ATACB";
-               us->proto_handler = cypress_atacb_passthrough;
-               break;
-#endif
-
        }
 }
 
index 5f2703fa48e62f0fb7a8add95ec8e442cf4c23c3..be461ee9f0057a4547cb783fae7da43843a92154 100644 (file)
@@ -77,6 +77,7 @@ struct ignore_entry {
 }
 
 static struct ignore_entry ignore_ids[] = {
+#      include "unusual_cypress.h"
 #      include "unusual_isd200.h"
 #      include "unusual_sddr09.h"
 #      include "unusual_sddr55.h"