1 /* Driver for Lexar "Jumpshot" Compact Flash reader
3 * $Id: jumpshot.c,v 1.7 2002/02/25 00:40:13 mdharm Exp $
5 * jumpshot driver v0.1:
9 * Current development and maintenance by:
10 * (c) 2000 Jimmie Mayfield (mayfield+usb@sackheads.org)
12 * Many thanks to Robert Baruch for the SanDisk SmartMedia reader driver
13 * which I used as a template for this driver.
15 * Some bugfixes and scatter-gather code by Gregory P. Smith
16 * (greg-usb@electricrain.com)
18 * Fix for media change by Joerg Schneider (js@joergschneider.com)
20 * Developed with the assistance of:
22 * (C) 2002 Alan Stern <stern@rowland.org>
24 * This program is free software; you can redistribute it and/or modify it
25 * under the terms of the GNU General Public License as published by the
26 * Free Software Foundation; either version 2, or (at your option) any
29 * This program is distributed in the hope that it will be useful, but
30 * WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32 * General Public License for more details.
34 * You should have received a copy of the GNU General Public License along
35 * with this program; if not, write to the Free Software Foundation, Inc.,
36 * 675 Mass Ave, Cambridge, MA 02139, USA.
40 * This driver attempts to support the Lexar Jumpshot USB CompactFlash
41 * reader. Like many other USB CompactFlash readers, the Jumpshot contains
44 * This driver supports reading and writing. If you're truly paranoid,
45 * however, you can force the driver into a write-protected state by setting
46 * the WP enable bits in jumpshot_handle_mode_sense. Basically this means
47 * setting mode_param_header[3] = 0x80.
50 #include "transport.h"
56 #include <linux/sched.h>
57 #include <linux/errno.h>
58 #include <linux/slab.h>
60 extern int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
61 u8 request, u8 requesttype, u16 value,
62 u16 index, void *data, u16 size);
63 extern int usb_stor_bulk_msg(struct us_data *us, void *data, int pipe,
64 unsigned int len, unsigned int *act_len);
67 static void jumpshot_dump_data(unsigned char *data, int len)
69 unsigned char buf[80];
75 memset(buf, 0, sizeof(buf));
77 for (sofar = 0; sofar < len; sofar++) {
78 sprintf(buf + strlen(buf), "%02x ",
79 ((unsigned int) data[sofar]) & 0xFF);
81 if (sofar % 16 == 15) {
82 US_DEBUGP("jumpshot: %s\n", buf);
83 memset(buf, 0, sizeof(buf));
88 US_DEBUGP("jumpshot: %s\n", buf);
93 * Send a control message and wait for the response.
95 * us - the pointer to the us_data structure for the device to use
97 * request - the URB Setup Packet's first 6 bytes. The first byte always
98 * corresponds to the request type, and the second byte always corresponds
99 * to the request. The other 4 bytes do not correspond to value and index,
100 * since they are used in a custom way by the SCM protocol.
102 * xfer_data - a buffer from which to get, or to which to store, any data
103 * that gets send or received, respectively, with the URB. Even though
104 * it looks like we allocate a buffer in this code for the data, xfer_data
105 * must contain enough allocated space.
107 * xfer_len - the number of bytes to send or receive with the URB.
109 * This routine snarfed from the SanDisk SDDR-09 driver
112 static int jumpshot_send_control(struct us_data *us,
114 unsigned char request,
115 unsigned char requesttype,
116 unsigned short value,
117 unsigned short index,
118 unsigned char *xfer_data,
119 unsigned int xfer_len)
123 // Send the URB to the device and wait for a response.
125 /* Why are request and request type reversed in this call? */
127 result = usb_stor_control_msg(us, pipe,
128 request, requesttype,
129 value, index, xfer_data, xfer_len);
131 // Check the return code for the command.
134 /* if the command was aborted, indicate that */
135 if (result == -ECONNRESET)
136 return USB_STOR_TRANSPORT_ABORTED;
138 /* a stall is a fatal condition from the device */
139 if (result == -EPIPE) {
140 US_DEBUGP("jumpshot_send_control: -- Stall on control pipe. Clearing\n");
141 result = usb_stor_clear_halt(us, pipe);
142 US_DEBUGP("jumpshot_send_control: -- usb_stor_clear_halt() returns %d\n", result);
143 return USB_STOR_TRANSPORT_FAILED;
146 /* Uh oh... serious problem here */
147 return USB_STOR_TRANSPORT_ERROR;
150 return USB_STOR_TRANSPORT_GOOD;
154 static int jumpshot_raw_bulk(int direction,
163 if (direction == SCSI_DATA_READ)
164 pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in);
166 pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out);
168 result = usb_stor_bulk_msg(us, data, pipe, len, &act_len);
170 // if we stall, we need to clear it before we go on
171 if (result == -EPIPE) {
172 US_DEBUGP("jumpshot_raw_bulk: EPIPE. clearing endpoint halt for"
173 " pipe 0x%x, stalled at %d bytes\n", pipe, act_len);
174 usb_stor_clear_halt(us, pipe);
178 // NAK - that means we've retried a few times already
179 if (result == -ETIMEDOUT) {
180 US_DEBUGP("jumpshot_raw_bulk: device NAKed\n");
181 return US_BULK_TRANSFER_FAILED;
184 // -ECONNRESET -- we canceled this transfer
185 if (result == -ECONNRESET) {
186 US_DEBUGP("jumpshot_raw_bulk: transfer aborted\n");
187 return US_BULK_TRANSFER_ABORTED;
190 if (result == -EPIPE) {
191 US_DEBUGP("jumpshot_raw_bulk: output pipe stalled\n");
192 return USB_STOR_TRANSPORT_FAILED;
195 // the catch-all case
196 US_DEBUGP("jumpshot_raw_bulk: unknown error\n");
197 return US_BULK_TRANSFER_FAILED;
200 if (act_len != len) {
201 US_DEBUGP("jumpshot_raw_bulk: Warning. Transferred only %d bytes\n", act_len);
202 return US_BULK_TRANSFER_SHORT;
205 US_DEBUGP("jumpshot_raw_bulk: Transfered %d of %d bytes\n", act_len, len);
206 return US_BULK_TRANSFER_GOOD;
209 static inline int jumpshot_bulk_read(struct us_data *us,
214 return USB_STOR_TRANSPORT_GOOD;
216 US_DEBUGP("jumpshot_bulk_read: len = %d\n", len);
217 return jumpshot_raw_bulk(SCSI_DATA_READ, us, data, len);
221 static inline int jumpshot_bulk_write(struct us_data *us,
226 return USB_STOR_TRANSPORT_GOOD;
228 US_DEBUGP("jumpshot_bulk_write: len = %d\n", len);
229 return jumpshot_raw_bulk(SCSI_DATA_WRITE, us, data, len);
233 static int jumpshot_get_status(struct us_data *us)
239 return USB_STOR_TRANSPORT_ERROR;
242 rc = jumpshot_send_control(us,
243 usb_rcvctrlpipe(us->pusb_dev, 0),
244 0, 0xA0, 0, 7, &reply, 1);
246 if (rc != USB_STOR_TRANSPORT_GOOD)
250 US_DEBUGP("jumpshot_get_status: 0x%2x\n",
251 (unsigned short) (reply));
252 return USB_STOR_TRANSPORT_ERROR;
255 return USB_STOR_TRANSPORT_GOOD;
258 static int jumpshot_read_data(struct us_data *us,
259 struct jumpshot_info *info,
265 unsigned char command[] = { 0, 0, 0, 0, 0, 0xe0, 0x20 };
266 unsigned char *buffer = NULL;
268 unsigned char thistime;
269 struct scatterlist *sg = NULL;
270 int totallen, len, result;
271 int sg_idx = 0, current_sg_offset = 0;
274 // we're working in LBA mode. according to the ATA spec,
275 // we can support up to 28-bit addressing. I don't know if Jumpshot
276 // supports beyond 24-bit addressing. It's kind of hard to test
277 // since it requires > 8GB CF card.
279 if (sector > 0x0FFFFFFF)
280 return USB_STOR_TRANSPORT_ERROR;
282 // If we're using scatter-gather, we have to create a new
283 // buffer to read all of the data in first, since a
284 // scatter-gather buffer could in theory start in the middle
285 // of a page, which would be bad. A developer who wants a
286 // challenge might want to write a limited-buffer
287 // version of this code.
289 totallen = sectors * info->ssize;
292 // loop, never allocate or transfer more than 64k at once (min(128k, 255*info->ssize) is the real limit)
293 len = min_t(int, totallen, 65536);
296 sg = (struct scatterlist *) dest;
297 buffer = kmalloc(len, GFP_NOIO);
299 return USB_STOR_TRANSPORT_ERROR;
305 thistime = (len / info->ssize) & 0xff;
308 command[1] = thistime;
309 command[2] = sector & 0xFF;
310 command[3] = (sector >> 8) & 0xFF;
311 command[4] = (sector >> 16) & 0xFF;
313 command[5] |= (sector >> 24) & 0x0F;
315 // send the setup + command
316 result = jumpshot_send_control(us,
317 usb_sndctrlpipe(us->pusb_dev, 0),
318 0, 0x20, 0, 1, command, 7);
319 if (result != USB_STOR_TRANSPORT_GOOD) {
326 result = jumpshot_bulk_read(us, ptr, len);
327 if (result != USB_STOR_TRANSPORT_GOOD) {
333 US_DEBUGP("jumpshot_read_data: %d bytes\n", len);
334 //jumpshot_dump_data(ptr, len);
341 while (sg_idx < use_sg && transferred < len) {
342 if (len - transferred >= sg[sg_idx].length - current_sg_offset) {
343 US_DEBUGP("jumpshot_read_data: adding %d bytes to %d byte sg buffer\n", sg[sg_idx].length - current_sg_offset, sg[sg_idx].length);
344 memcpy(sg[sg_idx].address + current_sg_offset,
345 buffer + transferred,
346 sg[sg_idx].length - current_sg_offset);
347 transferred += sg[sg_idx].length - current_sg_offset;
348 current_sg_offset = 0;
349 // on to the next sg buffer
352 US_DEBUGP("jumpshot_read_data: adding %d bytes to %d byte sg buffer\n", len - transferred, sg[sg_idx].length);
353 memcpy(sg[sg_idx].address + current_sg_offset,
354 buffer + transferred,
356 current_sg_offset += len - transferred;
357 // this sg buffer is only partially full and we're out of data to copy in
367 } while (totallen > 0);
369 return USB_STOR_TRANSPORT_GOOD;
373 static int jumpshot_write_data(struct us_data *us,
374 struct jumpshot_info *info,
380 unsigned char command[7] = { 0, 0, 0, 0, 0, 0xE0, 0x30 };
381 unsigned char *buffer = NULL;
383 unsigned char thistime;
384 struct scatterlist *sg = NULL;
385 int totallen, len, result, waitcount;
386 int sg_idx = 0, current_sg_offset = 0;
389 // we're working in LBA mode. according to the ATA spec,
390 // we can support up to 28-bit addressing. I don't know if Jumpshot
391 // supports beyond 24-bit addressing. It's kind of hard to test
392 // since it requires > 8GB CF card.
394 if (sector > 0x0FFFFFFF)
395 return USB_STOR_TRANSPORT_ERROR;
397 // If we're using scatter-gather, we have to create a new
398 // buffer to read all of the data in first, since a
399 // scatter-gather buffer could in theory start in the middle
400 // of a page, which would be bad. A developer who wants a
401 // challenge might want to write a limited-buffer
402 // version of this code.
404 totallen = sectors * info->ssize;
407 // loop, never allocate or transfer more than 64k at once (min(128k, 255*info->ssize) is the real limit)
408 len = min_t(int, totallen, 65536);
411 sg = (struct scatterlist *) src;
412 buffer = kmalloc(len, GFP_NOIO);
414 return USB_STOR_TRANSPORT_ERROR;
417 memset(buffer, 0, len);
419 // copy the data from the sg bufs into the big contiguous buf
422 while (transferred < len) {
423 if (len - transferred >= sg[sg_idx].length - current_sg_offset) {
424 US_DEBUGP("jumpshot_write_data: getting %d bytes from %d byte sg buffer\n", sg[sg_idx].length - current_sg_offset, sg[sg_idx].length);
425 memcpy(ptr + transferred,
426 sg[sg_idx].address + current_sg_offset,
427 sg[sg_idx].length - current_sg_offset);
428 transferred += sg[sg_idx].length - current_sg_offset;
429 current_sg_offset = 0;
430 // on to the next sg buffer
433 US_DEBUGP("jumpshot_write_data: getting %d bytes from %d byte sg buffer\n", len - transferred, sg[sg_idx].length);
434 memcpy(ptr + transferred,
435 sg[sg_idx].address + current_sg_offset,
437 current_sg_offset += len - transferred;
438 // we only copied part of this sg buffer
446 thistime = (len / info->ssize) & 0xff;
449 command[1] = thistime;
450 command[2] = sector & 0xFF;
451 command[3] = (sector >> 8) & 0xFF;
452 command[4] = (sector >> 16) & 0xFF;
454 command[5] |= (sector >> 24) & 0x0F;
456 // send the setup + command
457 result = jumpshot_send_control(us,
458 usb_sndctrlpipe(us->pusb_dev, 0),
459 0, 0x20, 0, 1, command, 7);
462 result = jumpshot_bulk_write(us, ptr, len);
463 if (result != USB_STOR_TRANSPORT_GOOD) {
469 // read the result. apparently the bulk write can complete before the
470 // jumpshot drive is finished writing. so we loop here until we
471 // get a good return code
474 result = jumpshot_get_status(us);
475 if (result != USB_STOR_TRANSPORT_GOOD) {
476 // I have not experimented to find the smallest value.
480 } while ((result != USB_STOR_TRANSPORT_GOOD) && (waitcount < 10));
482 if (result != USB_STOR_TRANSPORT_GOOD)
483 US_DEBUGP("jumpshot_write_data: Gah! Waitcount = 10. Bad write!?\n");
495 } while (totallen > 0);
500 static int jumpshot_id_device(struct us_data *us,
501 struct jumpshot_info *info)
503 unsigned char command[2] = { 0xe0, 0xec };
504 unsigned char reply[512];
508 return USB_STOR_TRANSPORT_ERROR;
511 rc = jumpshot_send_control(us,
512 usb_sndctrlpipe(us->pusb_dev, 0),
513 0, 0x20, 0, 6, command, 2);
515 if (rc != USB_STOR_TRANSPORT_GOOD) {
516 US_DEBUGP("jumpshot_id_device: Gah! send_control for read_capacity failed\n");
521 rc = jumpshot_bulk_read(us, reply, sizeof(reply));
522 if (rc != USB_STOR_TRANSPORT_GOOD)
525 info->sectors = ((u32)(reply[117]) << 24) |
526 ((u32)(reply[116]) << 16) |
527 ((u32)(reply[115]) << 8) |
528 ((u32)(reply[114]) );
530 return USB_STOR_TRANSPORT_GOOD;
533 static int jumpshot_handle_mode_sense(struct us_data *us,
538 unsigned char mode_param_header[8] = {
539 0, 0, 0, 0, 0, 0, 0, 0
541 unsigned char rw_err_page[12] = {
542 0x1, 0xA, 0x21, 1, 0, 0, 0, 0, 1, 0, 0, 0
544 unsigned char cache_page[12] = {
545 0x8, 0xA, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0
547 unsigned char rbac_page[12] = {
548 0x1B, 0xA, 0, 0x81, 0, 0, 0, 0, 0, 0, 0, 0
550 unsigned char timer_page[8] = {
551 0x1C, 0x6, 0, 0, 0, 0
553 unsigned char pc, page_code;
554 unsigned short total_len = 0;
555 unsigned short param_len, i = 0;
559 param_len = srb->cmnd[4];
561 param_len = ((u32) (srb->cmnd[7]) >> 8) | ((u32) (srb->cmnd[8]));
564 pc = srb->cmnd[2] >> 6;
565 page_code = srb->cmnd[2] & 0x3F;
569 US_DEBUGP("jumpshot_handle_mode_sense: Current values\n");
572 US_DEBUGP("jumpshot_handle_mode_sense: Changeable values\n");
575 US_DEBUGP("jumpshot_handle_mode_sense: Default values\n");
578 US_DEBUGP("jumpshot_handle_mode_sense: Saves values\n");
582 mode_param_header[3] = 0x80; // write enable
586 // vendor-specific mode
587 return USB_STOR_TRANSPORT_ERROR;
590 total_len = sizeof(rw_err_page);
591 mode_param_header[0] = total_len >> 8;
592 mode_param_header[1] = total_len & 0xFF;
593 mode_param_header[3] = 0x00; // WP enable: 0x80
595 memcpy(ptr, mode_param_header, sizeof(mode_param_header));
596 i += sizeof(mode_param_header);
597 memcpy(ptr + i, rw_err_page, sizeof(rw_err_page));
601 total_len = sizeof(cache_page);
602 mode_param_header[0] = total_len >> 8;
603 mode_param_header[1] = total_len & 0xFF;
604 mode_param_header[3] = 0x00; // WP enable: 0x80
606 memcpy(ptr, mode_param_header, sizeof(mode_param_header));
607 i += sizeof(mode_param_header);
608 memcpy(ptr + i, cache_page, sizeof(cache_page));
612 total_len = sizeof(rbac_page);
613 mode_param_header[0] = total_len >> 8;
614 mode_param_header[1] = total_len & 0xFF;
615 mode_param_header[3] = 0x00; // WP enable: 0x80
617 memcpy(ptr, mode_param_header, sizeof(mode_param_header));
618 i += sizeof(mode_param_header);
619 memcpy(ptr + i, rbac_page, sizeof(rbac_page));
623 total_len = sizeof(timer_page);
624 mode_param_header[0] = total_len >> 8;
625 mode_param_header[1] = total_len & 0xFF;
626 mode_param_header[3] = 0x00; // WP enable: 0x80
628 memcpy(ptr, mode_param_header, sizeof(mode_param_header));
629 i += sizeof(mode_param_header);
630 memcpy(ptr + i, timer_page, sizeof(timer_page));
634 total_len = sizeof(timer_page) + sizeof(rbac_page) +
635 sizeof(cache_page) + sizeof(rw_err_page);
636 mode_param_header[0] = total_len >> 8;
637 mode_param_header[1] = total_len & 0xFF;
638 mode_param_header[3] = 0x00; // WP enable: 0x80
640 memcpy(ptr, mode_param_header, sizeof(mode_param_header));
641 i += sizeof(mode_param_header);
642 memcpy(ptr + i, timer_page, sizeof(timer_page));
643 i += sizeof(timer_page);
644 memcpy(ptr + i, rbac_page, sizeof(rbac_page));
645 i += sizeof(rbac_page);
646 memcpy(ptr + i, cache_page, sizeof(cache_page));
647 i += sizeof(cache_page);
648 memcpy(ptr + i, rw_err_page, sizeof(rw_err_page));
652 return USB_STOR_TRANSPORT_GOOD;
656 void jumpshot_info_destructor(void *extra)
658 // this routine is a placeholder...
659 // currently, we don't allocate any extra blocks so we're okay
664 // Transport for the Lexar 'Jumpshot'
666 int jumpshot_transport(Scsi_Cmnd * srb, struct us_data *us)
668 struct jumpshot_info *info;
670 unsigned long block, blocks;
671 unsigned char *ptr = NULL;
672 unsigned char inquiry_response[36] = {
673 0x00, 0x80, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x00
678 us->extra = kmalloc(sizeof(struct jumpshot_info), GFP_NOIO);
680 US_DEBUGP("jumpshot_transport: Gah! Can't allocate storage for jumpshot info struct!\n");
681 return USB_STOR_TRANSPORT_ERROR;
683 memset(us->extra, 0, sizeof(struct jumpshot_info));
684 us->extra_destructor = jumpshot_info_destructor;
687 info = (struct jumpshot_info *) (us->extra);
688 ptr = (unsigned char *) srb->request_buffer;
690 if (srb->cmnd[0] == INQUIRY) {
691 US_DEBUGP("jumpshot_transport: INQUIRY. Returning bogus response.\n");
692 memset(inquiry_response + 8, 0, 28);
693 fill_inquiry_response(us, inquiry_response, 36);
694 return USB_STOR_TRANSPORT_GOOD;
697 if (srb->cmnd[0] == READ_CAPACITY) {
698 info->ssize = 0x200; // hard coded 512 byte sectors as per ATA spec
700 rc = jumpshot_get_status(us);
701 if (rc != USB_STOR_TRANSPORT_GOOD)
704 rc = jumpshot_id_device(us, info);
705 if (rc != USB_STOR_TRANSPORT_GOOD)
708 US_DEBUGP("jumpshot_transport: READ_CAPACITY: %ld sectors, %ld bytes per sector\n",
709 info->sectors, info->ssize);
713 ((u32 *) ptr)[0] = cpu_to_be32(info->sectors - 1);
714 ((u32 *) ptr)[1] = cpu_to_be32(info->ssize);
716 return USB_STOR_TRANSPORT_GOOD;
719 if (srb->cmnd[0] == MODE_SELECT_10) {
720 US_DEBUGP("jumpshot_transport: Gah! MODE_SELECT_10.\n");
721 return USB_STOR_TRANSPORT_ERROR;
724 if (srb->cmnd[0] == READ_10) {
725 block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
726 ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5]));
728 blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
730 US_DEBUGP("jumpshot_transport: READ_10: read block 0x%04lx count %ld\n", block, blocks);
731 return jumpshot_read_data(us, info, block, blocks, ptr, srb->use_sg);
734 if (srb->cmnd[0] == READ_12) {
735 // I don't think we'll ever see a READ_12 but support it anyway...
737 block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
738 ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5]));
740 blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) |
741 ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9]));
743 US_DEBUGP("jumpshot_transport: READ_12: read block 0x%04lx count %ld\n", block, blocks);
744 return jumpshot_read_data(us, info, block, blocks, ptr, srb->use_sg);
747 if (srb->cmnd[0] == WRITE_10) {
748 block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
749 ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5]));
751 blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
753 US_DEBUGP("jumpshot_transport: WRITE_10: write block 0x%04lx count %ld\n", block, blocks);
754 return jumpshot_write_data(us, info, block, blocks, ptr, srb->use_sg);
757 if (srb->cmnd[0] == WRITE_12) {
758 // I don't think we'll ever see a WRITE_12 but support it anyway...
760 block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
761 ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5]));
763 blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) |
764 ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9]));
766 US_DEBUGP("jumpshot_transport: WRITE_12: write block 0x%04lx count %ld\n", block, blocks);
767 return jumpshot_write_data(us, info, block, blocks, ptr, srb->use_sg);
771 if (srb->cmnd[0] == TEST_UNIT_READY) {
772 US_DEBUGP("jumpshot_transport: TEST_UNIT_READY.\n");
773 return jumpshot_get_status(us);
776 if (srb->cmnd[0] == REQUEST_SENSE) {
777 US_DEBUGP("jumpshot_transport: REQUEST_SENSE. Returning NO SENSE for now\n");
780 ptr[2] = info->sense_key;
782 ptr[12] = info->sense_asc;
783 ptr[13] = info->sense_ascq;
785 return USB_STOR_TRANSPORT_GOOD;
788 if (srb->cmnd[0] == MODE_SENSE) {
789 US_DEBUGP("jumpshot_transport: MODE_SENSE_6 detected\n");
790 return jumpshot_handle_mode_sense(us, srb, ptr, TRUE);
793 if (srb->cmnd[0] == MODE_SENSE_10) {
794 US_DEBUGP("jumpshot_transport: MODE_SENSE_10 detected\n");
795 return jumpshot_handle_mode_sense(us, srb, ptr, FALSE);
798 if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) {
799 // sure. whatever. not like we can stop the user from popping
800 // the media out of the device (no locking doors, etc)
802 return USB_STOR_TRANSPORT_GOOD;
805 if (srb->cmnd[0] == START_STOP) {
806 /* this is used by sd.c'check_scsidisk_media_change to detect
808 US_DEBUGP("jumpshot_transport: START_STOP.\n");
809 /* the first jumpshot_id_device after a media change returns
810 an error (determined experimentally) */
811 rc = jumpshot_id_device(us, info);
812 if (rc == USB_STOR_TRANSPORT_GOOD) {
813 info->sense_key = NO_SENSE;
814 srb->result = SUCCESS;
816 info->sense_key = UNIT_ATTENTION;
817 srb->result = CHECK_CONDITION;
822 US_DEBUGP("jumpshot_transport: Gah! Unknown command: %d (0x%x)\n", srb->cmnd[0], srb->cmnd[0]);
823 return USB_STOR_TRANSPORT_ERROR;