diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2009-02-12 14:48:26 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-03-24 19:20:35 -0400 |
commit | c10337846c93bd914dd3003ffb001adc583b313e (patch) | |
tree | 32cb40a67324c7033c32fcae2e35609c192bb878 /drivers/usb/storage/karma.c | |
parent | a74bba3bf92cb6425789ae5050bdcca1283bc6f4 (diff) |
usb-storage: make karma a separate module
This patch (as1216) converts usb-storage's karma subdriver into a
separate module.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/storage/karma.c')
-rw-r--r-- | drivers/usb/storage/karma.c | 96 |
1 files changed, 91 insertions, 5 deletions
diff --git a/drivers/usb/storage/karma.c b/drivers/usb/storage/karma.c index 0d79ae5683f7..cfb8e60866b8 100644 --- a/drivers/usb/storage/karma.c +++ b/drivers/usb/storage/karma.c | |||
@@ -18,6 +18,8 @@ | |||
18 | * 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | * 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/module.h> | ||
22 | |||
21 | #include <scsi/scsi.h> | 23 | #include <scsi/scsi.h> |
22 | #include <scsi/scsi_cmnd.h> | 24 | #include <scsi/scsi_cmnd.h> |
23 | #include <scsi/scsi_device.h> | 25 | #include <scsi/scsi_device.h> |
@@ -25,7 +27,6 @@ | |||
25 | #include "usb.h" | 27 | #include "usb.h" |
26 | #include "transport.h" | 28 | #include "transport.h" |
27 | #include "debug.h" | 29 | #include "debug.h" |
28 | #include "karma.h" | ||
29 | 30 | ||
30 | #define RIO_PREFIX "RIOP\x00" | 31 | #define RIO_PREFIX "RIOP\x00" |
31 | #define RIO_PREFIX_LEN 5 | 32 | #define RIO_PREFIX_LEN 5 |
@@ -36,13 +37,53 @@ | |||
36 | #define RIO_LEAVE_STORAGE 0x2 | 37 | #define RIO_LEAVE_STORAGE 0x2 |
37 | #define RIO_RESET 0xC | 38 | #define RIO_RESET 0xC |
38 | 39 | ||
39 | extern int usb_stor_Bulk_transport(struct scsi_cmnd *, struct us_data *); | ||
40 | |||
41 | struct karma_data { | 40 | struct karma_data { |
42 | int in_storage; | 41 | int in_storage; |
43 | char *recv; | 42 | char *recv; |
44 | }; | 43 | }; |
45 | 44 | ||
45 | static int rio_karma_init(struct us_data *us); | ||
46 | |||
47 | |||
48 | /* | ||
49 | * The table of devices | ||
50 | */ | ||
51 | #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \ | ||
52 | vendorName, productName, useProtocol, useTransport, \ | ||
53 | initFunction, flags) \ | ||
54 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ | ||
55 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } | ||
56 | |||
57 | struct usb_device_id karma_usb_ids[] = { | ||
58 | # include "unusual_karma.h" | ||
59 | { } /* Terminating entry */ | ||
60 | }; | ||
61 | MODULE_DEVICE_TABLE(usb, karma_usb_ids); | ||
62 | |||
63 | #undef UNUSUAL_DEV | ||
64 | |||
65 | /* | ||
66 | * The flags table | ||
67 | */ | ||
68 | #define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \ | ||
69 | vendor_name, product_name, use_protocol, use_transport, \ | ||
70 | init_function, Flags) \ | ||
71 | { \ | ||
72 | .vendorName = vendor_name, \ | ||
73 | .productName = product_name, \ | ||
74 | .useProtocol = use_protocol, \ | ||
75 | .useTransport = use_transport, \ | ||
76 | .initFunction = init_function, \ | ||
77 | } | ||
78 | |||
79 | static struct us_unusual_dev karma_unusual_dev_list[] = { | ||
80 | # include "unusual_karma.h" | ||
81 | { } /* Terminating entry */ | ||
82 | }; | ||
83 | |||
84 | #undef UNUSUAL_DEV | ||
85 | |||
86 | |||
46 | /* | 87 | /* |
47 | * Send commands to Rio Karma. | 88 | * Send commands to Rio Karma. |
48 | * | 89 | * |
@@ -104,7 +145,7 @@ err: | |||
104 | * Trap START_STOP and READ_10 to leave/re-enter storage mode. | 145 | * Trap START_STOP and READ_10 to leave/re-enter storage mode. |
105 | * Everything else is propagated to the normal bulk layer. | 146 | * Everything else is propagated to the normal bulk layer. |
106 | */ | 147 | */ |
107 | int rio_karma_transport(struct scsi_cmnd *srb, struct us_data *us) | 148 | static int rio_karma_transport(struct scsi_cmnd *srb, struct us_data *us) |
108 | { | 149 | { |
109 | int ret; | 150 | int ret; |
110 | struct karma_data *data = (struct karma_data *) us->extra; | 151 | struct karma_data *data = (struct karma_data *) us->extra; |
@@ -133,7 +174,7 @@ static void rio_karma_destructor(void *extra) | |||
133 | kfree(data->recv); | 174 | kfree(data->recv); |
134 | } | 175 | } |
135 | 176 | ||
136 | int rio_karma_init(struct us_data *us) | 177 | static int rio_karma_init(struct us_data *us) |
137 | { | 178 | { |
138 | int ret = 0; | 179 | int ret = 0; |
139 | struct karma_data *data = kzalloc(sizeof(struct karma_data), GFP_NOIO); | 180 | struct karma_data *data = kzalloc(sizeof(struct karma_data), GFP_NOIO); |
@@ -153,3 +194,48 @@ int rio_karma_init(struct us_data *us) | |||
153 | out: | 194 | out: |
154 | return ret; | 195 | return ret; |
155 | } | 196 | } |
197 | |||
198 | static int karma_probe(struct usb_interface *intf, | ||
199 | const struct usb_device_id *id) | ||
200 | { | ||
201 | struct us_data *us; | ||
202 | int result; | ||
203 | |||
204 | result = usb_stor_probe1(&us, intf, id, | ||
205 | (id - karma_usb_ids) + karma_unusual_dev_list); | ||
206 | if (result) | ||
207 | return result; | ||
208 | |||
209 | us->transport_name = "Rio Karma/Bulk"; | ||
210 | us->transport = rio_karma_transport; | ||
211 | us->transport_reset = usb_stor_Bulk_reset; | ||
212 | |||
213 | result = usb_stor_probe2(us); | ||
214 | return result; | ||
215 | } | ||
216 | |||
217 | static struct usb_driver karma_driver = { | ||
218 | .name = "ums-karma", | ||
219 | .probe = karma_probe, | ||
220 | .disconnect = usb_stor_disconnect, | ||
221 | .suspend = usb_stor_suspend, | ||
222 | .resume = usb_stor_resume, | ||
223 | .reset_resume = usb_stor_reset_resume, | ||
224 | .pre_reset = usb_stor_pre_reset, | ||
225 | .post_reset = usb_stor_post_reset, | ||
226 | .id_table = karma_usb_ids, | ||
227 | .soft_unbind = 1, | ||
228 | }; | ||
229 | |||
230 | static int __init karma_init(void) | ||
231 | { | ||
232 | return usb_register(&karma_driver); | ||
233 | } | ||
234 | |||
235 | static void __exit karma_exit(void) | ||
236 | { | ||
237 | usb_deregister(&karma_driver); | ||
238 | } | ||
239 | |||
240 | module_init(karma_init); | ||
241 | module_exit(karma_exit); | ||