aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage/karma.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/storage/karma.c')
-rw-r--r--drivers/usb/storage/karma.c100
1 files changed, 95 insertions, 5 deletions
diff --git a/drivers/usb/storage/karma.c b/drivers/usb/storage/karma.c
index 0d79ae5683f..7953d93a773 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,10 @@
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" 30
31MODULE_DESCRIPTION("Driver for Rio Karma");
32MODULE_AUTHOR("Bob Copeland <me@bobcopeland.com>, Keith Bennett <keith@mcs.st-and.ac.uk>");
33MODULE_LICENSE("GPL");
29 34
30#define RIO_PREFIX "RIOP\x00" 35#define RIO_PREFIX "RIOP\x00"
31#define RIO_PREFIX_LEN 5 36#define RIO_PREFIX_LEN 5
@@ -36,13 +41,53 @@
36#define RIO_LEAVE_STORAGE 0x2 41#define RIO_LEAVE_STORAGE 0x2
37#define RIO_RESET 0xC 42#define RIO_RESET 0xC
38 43
39extern int usb_stor_Bulk_transport(struct scsi_cmnd *, struct us_data *);
40
41struct karma_data { 44struct karma_data {
42 int in_storage; 45 int in_storage;
43 char *recv; 46 char *recv;
44}; 47};
45 48
49static int rio_karma_init(struct us_data *us);
50
51
52/*
53 * The table of devices
54 */
55#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
56 vendorName, productName, useProtocol, useTransport, \
57 initFunction, flags) \
58{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
59 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
60
61struct usb_device_id karma_usb_ids[] = {
62# include "unusual_karma.h"
63 { } /* Terminating entry */
64};
65MODULE_DEVICE_TABLE(usb, karma_usb_ids);
66
67#undef UNUSUAL_DEV
68
69/*
70 * The flags table
71 */
72#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
73 vendor_name, product_name, use_protocol, use_transport, \
74 init_function, Flags) \
75{ \
76 .vendorName = vendor_name, \
77 .productName = product_name, \
78 .useProtocol = use_protocol, \
79 .useTransport = use_transport, \
80 .initFunction = init_function, \
81}
82
83static struct us_unusual_dev karma_unusual_dev_list[] = {
84# include "unusual_karma.h"
85 { } /* Terminating entry */
86};
87
88#undef UNUSUAL_DEV
89
90
46/* 91/*
47 * Send commands to Rio Karma. 92 * Send commands to Rio Karma.
48 * 93 *
@@ -104,7 +149,7 @@ err:
104 * Trap START_STOP and READ_10 to leave/re-enter storage mode. 149 * Trap START_STOP and READ_10 to leave/re-enter storage mode.
105 * Everything else is propagated to the normal bulk layer. 150 * Everything else is propagated to the normal bulk layer.
106 */ 151 */
107int rio_karma_transport(struct scsi_cmnd *srb, struct us_data *us) 152static int rio_karma_transport(struct scsi_cmnd *srb, struct us_data *us)
108{ 153{
109 int ret; 154 int ret;
110 struct karma_data *data = (struct karma_data *) us->extra; 155 struct karma_data *data = (struct karma_data *) us->extra;
@@ -133,7 +178,7 @@ static void rio_karma_destructor(void *extra)
133 kfree(data->recv); 178 kfree(data->recv);
134} 179}
135 180
136int rio_karma_init(struct us_data *us) 181static int rio_karma_init(struct us_data *us)
137{ 182{
138 int ret = 0; 183 int ret = 0;
139 struct karma_data *data = kzalloc(sizeof(struct karma_data), GFP_NOIO); 184 struct karma_data *data = kzalloc(sizeof(struct karma_data), GFP_NOIO);
@@ -153,3 +198,48 @@ int rio_karma_init(struct us_data *us)
153out: 198out:
154 return ret; 199 return ret;
155} 200}
201
202static int karma_probe(struct usb_interface *intf,
203 const struct usb_device_id *id)
204{
205 struct us_data *us;
206 int result;
207
208 result = usb_stor_probe1(&us, intf, id,
209 (id - karma_usb_ids) + karma_unusual_dev_list);
210 if (result)
211 return result;
212
213 us->transport_name = "Rio Karma/Bulk";
214 us->transport = rio_karma_transport;
215 us->transport_reset = usb_stor_Bulk_reset;
216
217 result = usb_stor_probe2(us);
218 return result;
219}
220
221static struct usb_driver karma_driver = {
222 .name = "ums-karma",
223 .probe = karma_probe,
224 .disconnect = usb_stor_disconnect,
225 .suspend = usb_stor_suspend,
226 .resume = usb_stor_resume,
227 .reset_resume = usb_stor_reset_resume,
228 .pre_reset = usb_stor_pre_reset,
229 .post_reset = usb_stor_post_reset,
230 .id_table = karma_usb_ids,
231 .soft_unbind = 1,
232};
233
234static int __init karma_init(void)
235{
236 return usb_register(&karma_driver);
237}
238
239static void __exit karma_exit(void)
240{
241 usb_deregister(&karma_driver);
242}
243
244module_init(karma_init);
245module_exit(karma_exit);