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

index 8adece1dd2947e37264bc634fafa43885524ee5f..8a372bac0e435cf4d57e0a588904bb5d918347f5 100644 (file)
@@ -131,7 +131,7 @@ config USB_STORAGE_ALAUDA
          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"
+       tristate "Support OneTouch Button on Maxtor Hard Drives"
        depends on USB_STORAGE
        depends on INPUT=y || INPUT=USB_STORAGE
        help
@@ -143,6 +143,8 @@ config USB_STORAGE_ONETOUCH
          this input in any keybinding software. (e.g. gnome's keyboard short-
          cuts)
 
+         If this driver is compiled as a module, it will be named ums-onetouch.
+
 config USB_STORAGE_KARMA
        tristate "Support for Rio Karma music player"
        depends on USB_STORAGE
index 870680ea37098d21127d7622be3ab283d629d5ae..5be54c01966219608675b8338cf8d114d7d0cf59 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_ONETOUCH) += onetouch.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,6 +27,7 @@ obj-$(CONFIG_USB_STORAGE_FREECOM)     += ums-freecom.o
 obj-$(CONFIG_USB_STORAGE_ISD200)       += ums-isd200.o
 obj-$(CONFIG_USB_STORAGE_JUMPSHOT)     += ums-jumpshot.o
 obj-$(CONFIG_USB_STORAGE_KARMA)                += ums-karma.o
+obj-$(CONFIG_USB_STORAGE_ONETOUCH)     += ums-onetouch.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
@@ -39,6 +39,7 @@ ums-freecom-objs      := freecom.o
 ums-isd200-objs                := isd200.o
 ums-jumpshot-objs      := jumpshot.o
 ums-karma-objs         := karma.o
+ums-onetouch-objs      := onetouch.o
 ums-sddr09-objs                := sddr09.o
 ums-sddr55-objs                := sddr55.o
 ums-usbat-objs         := shuttle_usbat.o
index c7bf8954b4e4de35af0be81e9d7244ed9881eb16..8bd095635a99d21d5c8e0ada673c7b9621e94d05 100644 (file)
 #include <linux/module.h>
 #include <linux/usb/input.h>
 #include "usb.h"
-#include "onetouch.h"
 #include "debug.h"
 
+#define ONETOUCH_PKT_LEN        0x02
+#define ONETOUCH_BUTTON         KEY_PROG1
+
+static int onetouch_connect_input(struct us_data *ss);
 static void onetouch_release_input(void *onetouch_);
 
 struct usb_onetouch {
@@ -52,6 +55,46 @@ struct usb_onetouch {
        unsigned int is_open:1;
 };
 
+
+/*
+ * 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 onetouch_usb_ids[] = {
+#      include "unusual_onetouch.h"
+       { }             /* Terminating entry */
+};
+MODULE_DEVICE_TABLE(usb, onetouch_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 onetouch_unusual_dev_list[] = {
+#      include "unusual_onetouch.h"
+       { }             /* Terminating entry */
+};
+
+#undef UNUSUAL_DEV
+
+
 static void usb_onetouch_irq(struct urb *urb)
 {
        struct usb_onetouch *onetouch = urb->context;
@@ -127,7 +170,7 @@ static void usb_onetouch_pm_hook(struct us_data *us, int action)
 }
 #endif /* CONFIG_PM */
 
-int onetouch_connect_input(struct us_data *ss)
+static int onetouch_connect_input(struct us_data *ss)
 {
        struct usb_device *udev = ss->pusb_dev;
        struct usb_host_interface *interface;
@@ -236,3 +279,46 @@ static void onetouch_release_input(void *onetouch_)
                                onetouch->data, onetouch->data_dma);
        }
 }
