Loading...
1/* Driver for Lexar "Jumpshot" Compact Flash reader
2 *
3 * jumpshot driver v0.1:
4 *
5 * First release
6 *
7 * Current development and maintenance by:
8 * (c) 2000 Jimmie Mayfield (mayfield+usb@sackheads.org)
9 *
10 * Many thanks to Robert Baruch for the SanDisk SmartMedia reader driver
11 * which I used as a template for this driver.
12 *
13 * Some bugfixes and scatter-gather code by Gregory P. Smith
14 * (greg-usb@electricrain.com)
15 *
16 * Fix for media change by Joerg Schneider (js@joergschneider.com)
17 *
18 * Developed with the assistance of:
19 *
20 * (C) 2002 Alan Stern <stern@rowland.org>
21 *
22 * This program is free software; you can redistribute it and/or modify it
23 * under the terms of the GNU General Public License as published by the
24 * Free Software Foundation; either version 2, or (at your option) any
25 * later version.
26 *
27 * This program is distributed in the hope that it will be useful, but
28 * WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 * General Public License for more details.
31 *
32 * You should have received a copy of the GNU General Public License along
33 * with this program; if not, write to the Free Software Foundation, Inc.,
34 * 675 Mass Ave, Cambridge, MA 02139, USA.
35 */
36
37 /*
38 * This driver attempts to support the Lexar Jumpshot USB CompactFlash
39 * reader. Like many other USB CompactFlash readers, the Jumpshot contains
40 * a USB-to-ATA chip.
41 *
42 * This driver supports reading and writing. If you're truly paranoid,
43 * however, you can force the driver into a write-protected state by setting
44 * the WP enable bits in jumpshot_handle_mode_sense. See the comments
45 * in that routine.
46 */
47
48#include <linux/errno.h>
49#include <linux/module.h>
50#include <linux/slab.h>
51
52#include <scsi/scsi.h>
53#include <scsi/scsi_cmnd.h>
54
55#include "usb.h"
56#include "transport.h"
57#include "protocol.h"
58#include "debug.h"
59
60
61MODULE_DESCRIPTION("Driver for Lexar \"Jumpshot\" Compact Flash reader");
62MODULE_AUTHOR("Jimmie Mayfield <mayfield+usb@sackheads.org>");
63MODULE_LICENSE("GPL");
64
65/*
66 * The table of devices
67 */
68#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
69 vendorName, productName, useProtocol, useTransport, \
70 initFunction, flags) \
71{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
72 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
73
74struct usb_device_id jumpshot_usb_ids[] = {
75# include "unusual_jumpshot.h"
76 { } /* Terminating entry */
77};
78MODULE_DEVICE_TABLE(usb, jumpshot_usb_ids);
79
80#undef UNUSUAL_DEV
81
82/*
83 * The flags table
84 */
85#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
86 vendor_name, product_name, use_protocol, use_transport, \
87 init_function, Flags) \
88{ \
89 .vendorName = vendor_name, \
90 .productName = product_name, \
91 .useProtocol = use_protocol, \
92 .useTransport = use_transport, \
93 .initFunction = init_function, \
94}
95
96static struct us_unusual_dev jumpshot_unusual_dev_list[] = {
97# include "unusual_jumpshot.h"
98 { } /* Terminating entry */
99};
100
101#undef UNUSUAL_DEV
102
103
104struct jumpshot_info {
105 unsigned long sectors; /* total sector count */
106 unsigned long ssize; /* sector size in bytes */
107
108 /* the following aren't used yet */
109 unsigned char sense_key;
110 unsigned long sense_asc; /* additional sense code */
111 unsigned long sense_ascq; /* additional sense code qualifier */
112};
113
114static inline int jumpshot_bulk_read(struct us_data *us,
115 unsigned char *data,
116 unsigned int len)
117{
118 if (len == 0)
119 return USB_STOR_XFER_GOOD;
120
121 US_DEBUGP("jumpshot_bulk_read: len = %d\n", len);
122 return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
123 data, len, NULL);
124}
125
126
127static inline int jumpshot_bulk_write(struct us_data *us,
128 unsigned char *data,
129 unsigned int len)
130{
131 if (len == 0)
132 return USB_STOR_XFER_GOOD;
133
134 US_DEBUGP("jumpshot_bulk_write: len = %d\n", len);
135 return usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
136 data, len, NULL);
137}
138
139
140static int jumpshot_get_status(struct us_data *us)
141{
142 int rc;
143
144 if (!us)
145 return USB_STOR_TRANSPORT_ERROR;
146
147 // send the setup
148 rc = usb_stor_ctrl_transfer(us, us->recv_ctrl_pipe,
149 0, 0xA0, 0, 7, us->iobuf, 1);
150
151 if (rc != USB_STOR_XFER_GOOD)
152 return USB_STOR_TRANSPORT_ERROR;
153
154 if (us->iobuf[0] != 0x50) {
155 US_DEBUGP("jumpshot_get_status: 0x%2x\n",
156 us->iobuf[0]);
157 return USB_STOR_TRANSPORT_ERROR;
158 }
159
160 return USB_STOR_TRANSPORT_GOOD;
161}
162
163static int jumpshot_read_data(struct us_data *us,
164 struct jumpshot_info *info,
165 u32 sector,
166 u32 sectors)
167{
168 unsigned char *command = us->iobuf;
169 unsigned char *buffer;
170 unsigned char thistime;
171 unsigned int totallen, alloclen;
172 int len, result;
173 unsigned int sg_offset = 0;
174 struct scatterlist *sg = NULL;
175
176 // we're working in LBA mode. according to the ATA spec,
177 // we can support up to 28-bit addressing. I don't know if Jumpshot
178 // supports beyond 24-bit addressing. It's kind of hard to test
179 // since it requires > 8GB CF card.
180
181 if (sector > 0x0FFFFFFF)
182 return USB_STOR_TRANSPORT_ERROR;
183
184 totallen = sectors * info->ssize;
185
186 // Since we don't read more than 64 KB at a time, we have to create
187 // a bounce buffer and move the data a piece at a time between the
188 // bounce buffer and the actual transfer buffer.
189
190 alloclen = min(totallen, 65536u);
191 buffer = kmalloc(alloclen, GFP_NOIO);
192 if (buffer == NULL)
193 return USB_STOR_TRANSPORT_ERROR;
194
195 do {
196 // loop, never allocate or transfer more than 64k at once
197 // (min(128k, 255*info->ssize) is the real limit)
198 len = min(totallen, alloclen);
199 thistime = (len / info->ssize) & 0xff;
200
201 command[0] = 0;
202 command[1] = thistime;
203 command[2] = sector & 0xFF;
204 command[3] = (sector >> 8) & 0xFF;
205 command[4] = (sector >> 16) & 0xFF;
206
207 command[5] = 0xE0 | ((sector >> 24) & 0x0F);
208 command[6] = 0x20;
209
210 // send the setup + command
211 result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
212 0, 0x20, 0, 1, command, 7);
213 if (result != USB_STOR_XFER_GOOD)
214 goto leave;
215
216 // read the result
217 result = jumpshot_bulk_read(us, buffer, len);
218 if (result != USB_STOR_XFER_GOOD)
219 goto leave;
220
221 US_DEBUGP("jumpshot_read_data: %d bytes\n", len);
222
223 // Store the data in the transfer buffer
224 usb_stor_access_xfer_buf(buffer, len, us->srb,
225 &sg, &sg_offset, TO_XFER_BUF);
226
227 sector += thistime;
228 totallen -= len;
229 } while (totallen > 0);
230
231 kfree(buffer);
232 return USB_STOR_TRANSPORT_GOOD;
233
234 leave:
235 kfree(buffer);
236 return USB_STOR_TRANSPORT_ERROR;
237}
238
239
240static int jumpshot_write_data(struct us_data *us,
241 struct jumpshot_info *info,
242 u32 sector,
243 u32 sectors)
244{
245 unsigned char *command = us->iobuf;
246 unsigned char *buffer;
247 unsigned char thistime;
248 unsigned int totallen, alloclen;
249 int len, result, waitcount;
250 unsigned int sg_offset = 0;
251 struct scatterlist *sg = NULL;
252
253 // we're working in LBA mode. according to the ATA spec,
254 // we can support up to 28-bit addressing. I don't know if Jumpshot
255 // supports beyond 24-bit addressing. It's kind of hard to test
256 // since it requires > 8GB CF card.
257 //
258 if (sector > 0x0FFFFFFF)
259 return USB_STOR_TRANSPORT_ERROR;
260
261 totallen = sectors * info->ssize;
262
263 // Since we don't write more than 64 KB at a time, we have to create
264 // a bounce buffer and move the data a piece at a time between the
265 // bounce buffer and the actual transfer buffer.
266
267 alloclen = min(totallen, 65536u);
268 buffer = kmalloc(alloclen, GFP_NOIO);
269 if (buffer == NULL)
270 return USB_STOR_TRANSPORT_ERROR;
271
272 do {
273 // loop, never allocate or transfer more than 64k at once
274 // (min(128k, 255*info->ssize) is the real limit)
275
276 len = min(totallen, alloclen);
277 thistime = (len / info->ssize) & 0xff;
278
279 // Get the data from the transfer buffer
280 usb_stor_access_xfer_buf(buffer, len, us->srb,
281 &sg, &sg_offset, FROM_XFER_BUF);
282
283 command[0] = 0;
284 command[1] = thistime;
285 command[2] = sector & 0xFF;
286 command[3] = (sector >> 8) & 0xFF;
287 command[4] = (sector >> 16) & 0xFF;
288
289 command[5] = 0xE0 | ((sector >> 24) & 0x0F);
290 command[6] = 0x30;
291
292 // send the setup + command
293 result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
294 0, 0x20, 0, 1, command, 7);
295 if (result != USB_STOR_XFER_GOOD)
296 goto leave;
297
298 // send the data
299 result = jumpshot_bulk_write(us, buffer, len);
300 if (result != USB_STOR_XFER_GOOD)
301 goto leave;
302
303 // read the result. apparently the bulk write can complete
304 // before the jumpshot drive is finished writing. so we loop
305 // here until we get a good return code
306 waitcount = 0;
307 do {
308 result = jumpshot_get_status(us);
309 if (result != USB_STOR_TRANSPORT_GOOD) {
310 // I have not experimented to find the smallest value.
311 //
312 msleep(50);
313 }
314 } while ((result != USB_STOR_TRANSPORT_GOOD) && (waitcount < 10));
315
316 if (result != USB_STOR_TRANSPORT_GOOD)
317 US_DEBUGP("jumpshot_write_data: Gah! Waitcount = 10. Bad write!?\n");
318
319 sector += thistime;
320 totallen -= len;
321 } while (totallen > 0);
322
323 kfree(buffer);
324 return result;
325
326 leave:
327 kfree(buffer);
328 return USB_STOR_TRANSPORT_ERROR;
329}
330
331static int jumpshot_id_device(struct us_data *us,
332 struct jumpshot_info *info)
333{
334 unsigned char *command = us->iobuf;
335 unsigned char *reply;
336 int rc;
337
338 if (!info)
339 return USB_STOR_TRANSPORT_ERROR;
340
341 command[0] = 0xE0;
342 command[1] = 0xEC;
343 reply = kmalloc(512, GFP_NOIO);
344 if (!reply)
345 return USB_STOR_TRANSPORT_ERROR;
346
347 // send the setup
348 rc = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
349 0, 0x20, 0, 6, command, 2);
350
351 if (rc != USB_STOR_XFER_GOOD) {
352 US_DEBUGP("jumpshot_id_device: Gah! "
353 "send_control for read_capacity failed\n");
354 rc = USB_STOR_TRANSPORT_ERROR;
355 goto leave;
356 }
357
358 // read the reply
359 rc = jumpshot_bulk_read(us, reply, 512);
360 if (rc != USB_STOR_XFER_GOOD) {
361 rc = USB_STOR_TRANSPORT_ERROR;
362 goto leave;
363 }
364
365 info->sectors = ((u32)(reply[117]) << 24) |
366 ((u32)(reply[116]) << 16) |
367 ((u32)(reply[115]) << 8) |
368 ((u32)(reply[114]) );
369
370 rc = USB_STOR_TRANSPORT_GOOD;
371
372 leave:
373 kfree(reply);
374 return rc;
375}
376
377static int jumpshot_handle_mode_sense(struct us_data *us,
378 struct scsi_cmnd * srb,
379 int sense_6)
380{
381 static unsigned char rw_err_page[12] = {
382 0x1, 0xA, 0x21, 1, 0, 0, 0, 0, 1, 0, 0, 0
383 };
384 static unsigned char cache_page[12] = {
385 0x8, 0xA, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0
386 };
387 static unsigned char rbac_page[12] = {
388 0x1B, 0xA, 0, 0x81, 0, 0, 0, 0, 0, 0, 0, 0
389 };
390 static unsigned char timer_page[8] = {
391 0x1C, 0x6, 0, 0, 0, 0
392 };
393 unsigned char pc, page_code;
394 unsigned int i = 0;
395 struct jumpshot_info *info = (struct jumpshot_info *) (us->extra);
396 unsigned char *ptr = us->iobuf;
397
398 pc = srb->cmnd[2] >> 6;
399 page_code = srb->cmnd[2] & 0x3F;
400
401 switch (pc) {
402 case 0x0:
403 US_DEBUGP("jumpshot_handle_mode_sense: Current values\n");
404 break;
405 case 0x1:
406 US_DEBUGP("jumpshot_handle_mode_sense: Changeable values\n");
407 break;
408 case 0x2:
409 US_DEBUGP("jumpshot_handle_mode_sense: Default values\n");
410 break;
411 case 0x3:
412 US_DEBUGP("jumpshot_handle_mode_sense: Saves values\n");
413 break;
414 }
415
416 memset(ptr, 0, 8);
417 if (sense_6) {
418 ptr[2] = 0x00; // WP enable: 0x80
419 i = 4;
420 } else {
421 ptr[3] = 0x00; // WP enable: 0x80
422 i = 8;
423 }
424
425 switch (page_code) {
426 case 0x0:
427 // vendor-specific mode
428 info->sense_key = 0x05;
429 info->sense_asc = 0x24;
430 info->sense_ascq = 0x00;
431 return USB_STOR_TRANSPORT_FAILED;
432
433 case 0x1:
434 memcpy(ptr + i, rw_err_page, sizeof(rw_err_page));
435 i += sizeof(rw_err_page);
436 break;
437
438 case 0x8:
439 memcpy(ptr + i, cache_page, sizeof(cache_page));
440 i += sizeof(cache_page);
441 break;
442
443 case 0x1B:
444 memcpy(ptr + i, rbac_page, sizeof(rbac_page));
445 i += sizeof(rbac_page);
446 break;
447
448 case 0x1C:
449 memcpy(ptr + i, timer_page, sizeof(timer_page));
450 i += sizeof(timer_page);
451 break;
452
453 case 0x3F:
454 memcpy(ptr + i, timer_page, sizeof(timer_page));
455 i += sizeof(timer_page);
456 memcpy(ptr + i, rbac_page, sizeof(rbac_page));
457 i += sizeof(rbac_page);
458 memcpy(ptr + i, cache_page, sizeof(cache_page));
459 i += sizeof(cache_page);
460 memcpy(ptr + i, rw_err_page, sizeof(rw_err_page));
461 i += sizeof(rw_err_page);
462 break;
463 }
464
465 if (sense_6)
466 ptr[0] = i - 1;
467 else
468 ((__be16 *) ptr)[0] = cpu_to_be16(i - 2);
469 usb_stor_set_xfer_buf(ptr, i, srb);
470
471 return USB_STOR_TRANSPORT_GOOD;
472}
473
474
475static void jumpshot_info_destructor(void *extra)
476{
477 // this routine is a placeholder...
478 // currently, we don't allocate any extra blocks so we're okay
479}
480
481
482
483// Transport for the Lexar 'Jumpshot'
484//
485static int jumpshot_transport(struct scsi_cmnd *srb, struct us_data *us)
486{
487 struct jumpshot_info *info;
488 int rc;
489 unsigned long block, blocks;
490 unsigned char *ptr = us->iobuf;
491 static unsigned char inquiry_response[8] = {
492 0x00, 0x80, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x00
493 };
494
495 if (!us->extra) {
496 us->extra = kzalloc(sizeof(struct jumpshot_info), GFP_NOIO);
497 if (!us->extra) {
498 US_DEBUGP("jumpshot_transport: Gah! Can't allocate storage for jumpshot info struct!\n");
499 return USB_STOR_TRANSPORT_ERROR;
500 }
501 us->extra_destructor = jumpshot_info_destructor;
502 }
503
504 info = (struct jumpshot_info *) (us->extra);
505
506 if (srb->cmnd[0] == INQUIRY) {
507 US_DEBUGP("jumpshot_transport: INQUIRY. Returning bogus response.\n");
508 memcpy(ptr, inquiry_response, sizeof(inquiry_response));
509 fill_inquiry_response(us, ptr, 36);
510 return USB_STOR_TRANSPORT_GOOD;
511 }
512
513 if (srb->cmnd[0] == READ_CAPACITY) {
514 info->ssize = 0x200; // hard coded 512 byte sectors as per ATA spec
515
516 rc = jumpshot_get_status(us);
517 if (rc != USB_STOR_TRANSPORT_GOOD)
518 return rc;
519
520 rc = jumpshot_id_device(us, info);
521 if (rc != USB_STOR_TRANSPORT_GOOD)
522 return rc;
523
524 US_DEBUGP("jumpshot_transport: READ_CAPACITY: %ld sectors, %ld bytes per sector\n",
525 info->sectors, info->ssize);
526
527 // build the reply
528 //
529 ((__be32 *) ptr)[0] = cpu_to_be32(info->sectors - 1);
530 ((__be32 *) ptr)[1] = cpu_to_be32(info->ssize);
531 usb_stor_set_xfer_buf(ptr, 8, srb);
532
533 return USB_STOR_TRANSPORT_GOOD;
534 }
535
536 if (srb->cmnd[0] == MODE_SELECT_10) {
537 US_DEBUGP("jumpshot_transport: Gah! MODE_SELECT_10.\n");
538 return USB_STOR_TRANSPORT_ERROR;
539 }
540
541 if (srb->cmnd[0] == READ_10) {
542 block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
543 ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5]));
544
545 blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
546
547 US_DEBUGP("jumpshot_transport: READ_10: read block 0x%04lx count %ld\n", block, blocks);
548 return jumpshot_read_data(us, info, block, blocks);
549 }
550
551 if (srb->cmnd[0] == READ_12) {
552 // I don't think we'll ever see a READ_12 but support it anyway...
553 //
554 block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
555 ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5]));
556
557 blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) |
558 ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9]));
559
560 US_DEBUGP("jumpshot_transport: READ_12: read block 0x%04lx count %ld\n", block, blocks);
561 return jumpshot_read_data(us, info, block, blocks);
562 }
563
564 if (srb->cmnd[0] == WRITE_10) {
565 block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
566 ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5]));
567
568 blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
569
570 US_DEBUGP("jumpshot_transport: WRITE_10: write block 0x%04lx count %ld\n", block, blocks);
571 return jumpshot_write_data(us, info, block, blocks);
572 }
573
574 if (srb->cmnd[0] == WRITE_12) {
575 // I don't think we'll ever see a WRITE_12 but support it anyway...
576 //
577 block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
578 ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5]));
579
580 blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) |
581 ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9]));
582
583 US_DEBUGP("jumpshot_transport: WRITE_12: write block 0x%04lx count %ld\n", block, blocks);
584 return jumpshot_write_data(us, info, block, blocks);
585 }
586
587
588 if (srb->cmnd[0] == TEST_UNIT_READY) {
589 US_DEBUGP("jumpshot_transport: TEST_UNIT_READY.\n");
590 return jumpshot_get_status(us);
591 }
592
593 if (srb->cmnd[0] == REQUEST_SENSE) {
594 US_DEBUGP("jumpshot_transport: REQUEST_SENSE.\n");
595
596 memset(ptr, 0, 18);
597 ptr[0] = 0xF0;
598 ptr[2] = info->sense_key;
599 ptr[7] = 11;
600 ptr[12] = info->sense_asc;
601 ptr[13] = info->sense_ascq;
602 usb_stor_set_xfer_buf(ptr, 18, srb);
603
604 return USB_STOR_TRANSPORT_GOOD;
605 }
606
607 if (srb->cmnd[0] == MODE_SENSE) {
608 US_DEBUGP("jumpshot_transport: MODE_SENSE_6 detected\n");
609 return jumpshot_handle_mode_sense(us, srb, 1);
610 }
611
612 if (srb->cmnd[0] == MODE_SENSE_10) {
613 US_DEBUGP("jumpshot_transport: MODE_SENSE_10 detected\n");
614 return jumpshot_handle_mode_sense(us, srb, 0);
615 }
616
617 if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) {
618 // sure. whatever. not like we can stop the user from popping
619 // the media out of the device (no locking doors, etc)
620 //
621 return USB_STOR_TRANSPORT_GOOD;
622 }
623
624 if (srb->cmnd[0] == START_STOP) {
625 /* this is used by sd.c'check_scsidisk_media_change to detect
626 media change */
627 US_DEBUGP("jumpshot_transport: START_STOP.\n");
628 /* the first jumpshot_id_device after a media change returns
629 an error (determined experimentally) */
630 rc = jumpshot_id_device(us, info);
631 if (rc == USB_STOR_TRANSPORT_GOOD) {
632 info->sense_key = NO_SENSE;
633 srb->result = SUCCESS;
634 } else {
635 info->sense_key = UNIT_ATTENTION;
636 srb->result = SAM_STAT_CHECK_CONDITION;
637 }
638 return rc;
639 }
640
641 US_DEBUGP("jumpshot_transport: Gah! Unknown command: %d (0x%x)\n",
642 srb->cmnd[0], srb->cmnd[0]);
643 info->sense_key = 0x05;
644 info->sense_asc = 0x20;
645 info->sense_ascq = 0x00;
646 return USB_STOR_TRANSPORT_FAILED;
647}
648
649static int jumpshot_probe(struct usb_interface *intf,
650 const struct usb_device_id *id)
651{
652 struct us_data *us;
653 int result;
654
655 result = usb_stor_probe1(&us, intf, id,
656 (id - jumpshot_usb_ids) + jumpshot_unusual_dev_list);
657 if (result)
658 return result;
659
660 us->transport_name = "Lexar Jumpshot Control/Bulk";
661 us->transport = jumpshot_transport;
662 us->transport_reset = usb_stor_Bulk_reset;
663 us->max_lun = 1;
664
665 result = usb_stor_probe2(us);
666 return result;
667}
668
669static struct usb_driver jumpshot_driver = {
670 .name = "ums-jumpshot",
671 .probe = jumpshot_probe,
672 .disconnect = usb_stor_disconnect,
673 .suspend = usb_stor_suspend,
674 .resume = usb_stor_resume,
675 .reset_resume = usb_stor_reset_resume,
676 .pre_reset = usb_stor_pre_reset,
677 .post_reset = usb_stor_post_reset,
678 .id_table = jumpshot_usb_ids,
679 .soft_unbind = 1,
680};
681
682static int __init jumpshot_init(void)
683{
684 return usb_register(&jumpshot_driver);
685}
686
687static void __exit jumpshot_exit(void)
688{
689 usb_deregister(&jumpshot_driver);
690}
691
692module_init(jumpshot_init);
693module_exit(jumpshot_exit);
1/*
2 * Driver for Lexar "Jumpshot" Compact Flash reader
3 *
4 * jumpshot driver v0.1:
5 *
6 * First release
7 *
8 * Current development and maintenance by:
9 * (c) 2000 Jimmie Mayfield (mayfield+usb@sackheads.org)
10 *
11 * Many thanks to Robert Baruch for the SanDisk SmartMedia reader driver
12 * which I used as a template for this driver.
13 *
14 * Some bugfixes and scatter-gather code by Gregory P. Smith
15 * (greg-usb@electricrain.com)
16 *
17 * Fix for media change by Joerg Schneider (js@joergschneider.com)
18 *
19 * Developed with the assistance of:
20 *
21 * (C) 2002 Alan Stern <stern@rowland.org>
22 *
23 * This program is free software; you can redistribute it and/or modify it
24 * under the terms of the GNU General Public License as published by the
25 * Free Software Foundation; either version 2, or (at your option) any
26 * later version.
27 *
28 * This program is distributed in the hope that it will be useful, but
29 * WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 * General Public License for more details.
32 *
33 * You should have received a copy of the GNU General Public License along
34 * with this program; if not, write to the Free Software Foundation, Inc.,
35 * 675 Mass Ave, Cambridge, MA 02139, USA.
36 */
37
38 /*
39 * This driver attempts to support the Lexar Jumpshot USB CompactFlash
40 * reader. Like many other USB CompactFlash readers, the Jumpshot contains
41 * a USB-to-ATA chip.
42 *
43 * This driver supports reading and writing. If you're truly paranoid,
44 * however, you can force the driver into a write-protected state by setting
45 * the WP enable bits in jumpshot_handle_mode_sense. See the comments
46 * in that routine.
47 */
48
49#include <linux/errno.h>
50#include <linux/module.h>
51#include <linux/slab.h>
52
53#include <scsi/scsi.h>
54#include <scsi/scsi_cmnd.h>
55
56#include "usb.h"
57#include "transport.h"
58#include "protocol.h"
59#include "debug.h"
60#include "scsiglue.h"
61
62#define DRV_NAME "ums-jumpshot"
63
64MODULE_DESCRIPTION("Driver for Lexar \"Jumpshot\" Compact Flash reader");
65MODULE_AUTHOR("Jimmie Mayfield <mayfield+usb@sackheads.org>");
66MODULE_LICENSE("GPL");
67
68/*
69 * The table of devices
70 */
71#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
72 vendorName, productName, useProtocol, useTransport, \
73 initFunction, flags) \
74{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
75 .driver_info = (flags) }
76
77static struct usb_device_id jumpshot_usb_ids[] = {
78# include "unusual_jumpshot.h"
79 { } /* Terminating entry */
80};
81MODULE_DEVICE_TABLE(usb, jumpshot_usb_ids);
82
83#undef UNUSUAL_DEV
84
85/*
86 * The flags table
87 */
88#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
89 vendor_name, product_name, use_protocol, use_transport, \
90 init_function, Flags) \
91{ \
92 .vendorName = vendor_name, \
93 .productName = product_name, \
94 .useProtocol = use_protocol, \
95 .useTransport = use_transport, \
96 .initFunction = init_function, \
97}
98
99static struct us_unusual_dev jumpshot_unusual_dev_list[] = {
100# include "unusual_jumpshot.h"
101 { } /* Terminating entry */
102};
103
104#undef UNUSUAL_DEV
105
106
107struct jumpshot_info {
108 unsigned long sectors; /* total sector count */
109 unsigned long ssize; /* sector size in bytes */
110
111 /* the following aren't used yet */
112 unsigned char sense_key;
113 unsigned long sense_asc; /* additional sense code */
114 unsigned long sense_ascq; /* additional sense code qualifier */
115};
116
117static inline int jumpshot_bulk_read(struct us_data *us,
118 unsigned char *data,
119 unsigned int len)
120{
121 if (len == 0)
122 return USB_STOR_XFER_GOOD;
123
124 usb_stor_dbg(us, "len = %d\n", len);
125 return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
126 data, len, NULL);
127}
128
129
130static inline int jumpshot_bulk_write(struct us_data *us,
131 unsigned char *data,
132 unsigned int len)
133{
134 if (len == 0)
135 return USB_STOR_XFER_GOOD;
136
137 usb_stor_dbg(us, "len = %d\n", len);
138 return usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
139 data, len, NULL);
140}
141
142
143static int jumpshot_get_status(struct us_data *us)
144{
145 int rc;
146
147 if (!us)
148 return USB_STOR_TRANSPORT_ERROR;
149
150 // send the setup
151 rc = usb_stor_ctrl_transfer(us, us->recv_ctrl_pipe,
152 0, 0xA0, 0, 7, us->iobuf, 1);
153
154 if (rc != USB_STOR_XFER_GOOD)
155 return USB_STOR_TRANSPORT_ERROR;
156
157 if (us->iobuf[0] != 0x50) {
158 usb_stor_dbg(us, "0x%2x\n", us->iobuf[0]);
159 return USB_STOR_TRANSPORT_ERROR;
160 }
161
162 return USB_STOR_TRANSPORT_GOOD;
163}
164
165static int jumpshot_read_data(struct us_data *us,
166 struct jumpshot_info *info,
167 u32 sector,
168 u32 sectors)
169{
170 unsigned char *command = us->iobuf;
171 unsigned char *buffer;
172 unsigned char thistime;
173 unsigned int totallen, alloclen;
174 int len, result;
175 unsigned int sg_offset = 0;
176 struct scatterlist *sg = NULL;
177
178 // we're working in LBA mode. according to the ATA spec,
179 // we can support up to 28-bit addressing. I don't know if Jumpshot
180 // supports beyond 24-bit addressing. It's kind of hard to test
181 // since it requires > 8GB CF card.
182
183 if (sector > 0x0FFFFFFF)
184 return USB_STOR_TRANSPORT_ERROR;
185
186 totallen = sectors * info->ssize;
187
188 // Since we don't read more than 64 KB at a time, we have to create
189 // a bounce buffer and move the data a piece at a time between the
190 // bounce buffer and the actual transfer buffer.
191
192 alloclen = min(totallen, 65536u);
193 buffer = kmalloc(alloclen, GFP_NOIO);
194 if (buffer == NULL)
195 return USB_STOR_TRANSPORT_ERROR;
196
197 do {
198 // loop, never allocate or transfer more than 64k at once
199 // (min(128k, 255*info->ssize) is the real limit)
200 len = min(totallen, alloclen);
201 thistime = (len / info->ssize) & 0xff;
202
203 command[0] = 0;
204 command[1] = thistime;
205 command[2] = sector & 0xFF;
206 command[3] = (sector >> 8) & 0xFF;
207 command[4] = (sector >> 16) & 0xFF;
208
209 command[5] = 0xE0 | ((sector >> 24) & 0x0F);
210 command[6] = 0x20;
211
212 // send the setup + command
213 result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
214 0, 0x20, 0, 1, command, 7);
215 if (result != USB_STOR_XFER_GOOD)
216 goto leave;
217
218 // read the result
219 result = jumpshot_bulk_read(us, buffer, len);
220 if (result != USB_STOR_XFER_GOOD)
221 goto leave;
222
223 usb_stor_dbg(us, "%d bytes\n", len);
224
225 // Store the data in the transfer buffer
226 usb_stor_access_xfer_buf(buffer, len, us->srb,
227 &sg, &sg_offset, TO_XFER_BUF);
228
229 sector += thistime;
230 totallen -= len;
231 } while (totallen > 0);
232
233 kfree(buffer);
234 return USB_STOR_TRANSPORT_GOOD;
235
236 leave:
237 kfree(buffer);
238 return USB_STOR_TRANSPORT_ERROR;
239}
240
241
242static int jumpshot_write_data(struct us_data *us,
243 struct jumpshot_info *info,
244 u32 sector,
245 u32 sectors)
246{
247 unsigned char *command = us->iobuf;
248 unsigned char *buffer;
249 unsigned char thistime;
250 unsigned int totallen, alloclen;
251 int len, result, waitcount;
252 unsigned int sg_offset = 0;
253 struct scatterlist *sg = NULL;
254
255 // we're working in LBA mode. according to the ATA spec,
256 // we can support up to 28-bit addressing. I don't know if Jumpshot
257 // supports beyond 24-bit addressing. It's kind of hard to test
258 // since it requires > 8GB CF card.
259 //
260 if (sector > 0x0FFFFFFF)
261 return USB_STOR_TRANSPORT_ERROR;
262
263 totallen = sectors * info->ssize;
264
265 // Since we don't write more than 64 KB at a time, we have to create
266 // a bounce buffer and move the data a piece at a time between the
267 // bounce buffer and the actual transfer buffer.
268
269 alloclen = min(totallen, 65536u);
270 buffer = kmalloc(alloclen, GFP_NOIO);
271 if (buffer == NULL)
272 return USB_STOR_TRANSPORT_ERROR;
273
274 do {
275 // loop, never allocate or transfer more than 64k at once
276 // (min(128k, 255*info->ssize) is the real limit)
277
278 len = min(totallen, alloclen);
279 thistime = (len / info->ssize) & 0xff;
280
281 // Get the data from the transfer buffer
282 usb_stor_access_xfer_buf(buffer, len, us->srb,
283 &sg, &sg_offset, FROM_XFER_BUF);
284
285 command[0] = 0;
286 command[1] = thistime;
287 command[2] = sector & 0xFF;
288 command[3] = (sector >> 8) & 0xFF;
289 command[4] = (sector >> 16) & 0xFF;
290
291 command[5] = 0xE0 | ((sector >> 24) & 0x0F);
292 command[6] = 0x30;
293
294 // send the setup + command
295 result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
296 0, 0x20, 0, 1, command, 7);
297 if (result != USB_STOR_XFER_GOOD)
298 goto leave;
299
300 // send the data
301 result = jumpshot_bulk_write(us, buffer, len);
302 if (result != USB_STOR_XFER_GOOD)
303 goto leave;
304
305 // read the result. apparently the bulk write can complete
306 // before the jumpshot drive is finished writing. so we loop
307 // here until we get a good return code
308 waitcount = 0;
309 do {
310 result = jumpshot_get_status(us);
311 if (result != USB_STOR_TRANSPORT_GOOD) {
312 // I have not experimented to find the smallest value.
313 //
314 msleep(50);
315 }
316 } while ((result != USB_STOR_TRANSPORT_GOOD) && (waitcount < 10));
317
318 if (result != USB_STOR_TRANSPORT_GOOD)
319 usb_stor_dbg(us, "Gah! Waitcount = 10. Bad write!?\n");
320
321 sector += thistime;
322 totallen -= len;
323 } while (totallen > 0);
324
325 kfree(buffer);
326 return result;
327
328 leave:
329 kfree(buffer);
330 return USB_STOR_TRANSPORT_ERROR;
331}
332
333static int jumpshot_id_device(struct us_data *us,
334 struct jumpshot_info *info)
335{
336 unsigned char *command = us->iobuf;
337 unsigned char *reply;
338 int rc;
339
340 if (!info)
341 return USB_STOR_TRANSPORT_ERROR;
342
343 command[0] = 0xE0;
344 command[1] = 0xEC;
345 reply = kmalloc(512, GFP_NOIO);
346 if (!reply)
347 return USB_STOR_TRANSPORT_ERROR;
348
349 // send the setup
350 rc = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
351 0, 0x20, 0, 6, command, 2);
352
353 if (rc != USB_STOR_XFER_GOOD) {
354 usb_stor_dbg(us, "Gah! send_control for read_capacity failed\n");
355 rc = USB_STOR_TRANSPORT_ERROR;
356 goto leave;
357 }
358
359 // read the reply
360 rc = jumpshot_bulk_read(us, reply, 512);
361 if (rc != USB_STOR_XFER_GOOD) {
362 rc = USB_STOR_TRANSPORT_ERROR;
363 goto leave;
364 }
365
366 info->sectors = ((u32)(reply[117]) << 24) |
367 ((u32)(reply[116]) << 16) |
368 ((u32)(reply[115]) << 8) |
369 ((u32)(reply[114]) );
370
371 rc = USB_STOR_TRANSPORT_GOOD;
372
373 leave:
374 kfree(reply);
375 return rc;
376}
377
378static int jumpshot_handle_mode_sense(struct us_data *us,
379 struct scsi_cmnd * srb,
380 int sense_6)
381{
382 static unsigned char rw_err_page[12] = {
383 0x1, 0xA, 0x21, 1, 0, 0, 0, 0, 1, 0, 0, 0
384 };
385 static unsigned char cache_page[12] = {
386 0x8, 0xA, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0
387 };
388 static unsigned char rbac_page[12] = {
389 0x1B, 0xA, 0, 0x81, 0, 0, 0, 0, 0, 0, 0, 0
390 };
391 static unsigned char timer_page[8] = {
392 0x1C, 0x6, 0, 0, 0, 0
393 };
394 unsigned char pc, page_code;
395 unsigned int i = 0;
396 struct jumpshot_info *info = (struct jumpshot_info *) (us->extra);
397 unsigned char *ptr = us->iobuf;
398
399 pc = srb->cmnd[2] >> 6;
400 page_code = srb->cmnd[2] & 0x3F;
401
402 switch (pc) {
403 case 0x0:
404 usb_stor_dbg(us, "Current values\n");
405 break;
406 case 0x1:
407 usb_stor_dbg(us, "Changeable values\n");
408 break;
409 case 0x2:
410 usb_stor_dbg(us, "Default values\n");
411 break;
412 case 0x3:
413 usb_stor_dbg(us, "Saves values\n");
414 break;
415 }
416
417 memset(ptr, 0, 8);
418 if (sense_6) {
419 ptr[2] = 0x00; // WP enable: 0x80
420 i = 4;
421 } else {
422 ptr[3] = 0x00; // WP enable: 0x80
423 i = 8;
424 }
425
426 switch (page_code) {
427 case 0x0:
428 // vendor-specific mode
429 info->sense_key = 0x05;
430 info->sense_asc = 0x24;
431 info->sense_ascq = 0x00;
432 return USB_STOR_TRANSPORT_FAILED;
433
434 case 0x1:
435 memcpy(ptr + i, rw_err_page, sizeof(rw_err_page));
436 i += sizeof(rw_err_page);
437 break;
438
439 case 0x8:
440 memcpy(ptr + i, cache_page, sizeof(cache_page));
441 i += sizeof(cache_page);
442 break;
443
444 case 0x1B:
445 memcpy(ptr + i, rbac_page, sizeof(rbac_page));
446 i += sizeof(rbac_page);
447 break;
448
449 case 0x1C:
450 memcpy(ptr + i, timer_page, sizeof(timer_page));
451 i += sizeof(timer_page);
452 break;
453
454 case 0x3F:
455 memcpy(ptr + i, timer_page, sizeof(timer_page));
456 i += sizeof(timer_page);
457 memcpy(ptr + i, rbac_page, sizeof(rbac_page));
458 i += sizeof(rbac_page);
459 memcpy(ptr + i, cache_page, sizeof(cache_page));
460 i += sizeof(cache_page);
461 memcpy(ptr + i, rw_err_page, sizeof(rw_err_page));
462 i += sizeof(rw_err_page);
463 break;
464 }
465
466 if (sense_6)
467 ptr[0] = i - 1;
468 else
469 ((__be16 *) ptr)[0] = cpu_to_be16(i - 2);
470 usb_stor_set_xfer_buf(ptr, i, srb);
471
472 return USB_STOR_TRANSPORT_GOOD;
473}
474
475
476static void jumpshot_info_destructor(void *extra)
477{
478 // this routine is a placeholder...
479 // currently, we don't allocate any extra blocks so we're okay
480}
481
482
483
484// Transport for the Lexar 'Jumpshot'
485//
486static int jumpshot_transport(struct scsi_cmnd *srb, struct us_data *us)
487{
488 struct jumpshot_info *info;
489 int rc;
490 unsigned long block, blocks;
491 unsigned char *ptr = us->iobuf;
492 static unsigned char inquiry_response[8] = {
493 0x00, 0x80, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x00
494 };
495
496 if (!us->extra) {
497 us->extra = kzalloc(sizeof(struct jumpshot_info), GFP_NOIO);
498 if (!us->extra)
499 return USB_STOR_TRANSPORT_ERROR;
500
501 us->extra_destructor = jumpshot_info_destructor;
502 }
503
504 info = (struct jumpshot_info *) (us->extra);
505
506 if (srb->cmnd[0] == INQUIRY) {
507 usb_stor_dbg(us, "INQUIRY - Returning bogus response\n");
508 memcpy(ptr, inquiry_response, sizeof(inquiry_response));
509 fill_inquiry_response(us, ptr, 36);
510 return USB_STOR_TRANSPORT_GOOD;
511 }
512
513 if (srb->cmnd[0] == READ_CAPACITY) {
514 info->ssize = 0x200; // hard coded 512 byte sectors as per ATA spec
515
516 rc = jumpshot_get_status(us);
517 if (rc != USB_STOR_TRANSPORT_GOOD)
518 return rc;
519
520 rc = jumpshot_id_device(us, info);
521 if (rc != USB_STOR_TRANSPORT_GOOD)
522 return rc;
523
524 usb_stor_dbg(us, "READ_CAPACITY: %ld sectors, %ld bytes per sector\n",
525 info->sectors, info->ssize);
526
527 // build the reply
528 //
529 ((__be32 *) ptr)[0] = cpu_to_be32(info->sectors - 1);
530 ((__be32 *) ptr)[1] = cpu_to_be32(info->ssize);
531 usb_stor_set_xfer_buf(ptr, 8, srb);
532
533 return USB_STOR_TRANSPORT_GOOD;
534 }
535
536 if (srb->cmnd[0] == MODE_SELECT_10) {
537 usb_stor_dbg(us, "Gah! MODE_SELECT_10\n");
538 return USB_STOR_TRANSPORT_ERROR;
539 }
540
541 if (srb->cmnd[0] == READ_10) {
542 block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
543 ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5]));
544
545 blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
546
547 usb_stor_dbg(us, "READ_10: read block 0x%04lx count %ld\n",
548 block, blocks);
549 return jumpshot_read_data(us, info, block, blocks);
550 }
551
552 if (srb->cmnd[0] == READ_12) {
553 // I don't think we'll ever see a READ_12 but support it anyway...
554 //
555 block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
556 ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5]));
557
558 blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) |
559 ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9]));
560
561 usb_stor_dbg(us, "READ_12: read block 0x%04lx count %ld\n",
562 block, blocks);
563 return jumpshot_read_data(us, info, block, blocks);
564 }
565
566 if (srb->cmnd[0] == WRITE_10) {
567 block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
568 ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5]));
569
570 blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
571
572 usb_stor_dbg(us, "WRITE_10: write block 0x%04lx count %ld\n",
573 block, blocks);
574 return jumpshot_write_data(us, info, block, blocks);
575 }
576
577 if (srb->cmnd[0] == WRITE_12) {
578 // I don't think we'll ever see a WRITE_12 but support it anyway...
579 //
580 block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
581 ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5]));
582
583 blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) |
584 ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9]));
585
586 usb_stor_dbg(us, "WRITE_12: write block 0x%04lx count %ld\n",
587 block, blocks);
588 return jumpshot_write_data(us, info, block, blocks);
589 }
590
591
592 if (srb->cmnd[0] == TEST_UNIT_READY) {
593 usb_stor_dbg(us, "TEST_UNIT_READY\n");
594 return jumpshot_get_status(us);
595 }
596
597 if (srb->cmnd[0] == REQUEST_SENSE) {
598 usb_stor_dbg(us, "REQUEST_SENSE\n");
599
600 memset(ptr, 0, 18);
601 ptr[0] = 0xF0;
602 ptr[2] = info->sense_key;
603 ptr[7] = 11;
604 ptr[12] = info->sense_asc;
605 ptr[13] = info->sense_ascq;
606 usb_stor_set_xfer_buf(ptr, 18, srb);
607
608 return USB_STOR_TRANSPORT_GOOD;
609 }
610
611 if (srb->cmnd[0] == MODE_SENSE) {
612 usb_stor_dbg(us, "MODE_SENSE_6 detected\n");
613 return jumpshot_handle_mode_sense(us, srb, 1);
614 }
615
616 if (srb->cmnd[0] == MODE_SENSE_10) {
617 usb_stor_dbg(us, "MODE_SENSE_10 detected\n");
618 return jumpshot_handle_mode_sense(us, srb, 0);
619 }
620
621 if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) {
622 /*
623 * sure. whatever. not like we can stop the user from popping
624 * the media out of the device (no locking doors, etc)
625 */
626 return USB_STOR_TRANSPORT_GOOD;
627 }
628
629 if (srb->cmnd[0] == START_STOP) {
630 /*
631 * this is used by sd.c'check_scsidisk_media_change to detect
632 * media change
633 */
634 usb_stor_dbg(us, "START_STOP\n");
635 /*
636 * the first jumpshot_id_device after a media change returns
637 * an error (determined experimentally)
638 */
639 rc = jumpshot_id_device(us, info);
640 if (rc == USB_STOR_TRANSPORT_GOOD) {
641 info->sense_key = NO_SENSE;
642 srb->result = SUCCESS;
643 } else {
644 info->sense_key = UNIT_ATTENTION;
645 srb->result = SAM_STAT_CHECK_CONDITION;
646 }
647 return rc;
648 }
649
650 usb_stor_dbg(us, "Gah! Unknown command: %d (0x%x)\n",
651 srb->cmnd[0], srb->cmnd[0]);
652 info->sense_key = 0x05;
653 info->sense_asc = 0x20;
654 info->sense_ascq = 0x00;
655 return USB_STOR_TRANSPORT_FAILED;
656}
657
658static struct scsi_host_template jumpshot_host_template;
659
660static int jumpshot_probe(struct usb_interface *intf,
661 const struct usb_device_id *id)
662{
663 struct us_data *us;
664 int result;
665
666 result = usb_stor_probe1(&us, intf, id,
667 (id - jumpshot_usb_ids) + jumpshot_unusual_dev_list,
668 &jumpshot_host_template);
669 if (result)
670 return result;
671
672 us->transport_name = "Lexar Jumpshot Control/Bulk";
673 us->transport = jumpshot_transport;
674 us->transport_reset = usb_stor_Bulk_reset;
675 us->max_lun = 1;
676
677 result = usb_stor_probe2(us);
678 return result;
679}
680
681static struct usb_driver jumpshot_driver = {
682 .name = DRV_NAME,
683 .probe = jumpshot_probe,
684 .disconnect = usb_stor_disconnect,
685 .suspend = usb_stor_suspend,
686 .resume = usb_stor_resume,
687 .reset_resume = usb_stor_reset_resume,
688 .pre_reset = usb_stor_pre_reset,
689 .post_reset = usb_stor_post_reset,
690 .id_table = jumpshot_usb_ids,
691 .soft_unbind = 1,
692 .no_dynamic_id = 1,
693};
694
695module_usb_stor_driver(jumpshot_driver, jumpshot_host_template, DRV_NAME);