1 /* Driver for SanDisk SDDR-55 SmartMedia reader
9 * Current development and maintenance by:
10 * (c) 2002 Simon Munton
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2, or (at your option) any
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include "transport.h"
33 #include <linux/jiffies.h>
34 #include <linux/errno.h>
35 #include <linux/slab.h>
37 #define short_pack(lsb,msb) ( ((u16)(lsb)) | ( ((u16)(msb))<<8 ) )
38 #define LSB_of(s) ((s)&0xFF)
39 #define MSB_of(s) ((s)>>8)
42 #define set_sense_info(sk, asc, ascq) \
44 info->sense_data[2] = sk; \
45 info->sense_data[12] = asc; \
46 info->sense_data[13] = ascq; \
50 struct sddr55_card_info {
51 unsigned long capacity; /* Size of card in bytes */
52 int max_log_blks; /* maximum number of logical blocks */
53 int pageshift; /* log2 of pagesize */
54 int smallpageshift; /* 1 if pagesize == 256 */
55 int blocksize; /* Size of block in pages */
56 int blockshift; /* log2 of blocksize */
57 int blockmask; /* 2^blockshift - 1 */
58 int read_only; /* non zero if card is write protected */
59 int force_read_only; /* non zero if we find a map error*/
60 int *lba_to_pba; /* logical to physical map */
61 int *pba_to_lba; /* physical to logical map */
62 int fatal_error; /* set if we detect something nasty */
63 unsigned long last_access; /* number of jiffies since we last talked to device */
64 unsigned char sense_data[18];
68 #define NOT_ALLOCATED 0xffffffff
69 #define BAD_BLOCK 0xffff
70 #define CIS_BLOCK 0x400
71 #define UNUSED_BLOCK 0x3ff
74 sddr55_bulk_transport(struct us_data *us, int direction,
75 unsigned char *data, unsigned int len) {
76 struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra;
77 unsigned int pipe = (direction == SCSI_DATA_READ) ?
78 us->recv_bulk_pipe : us->send_bulk_pipe;
81 return USB_STOR_XFER_GOOD;
82 info->last_access = jiffies;
83 return usb_stor_bulk_transfer_buf(us, pipe, data, len, NULL);
86 /* check if card inserted, if there is, update read_only status
87 * return non zero if no card
90 static int sddr55_status(struct us_data *us)
93 unsigned char *command = us->iobuf;
94 unsigned char *status = us->iobuf;
95 struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra;
98 memset(command, 0, 8);
101 result = sddr55_bulk_transport(us,
102 SCSI_DATA_WRITE, command, 8);
104 US_DEBUGP("Result for send_command in status %d\n",
107 if (result != USB_STOR_XFER_GOOD) {
108 set_sense_info (4, 0, 0); /* hardware error */
109 return USB_STOR_TRANSPORT_ERROR;
112 result = sddr55_bulk_transport(us,
113 SCSI_DATA_READ, status, 4);
115 /* expect to get short transfer if no card fitted */
116 if (result == USB_STOR_XFER_SHORT || result == USB_STOR_XFER_STALLED) {
117 /* had a short transfer, no card inserted, free map memory */
118 if (info->lba_to_pba)
119 kfree(info->lba_to_pba);
120 if (info->pba_to_lba)
121 kfree(info->pba_to_lba);
122 info->lba_to_pba = NULL;
123 info->pba_to_lba = NULL;
125 info->fatal_error = 0;
126 info->force_read_only = 0;
128 set_sense_info (2, 0x3a, 0); /* not ready, medium not present */
129 return USB_STOR_TRANSPORT_FAILED;
132 if (result != USB_STOR_XFER_GOOD) {
133 set_sense_info (4, 0, 0); /* hardware error */
134 return USB_STOR_TRANSPORT_FAILED;
137 /* check write protect status */
138 info->read_only = (status[0] & 0x20);
140 /* now read status */
141 result = sddr55_bulk_transport(us,
142 SCSI_DATA_READ, status, 2);
144 if (result != USB_STOR_XFER_GOOD) {
145 set_sense_info (4, 0, 0); /* hardware error */
148 return (result == USB_STOR_XFER_GOOD ?
149 USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_FAILED);
153 static int sddr55_read_data(struct us_data *us,
156 unsigned short sectors) {
158 int result = USB_STOR_TRANSPORT_GOOD;
159 unsigned char *command = us->iobuf;
160 unsigned char *status = us->iobuf;
161 struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra;
162 unsigned char *buffer;
165 unsigned long address;
167 unsigned short pages;
168 unsigned int len, index, offset;
170 // Since we only read in one block at a time, we have to create
171 // a bounce buffer and move the data a piece at a time between the
172 // bounce buffer and the actual transfer buffer.
174 len = min((unsigned int) sectors, (unsigned int) info->blocksize >>
175 info->smallpageshift) * PAGESIZE;
176 buffer = kmalloc(len, GFP_NOIO);
178 return USB_STOR_TRANSPORT_ERROR; /* out of memory */
183 /* have we got to end? */
184 if (lba >= info->max_log_blks)
187 pba = info->lba_to_pba[lba];
189 // Read as many sectors as possible in this block
191 pages = min((unsigned int) sectors << info->smallpageshift,
192 info->blocksize - page);
193 len = pages << info->pageshift;
195 US_DEBUGP("Read %02X pages, from PBA %04X"
196 " (LBA %04X) page %02X\n",
197 pages, pba, lba, page);
199 if (pba == NOT_ALLOCATED) {
200 /* no pba for this lba, fill with zeroes */
201 memset (buffer, 0, len);
204 address = (pba << info->blockshift) + page;
207 command[1] = LSB_of(address>>16);
208 command[2] = LSB_of(address>>8);
209 command[3] = LSB_of(address);
213 command[6] = LSB_of(pages << (1 - info->smallpageshift));
217 result = sddr55_bulk_transport(us,
218 SCSI_DATA_WRITE, command, 8);
220 US_DEBUGP("Result for send_command in read_data %d\n",
223 if (result != USB_STOR_XFER_GOOD) {
224 result = USB_STOR_TRANSPORT_ERROR;
229 result = sddr55_bulk_transport(us,
230 SCSI_DATA_READ, buffer, len);
232 if (result != USB_STOR_XFER_GOOD) {
233 result = USB_STOR_TRANSPORT_ERROR;
237 /* now read status */
238 result = sddr55_bulk_transport(us,
239 SCSI_DATA_READ, status, 2);
241 if (result != USB_STOR_XFER_GOOD) {
242 result = USB_STOR_TRANSPORT_ERROR;
246 /* check status for error */
247 if (status[0] == 0xff && status[1] == 0x4) {
248 set_sense_info (3, 0x11, 0);
249 result = USB_STOR_TRANSPORT_FAILED;
254 // Store the data in the transfer buffer
255 usb_stor_access_xfer_buf(buffer, len, us->srb,
256 &index, &offset, TO_XFER_BUF);
260 sectors -= pages >> info->smallpageshift;
263 result = USB_STOR_TRANSPORT_GOOD;
271 static int sddr55_write_data(struct us_data *us,
274 unsigned short sectors) {
276 int result = USB_STOR_TRANSPORT_GOOD;
277 unsigned char *command = us->iobuf;
278 unsigned char *status = us->iobuf;
279 struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra;
280 unsigned char *buffer;
283 unsigned int new_pba;
284 unsigned long address;
286 unsigned short pages;
288 unsigned int len, index, offset;
290 /* check if we are allowed to write */
291 if (info->read_only || info->force_read_only) {
292 set_sense_info (7, 0x27, 0); /* read only */
293 return USB_STOR_TRANSPORT_FAILED;
296 // Since we only write one block at a time, we have to create
297 // a bounce buffer and move the data a piece at a time between the
298 // bounce buffer and the actual transfer buffer.
300 len = min((unsigned int) sectors, (unsigned int) info->blocksize >>
301 info->smallpageshift) * PAGESIZE;
302 buffer = kmalloc(len, GFP_NOIO);
304 return USB_STOR_TRANSPORT_ERROR;
307 while (sectors > 0) {
309 /* have we got to end? */
310 if (lba >= info->max_log_blks)
313 pba = info->lba_to_pba[lba];
315 // Write as many sectors as possible in this block
317 pages = min((unsigned int) sectors << info->smallpageshift,
318 info->blocksize - page);
319 len = pages << info->pageshift;
321 // Get the data from the transfer buffer
322 usb_stor_access_xfer_buf(buffer, len, us->srb,
323 &index, &offset, FROM_XFER_BUF);
325 US_DEBUGP("Write %02X pages, to PBA %04X"
326 " (LBA %04X) page %02X\n",
327 pages, pba, lba, page);
331 if (pba == NOT_ALLOCATED) {
332 /* no pba allocated for this lba, find a free pba to use */
334 int max_pba = (info->max_log_blks / 250 ) * 256;
338 /* set pba to first block in zone lba is in */
339 pba = (lba / 1000) * 1024;
341 US_DEBUGP("No PBA for LBA %04X\n",lba);
347 * Scan through the map looking for an unused block
348 * leave 16 unused blocks at start (or as many as
349 * possible) since the sddr55 seems to reuse a used
350 * block when it shouldn't if we don't leave space.
352 for (i = 0; i < max_pba; i++, pba++) {
353 if (info->pba_to_lba[pba] == UNUSED_BLOCK) {
355 if (found_count++ > 16)
364 US_DEBUGP("Couldn't find unallocated block\n");
366 set_sense_info (3, 0x31, 0); /* medium error */
367 result = USB_STOR_TRANSPORT_FAILED;
371 US_DEBUGP("Allocating PBA %04X for LBA %04X\n", pba, lba);
373 /* set writing to unallocated block flag */
377 address = (pba << info->blockshift) + page;
379 command[1] = LSB_of(address>>16);
380 command[2] = LSB_of(address>>8);
381 command[3] = LSB_of(address);
383 /* set the lba into the command, modulo 1000 */
384 command[0] = LSB_of(lba % 1000);
385 command[6] = MSB_of(lba % 1000);
387 command[4] |= LSB_of(pages >> info->smallpageshift);
392 result = sddr55_bulk_transport(us,
393 SCSI_DATA_WRITE, command, 8);
395 if (result != USB_STOR_XFER_GOOD) {
396 US_DEBUGP("Result for send_command in write_data %d\n",
399 /* set_sense_info is superfluous here? */
400 set_sense_info (3, 0x3, 0);/* peripheral write error */
401 result = USB_STOR_TRANSPORT_FAILED;
406 result = sddr55_bulk_transport(us,
407 SCSI_DATA_WRITE, buffer, len);
409 if (result != USB_STOR_XFER_GOOD) {
410 US_DEBUGP("Result for send_data in write_data %d\n",
413 /* set_sense_info is superfluous here? */
414 set_sense_info (3, 0x3, 0);/* peripheral write error */
415 result = USB_STOR_TRANSPORT_FAILED;
419 /* now read status */
420 result = sddr55_bulk_transport(us, SCSI_DATA_READ, status, 6);
422 if (result != USB_STOR_XFER_GOOD) {
423 US_DEBUGP("Result for get_status in write_data %d\n",
426 /* set_sense_info is superfluous here? */
427 set_sense_info (3, 0x3, 0);/* peripheral write error */
428 result = USB_STOR_TRANSPORT_FAILED;
432 new_pba = (status[3] + (status[4] << 8) + (status[5] << 16))
435 /* check status for error */
436 if (status[0] == 0xff && status[1] == 0x4) {
437 info->pba_to_lba[new_pba] = BAD_BLOCK;
439 set_sense_info (3, 0x0c, 0);
440 result = USB_STOR_TRANSPORT_FAILED;
444 US_DEBUGP("Updating maps for LBA %04X: old PBA %04X, new PBA %04X\n",
447 /* update the lba<->pba maps, note new_pba might be the same as pba */
448 info->lba_to_pba[lba] = new_pba;
449 info->pba_to_lba[pba] = UNUSED_BLOCK;
451 /* check that new_pba wasn't already being used */
452 if (info->pba_to_lba[new_pba] != UNUSED_BLOCK) {
453 printk(KERN_ERR "sddr55 error: new PBA %04X already in use for LBA %04X\n",
454 new_pba, info->pba_to_lba[new_pba]);
455 info->fatal_error = 1;
456 set_sense_info (3, 0x31, 0);
457 result = USB_STOR_TRANSPORT_FAILED;
461 /* update the pba<->lba maps for new_pba */
462 info->pba_to_lba[new_pba] = lba % 1000;
466 sectors -= pages >> info->smallpageshift;
468 result = USB_STOR_TRANSPORT_GOOD;
475 static int sddr55_read_deviceID(struct us_data *us,
476 unsigned char *manufacturerID,
477 unsigned char *deviceID) {
480 unsigned char *command = us->iobuf;
481 unsigned char *content = us->iobuf;
483 memset(command, 0, 8);
486 result = sddr55_bulk_transport(us, SCSI_DATA_WRITE, command, 8);
488 US_DEBUGP("Result of send_control for device ID is %d\n",
491 if (result != USB_STOR_XFER_GOOD)
492 return USB_STOR_TRANSPORT_ERROR;
494 result = sddr55_bulk_transport(us,
495 SCSI_DATA_READ, content, 4);
497 if (result != USB_STOR_XFER_GOOD)
498 return USB_STOR_TRANSPORT_ERROR;
500 *manufacturerID = content[0];
501 *deviceID = content[1];
503 if (content[0] != 0xff) {
504 result = sddr55_bulk_transport(us,
505 SCSI_DATA_READ, content, 2);
508 return USB_STOR_TRANSPORT_GOOD;
512 int sddr55_reset(struct us_data *us) {
517 static unsigned long sddr55_get_capacity(struct us_data *us) {
519 unsigned char manufacturerID;
520 unsigned char deviceID;
522 struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra;
524 US_DEBUGP("Reading capacity...\n");
526 result = sddr55_read_deviceID(us,
530 US_DEBUGP("Result of read_deviceID is %d\n",
533 if (result != USB_STOR_XFER_GOOD)
536 US_DEBUGP("Device ID = %02X\n", deviceID);
537 US_DEBUGP("Manuf ID = %02X\n", manufacturerID);
540 info->smallpageshift = 0;
541 info->blocksize = 16;
542 info->blockshift = 4;
543 info->blockmask = 15;
551 info->smallpageshift = 1;
557 info->smallpageshift = 1;
558 case 0x5d: // 5d is a ROM card with pagesize 512.
572 info->blocksize = 32;
573 info->blockshift = 5;
574 info->blockmask = 31;
578 info->blocksize = 32;
579 info->blockshift = 5;
580 info->blockmask = 31;
584 info->blocksize = 32;
585 info->blockshift = 5;
586 info->blockmask = 31;
590 info->blocksize = 32;
591 info->blockshift = 5;
592 info->blockmask = 31;
601 static int sddr55_read_map(struct us_data *us) {
603 struct sddr55_card_info *info = (struct sddr55_card_info *)(us->extra);
605 unsigned char *buffer;
606 unsigned char *command = us->iobuf;
609 unsigned short max_lba;
615 numblocks = info->capacity >> (info->blockshift + info->pageshift);
617 buffer = kmalloc( numblocks * 2, GFP_NOIO );
622 memset(command, 0, 8);
624 command[6] = numblocks * 2 / 256;
627 result = sddr55_bulk_transport(us, SCSI_DATA_WRITE, command, 8);
629 if ( result != USB_STOR_XFER_GOOD) {
634 result = sddr55_bulk_transport(us, SCSI_DATA_READ, buffer, numblocks * 2);
636 if ( result != USB_STOR_XFER_GOOD) {
641 result = sddr55_bulk_transport(us, SCSI_DATA_READ, command, 2);
643 if ( result != USB_STOR_XFER_GOOD) {
648 if (info->lba_to_pba)
649 kfree(info->lba_to_pba);
650 if (info->pba_to_lba)
651 kfree(info->pba_to_lba);
652 info->lba_to_pba = kmalloc(numblocks*sizeof(int), GFP_NOIO);
653 info->pba_to_lba = kmalloc(numblocks*sizeof(int), GFP_NOIO);
655 if (info->lba_to_pba == NULL || info->pba_to_lba == NULL) {
656 if (info->lba_to_pba != NULL)
657 kfree(info->lba_to_pba);
658 if (info->pba_to_lba != NULL)
659 kfree(info->pba_to_lba);
660 info->lba_to_pba = NULL;
661 info->pba_to_lba = NULL;
666 memset(info->lba_to_pba, 0xff, numblocks*sizeof(int));
667 memset(info->pba_to_lba, 0xff, numblocks*sizeof(int));
669 /* set maximum lba */
670 max_lba = info->max_log_blks;
674 // Each block is 64 bytes of control data, so block i is located in
675 // scatterlist block i*64/128k = i*(2^6)*(2^-17) = i*(2^-11)
677 for (i=0; i<numblocks; i++) {
680 lba = short_pack(buffer[i * 2], buffer[i * 2 + 1]);
682 /* Every 1024 physical blocks ("zone"), the LBA numbers
683 * go back to zero, but are within a higher
684 * block of LBA's. Also, there is a maximum of
685 * 1000 LBA's per zone. In other words, in PBA
686 * 1024-2047 you will find LBA 0-999 which are
687 * really LBA 1000-1999. Yes, this wastes 24
688 * physical blocks per zone. Go figure.
689 * These devices can have blocks go bad, so there
690 * are 24 spare blocks to use when blocks do go bad.
693 /* SDDR55 returns 0xffff for a bad block, and 0x400 for the
694 * CIS block. (Is this true for cards 8MB or less??)
695 * Record these in the physical to logical map
698 info->pba_to_lba[i] = lba;
700 if (lba >= max_lba) {
704 if (info->lba_to_pba[lba + zone * 1000] != NOT_ALLOCATED &&
705 !info->force_read_only) {
706 printk("sddr55: map inconsistency at LBA %04X\n", lba + zone * 1000);
707 info->force_read_only = 1;
710 if (lba<0x10 || (lba>=0x3E0 && lba<0x3EF))
711 US_DEBUGP("LBA %04X <-> PBA %04X\n", lba, i);
713 info->lba_to_pba[lba + zone * 1000] = i;
721 static void sddr55_card_info_destructor(void *extra) {
722 struct sddr55_card_info *info = (struct sddr55_card_info *)extra;
727 if (info->lba_to_pba)
728 kfree(info->lba_to_pba);
729 if (info->pba_to_lba)
730 kfree(info->pba_to_lba);
735 * Transport for the Sandisk SDDR-55
737 int sddr55_transport(Scsi_Cmnd *srb, struct us_data *us)
740 static unsigned char inquiry_response[8] = {
741 0x00, 0x80, 0x00, 0x02, 0x1F, 0x00, 0x00, 0x00
743 // write-protected for now, no block descriptor support
744 static unsigned char mode_page_01[20] = {
745 0x0, 0x12, 0x00, 0x80, 0x0, 0x0, 0x0, 0x0,
747 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
749 unsigned char *ptr = us->iobuf;
750 unsigned long capacity;
754 unsigned short pages;
755 struct sddr55_card_info *info;
759 sizeof(struct sddr55_card_info), GFP_NOIO);
761 return USB_STOR_TRANSPORT_ERROR;
762 memset(us->extra, 0, sizeof(struct sddr55_card_info));
763 us->extra_destructor = sddr55_card_info_destructor;
766 info = (struct sddr55_card_info *)(us->extra);
768 if (srb->cmnd[0] == REQUEST_SENSE) {
769 US_DEBUGP("SDDR55: request sense %02x/%02x/%02x\n", info->sense_data[2], info->sense_data[12], info->sense_data[13]);
771 memcpy (ptr, info->sense_data, sizeof info->sense_data);
774 usb_stor_set_xfer_buf (ptr, sizeof info->sense_data, srb);
775 memset (info->sense_data, 0, sizeof info->sense_data);
777 return USB_STOR_TRANSPORT_GOOD;
780 memset (info->sense_data, 0, sizeof info->sense_data);
782 /* Dummy up a response for INQUIRY since SDDR55 doesn't
783 respond to INQUIRY commands */
785 if (srb->cmnd[0] == INQUIRY) {
786 memcpy(ptr, inquiry_response, 8);
787 fill_inquiry_response(us, ptr, 36);
788 return USB_STOR_TRANSPORT_GOOD;
791 /* only check card status if the map isn't allocated, ie no card seen yet
792 * or if it's been over half a second since we last accessed it
794 if (info->lba_to_pba == NULL || time_after(jiffies, info->last_access + HZ/2)) {
796 /* check to see if a card is fitted */
797 result = sddr55_status (us);
799 result = sddr55_status (us);
801 set_sense_info (6, 0x28, 0); /* new media, set unit attention, not ready to ready */
803 return USB_STOR_TRANSPORT_FAILED;
807 /* if we detected a problem with the map when writing,
808 don't allow any more access */
809 if (info->fatal_error) {
811 set_sense_info (3, 0x31, 0);
812 return USB_STOR_TRANSPORT_FAILED;
815 if (srb->cmnd[0] == READ_CAPACITY) {
817 capacity = sddr55_get_capacity(us);
820 set_sense_info (3, 0x30, 0); /* incompatible medium */
821 return USB_STOR_TRANSPORT_FAILED;
824 info->capacity = capacity;
826 /* figure out the maximum logical block number, allowing for
827 * the fact that only 250 out of every 256 are used */
828 info->max_log_blks = ((info->capacity >> (info->pageshift + info->blockshift)) / 256) * 250;
830 /* Last page in the card, adjust as we only use 250 out of
832 capacity = (capacity / 256) * 250;
834 capacity /= PAGESIZE;
837 ((u32 *) ptr)[0] = cpu_to_be32(capacity);
838 ((u32 *) ptr)[1] = cpu_to_be32(PAGESIZE);
839 usb_stor_set_xfer_buf(ptr, 8, srb);
843 return USB_STOR_TRANSPORT_GOOD;
846 if (srb->cmnd[0] == MODE_SENSE_10) {
848 memcpy(ptr, mode_page_01, sizeof mode_page_01);
849 ptr[3] = (info->read_only || info->force_read_only) ? 0x80 : 0;
850 usb_stor_set_xfer_buf(ptr, sizeof(mode_page_01), srb);
852 if ( (srb->cmnd[2] & 0x3F) == 0x01 ) {
854 "SDDR55: Dummy up request for mode page 1\n");
855 return USB_STOR_TRANSPORT_GOOD;
857 } else if ( (srb->cmnd[2] & 0x3F) == 0x3F ) {
859 "SDDR55: Dummy up request for all mode pages\n");
860 return USB_STOR_TRANSPORT_GOOD;
863 set_sense_info (5, 0x24, 0); /* invalid field in command */
864 return USB_STOR_TRANSPORT_FAILED;
867 if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) {
870 "SDDR55: %s medium removal. Not that I can do"
871 " anything about it...\n",
872 (srb->cmnd[4]&0x03) ? "Prevent" : "Allow");
874 return USB_STOR_TRANSPORT_GOOD;
878 if (srb->cmnd[0] == READ_10 || srb->cmnd[0] == WRITE_10) {
880 page = short_pack(srb->cmnd[3], srb->cmnd[2]);
882 page |= short_pack(srb->cmnd[5], srb->cmnd[4]);
883 pages = short_pack(srb->cmnd[8], srb->cmnd[7]);
885 page <<= info->smallpageshift;
887 // convert page to block and page-within-block
889 lba = page >> info->blockshift;
890 page = page & info->blockmask;
892 // locate physical block corresponding to logical block
894 if (lba >= info->max_log_blks) {
896 US_DEBUGP("Error: Requested LBA %04X exceeds maximum "
897 "block %04X\n", lba, info->max_log_blks-1);
899 set_sense_info (5, 0x24, 0); /* invalid field in command */
901 return USB_STOR_TRANSPORT_FAILED;
904 pba = info->lba_to_pba[lba];
906 if (srb->cmnd[0] == WRITE_10) {
907 US_DEBUGP("WRITE_10: write block %04X (LBA %04X) page %01X"
909 pba, lba, page, pages);
911 return sddr55_write_data(us, lba, page, pages);
913 US_DEBUGP("READ_10: read block %04X (LBA %04X) page %01X"
915 pba, lba, page, pages);
917 return sddr55_read_data(us, lba, page, pages);
922 if (srb->cmnd[0] == TEST_UNIT_READY) {
923 return USB_STOR_TRANSPORT_GOOD;
926 if (srb->cmnd[0] == START_STOP) {
927 return USB_STOR_TRANSPORT_GOOD;
930 set_sense_info (5, 0x20, 0); /* illegal command */
932 return USB_STOR_TRANSPORT_FAILED; // FIXME: sense buffer?