+
+static int onetouch_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 - onetouch_usb_ids) + onetouch_unusual_dev_list);
+       if (result)
+               return result;
+
+       /* Use default transport and protocol */
+
+       result = usb_stor_probe2(us);
+       return result;
+}
+
+static struct usb_driver onetouch_driver = {
+       .name =         "ums-onetouch",
+       .probe =        onetouch_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 =     onetouch_usb_ids,
+       .soft_unbind =  1,
+};
+
+static int __init onetouch_init(void)
+{
+       return usb_register(&onetouch_driver);
+}
+
+static void __exit onetouch_exit(void)
+{
+       usb_deregister(&onetouch_driver);
+}
+
+module_init(onetouch_init);
+module_exit(onetouch_exit);
diff --git a/drivers/usb/storage/onetouch.h b/drivers/usb/storage/onetouch.h
deleted file mode 100644 (file)
index 41c7aa8..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef _ONETOUCH_H_
-#define _ONETOUCH_H_
-
-#define ONETOUCH_PKT_LEN        0x02
-#define ONETOUCH_BUTTON         KEY_PROG1
-
-int onetouch_connect_input(struct us_data *ss);
-
-#endif
index 83e34a6ad59d269f8244b1e89331a4554f423b92..1c1f643e8a78f7e3d85c4823caef6b11388cc54e 100644 (file)
@@ -1182,23 +1182,6 @@ UNUSUAL_DEV( 0x0c45, 0x1060, 0x0100, 0x0100,
                US_SC_DEVICE, US_PR_DEVICE, NULL,
                US_FL_SINGLE_LUN ),
 
-/* Submitted by: Nick Sillik <n.sillik@temple.edu>
- * Needed for OneTouch extension to usb-storage
- *
- */
-#ifdef CONFIG_USB_STORAGE_ONETOUCH
-       UNUSUAL_DEV(  0x0d49, 0x7000, 0x0000, 0x9999,
-                       "Maxtor",
-                       "OneTouch External Harddrive",
-                       US_SC_DEVICE, US_PR_DEVICE, onetouch_connect_input,
-                       0),
-       UNUSUAL_DEV(  0x0d49, 0x7010, 0x0000, 0x9999,
-                       "Maxtor",
-                       "OneTouch External Harddrive",
-                       US_SC_DEVICE, US_PR_DEVICE, onetouch_connect_input,
-                       0),
-#endif
-
 /* Submitted by Joris Struyve <joris@struyve.be> */
 UNUSUAL_DEV( 0x0d96, 0x410a, 0x0001, 0xffff,
                "Medion",
diff --git a/drivers/usb/storage/unusual_onetouch.h b/drivers/usb/storage/unusual_onetouch.h
new file mode 100644 (file)
index 0000000..bd9306b
--- /dev/null
@@ -0,0 +1,36 @@
+/* Unusual Devices File for the Maxtor OneTouch USB hard drive's button
+ *
+ * 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_ONETOUCH) || \
+               defined(CONFIG_USB_STORAGE_ONETOUCH_MODULE)
+
+/* Submitted by: Nick Sillik <n.sillik@temple.edu>
+ * Needed for OneTouch extension to usb-storage
+ */
+UNUSUAL_DEV(  0x0d49, 0x7000, 0x0000, 0x9999,
+               "Maxtor",
+               "OneTouch External Harddrive",
+               US_SC_DEVICE, US_PR_DEVICE, onetouch_connect_input,
+               0),
+
+UNUSUAL_DEV(  0x0d49, 0x7010, 0x0000, 0x9999,
+               "Maxtor",
+               "OneTouch External Harddrive",
+               US_SC_DEVICE, US_PR_DEVICE, onetouch_connect_input,
+               0),
+
+#endif /* defined(CONFIG_USB_STORAGE_ONETOUCH) || ... */
index c5abf9bbce166d71bc9045cbf8dccfc4e6c21342..8060b85fe1a3fb377476e1cd0a6de55df6de9014 100644 (file)
@@ -66,9 +66,6 @@
 #include "debug.h"
 #include "initializers.h"
 
-#ifdef CONFIG_USB_STORAGE_ONETOUCH
-#include "onetouch.h"
-#endif
 #include "sierra_ms.h"
 #include "option_ms.h"
 
index bce086fcef5e35241a5c4f5b91f1a8cd0ebf4624..468bde7d1971c92b12307ed7557ec786f7e5f289 100644 (file)
@@ -84,6 +84,7 @@ static struct ignore_entry ignore_ids[] = {
 #      include "unusual_isd200.h"
 #      include "unusual_jumpshot.h"
 #      include "unusual_karma.h"
+#      include "unusual_onetouch.h"
 #      include "unusual_sddr09.h"
 #      include "unusual_sddr55.h"
 #      include "unusual_usbat.h"