Lines Matching +full:0 +full:us

52 static int usb_stor_sddr09_dpcm_init(struct us_data *us);
53 static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us);
54 static int usb_stor_sddr09_init(struct us_data *us);
97 #define LSB_of(s) ((s)&0xFF)
120 #define NAND_MFR_AMD 0x01
121 #define NAND_MFR_NATSEMI 0x8f
122 #define NAND_MFR_TOSHIBA 0x98
123 #define NAND_MFR_SAMSUNG 0xec
144 * 256 MB NAND flash has a 5-byte ID with 2nd byte 0xaa, 0xba, 0xca or 0xda.
149 { 0x6e, 20, 8, 4, 8, 2}, /* 1 MB */
150 { 0xe8, 20, 8, 4, 8, 2}, /* 1 MB */
151 { 0xec, 20, 8, 4, 8, 2}, /* 1 MB */
152 { 0x64, 21, 8, 4, 9, 2}, /* 2 MB */
153 { 0xea, 21, 8, 4, 9, 2}, /* 2 MB */
154 { 0x6b, 22, 9, 4, 9, 2}, /* 4 MB */
155 { 0xe3, 22, 9, 4, 9, 2}, /* 4 MB */
156 { 0xe5, 22, 9, 4, 9, 2}, /* 4 MB */
157 { 0xe6, 23, 9, 4, 10, 2}, /* 8 MB */
158 { 0x73, 24, 9, 5, 10, 2}, /* 16 MB */
159 { 0x75, 25, 9, 5, 10, 2}, /* 32 MB */
160 { 0x76, 26, 9, 5, 10, 3}, /* 64 MB */
161 { 0x79, 27, 9, 5, 10, 3}, /* 128 MB */
164 { 0x5d, 21, 9, 4, 8, 2}, /* 2 MB */
165 { 0xd5, 22, 9, 4, 9, 2}, /* 4 MB */
166 { 0xd6, 23, 9, 4, 10, 2}, /* 8 MB */
167 { 0x57, 24, 9, 4, 11, 2}, /* 16 MB */
168 { 0x58, 25, 9, 4, 12, 2}, /* 32 MB */
169 { 0,}
176 for (i = 0; i < ARRAY_SIZE(nand_flash_ids); i++) in nand_find_id()
191 parity[0] = 0; in nand_init_ecc()
195 for (i = 0; i < 256; i++) { in nand_init_ecc()
196 a = 0; in nand_init_ecc()
197 for (j = 0; j < 8; j++) { in nand_init_ecc()
199 if ((j & 1) == 0) in nand_init_ecc()
200 a ^= 0x04; in nand_init_ecc()
201 if ((j & 2) == 0) in nand_init_ecc()
202 a ^= 0x10; in nand_init_ecc()
203 if ((j & 4) == 0) in nand_init_ecc()
204 a ^= 0x40; in nand_init_ecc()
207 ecc2[i] = ~(a ^ (a<<1) ^ (parity[i] ? 0xa8 : 0)); in nand_init_ecc()
214 unsigned char par = 0, bit, bits[8] = {0}; in nand_compute_ecc()
217 for (i = 0; i < 256; i++) { in nand_compute_ecc()
220 for (j = 0; j < 8; j++) in nand_compute_ecc()
221 if ((i & (1<<j)) == 0) in nand_compute_ecc()
226 a = (bits[3] << 6) + (bits[2] << 4) + (bits[1] << 2) + bits[0]; in nand_compute_ecc()
227 ecc[0] = ~(a ^ (a<<1) ^ (parity[par] ? 0xaa : 0)); in nand_compute_ecc()
230 ecc[1] = ~(a ^ (a<<1) ^ (parity[par] ? 0xaa : 0)); in nand_compute_ecc()
236 return (data[0] == ecc[0] && data[1] == ecc[1] && data[2] == ecc[2]); in nand_compare_ecc()
271 * (and things fail with LUN 0).
280 #define UNDEF 0xffffffff
281 #define SPARE 0xfffffffe
282 #define UNUSABLE 0xfffffffd
284 static const int erase_bad_lba_entries = 0;
286 /* send vendor interface command (0x41) */
287 /* called for requests 0, 1, 8 */
289 sddr09_send_command(struct us_data *us, in sddr09_send_command() argument
295 unsigned char requesttype = (0x41 | direction); in sddr09_send_command()
301 pipe = us->recv_ctrl_pipe; in sddr09_send_command()
303 pipe = us->send_ctrl_pipe; in sddr09_send_command()
305 rc = usb_stor_ctrl_transfer(us, pipe, request, requesttype, in sddr09_send_command()
306 0, 0, xfer_data, xfer_len); in sddr09_send_command()
308 case USB_STOR_XFER_GOOD: return 0; in sddr09_send_command()
315 sddr09_send_scsi_command(struct us_data *us, in sddr09_send_scsi_command() argument
318 return sddr09_send_command(us, 0, USB_DIR_OUT, command, command_len); in sddr09_send_scsi_command()
321 #if 0
324 * byte 0: opcode: 00
327 sddr09_test_unit_ready(struct us_data *us) {
328 unsigned char *command = us->iobuf;
331 memset(command, 0, 6);
334 result = sddr09_send_scsi_command(us, command, 6);
336 usb_stor_dbg(us, "sddr09_test_unit_ready returns %d\n", result);
344 * byte 0: opcode: 03
348 sddr09_request_sense(struct us_data *us, unsigned char *sensebuf, int buflen) { in sddr09_request_sense() argument
349 unsigned char *command = us->iobuf; in sddr09_request_sense()
352 memset(command, 0, 12); in sddr09_request_sense()
353 command[0] = 0x03; in sddr09_request_sense()
357 result = sddr09_send_scsi_command(us, command, 12); in sddr09_request_sense()
361 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, in sddr09_request_sense()
363 return (result == USB_STOR_XFER_GOOD ? 0 : -EIO); in sddr09_request_sense()
368 * byte 0: opcode: E8
389 sddr09_readX(struct us_data *us, int x, unsigned long fromaddress, in sddr09_readX() argument
393 unsigned char *command = us->iobuf; in sddr09_readX()
396 command[0] = 0xE8; in sddr09_readX()
400 command[4] = MSB_of(fromaddress & 0xFFFF); in sddr09_readX()
401 command[5] = LSB_of(fromaddress & 0xFFFF); in sddr09_readX()
402 command[6] = 0; in sddr09_readX()
403 command[7] = 0; in sddr09_readX()
404 command[8] = 0; in sddr09_readX()
405 command[9] = 0; in sddr09_readX()
409 result = sddr09_send_scsi_command(us, command, 12); in sddr09_readX()
412 usb_stor_dbg(us, "Result for send_control in sddr09_read2%d %d\n", in sddr09_readX()
417 result = usb_stor_bulk_transfer_sg(us, us->recv_bulk_pipe, in sddr09_readX()
421 usb_stor_dbg(us, "Result for bulk_transfer in sddr09_read2%d %d\n", in sddr09_readX()
425 return 0; in sddr09_readX()
438 sddr09_read20(struct us_data *us, unsigned long fromaddress, in sddr09_read20() argument
443 return sddr09_readX(us, 0, fromaddress, nr_of_pages, bulklen, in sddr09_read20()
461 sddr09_read21(struct us_data *us, unsigned long fromaddress, in sddr09_read21() argument
465 return sddr09_readX(us, 1, fromaddress, count, bulklen, in sddr09_read21()
479 sddr09_read22(struct us_data *us, unsigned long fromaddress, in sddr09_read22() argument
483 usb_stor_dbg(us, "reading %d pages, %d bytes\n", nr_of_pages, bulklen); in sddr09_read22()
484 return sddr09_readX(us, 2, fromaddress, nr_of_pages, bulklen, in sddr09_read22()
488 #if 0
503 sddr09_read23(struct us_data *us, unsigned long fromaddress,
507 return sddr09_readX(us, 3, fromaddress, count, bulklen,
514 * byte 0: opcode: EA
522 sddr09_erase(struct us_data *us, unsigned long Eaddress) { in sddr09_erase() argument
523 unsigned char *command = us->iobuf; in sddr09_erase()
526 usb_stor_dbg(us, "erase address %lu\n", Eaddress); in sddr09_erase()
528 memset(command, 0, 12); in sddr09_erase()
529 command[0] = 0xEA; in sddr09_erase()
533 command[8] = MSB_of(Eaddress & 0xFFFF); in sddr09_erase()
534 command[9] = LSB_of(Eaddress & 0xFFFF); in sddr09_erase()
536 result = sddr09_send_scsi_command(us, command, 12); in sddr09_erase()
539 usb_stor_dbg(us, "Result for send_control in sddr09_erase %d\n", in sddr09_erase()
547 * byte 0: opcode: EE
561 * byte 0: opcode: E9
571 sddr09_writeX(struct us_data *us, in sddr09_writeX() argument
575 unsigned char *command = us->iobuf; in sddr09_writeX()
578 command[0] = 0xE9; in sddr09_writeX()
583 command[4] = MSB_of(Waddress & 0xFFFF); in sddr09_writeX()
584 command[5] = LSB_of(Waddress & 0xFFFF); in sddr09_writeX()
588 command[8] = MSB_of(Eaddress & 0xFFFF); in sddr09_writeX()
589 command[9] = LSB_of(Eaddress & 0xFFFF); in sddr09_writeX()
594 result = sddr09_send_scsi_command(us, command, 12); in sddr09_writeX()
597 usb_stor_dbg(us, "Result for send_control in sddr09_writeX %d\n", in sddr09_writeX()
602 result = usb_stor_bulk_transfer_sg(us, us->send_bulk_pipe, in sddr09_writeX()
606 usb_stor_dbg(us, "Result for bulk_transfer in sddr09_writeX %d\n", in sddr09_writeX()
610 return 0; in sddr09_writeX()
615 sddr09_write_inplace(struct us_data *us, unsigned long address, in sddr09_write_inplace() argument
619 return sddr09_writeX(us, address, address, nr_of_pages, bulklen, in sddr09_write_inplace()
623 #if 0
626 * byte 0: opcode E7
636 sddr09_read_sg_test_only(struct us_data *us) {
637 unsigned char *command = us->iobuf;
642 nsg = bulklen = 0;
643 command[0] = 0xE7;
645 command[2] = 0;
650 command[4*nsg+1] = ((address >> 9) & 0xFF);
651 command[4*nsg+0] = ((address >> 17) & 0xFF);
652 command[4*nsg-1] = ((address >> 25) & 0xFF);
658 command[4*nsg+1] = ((address >> 9) & 0xFF);
659 command[4*nsg+0] = ((address >> 17) & 0xFF);
660 command[4*nsg-1] = ((address >> 25) & 0xFF);
666 command[4*nsg+1] = ((address >> 9) & 0xFF);
667 command[4*nsg+0] = ((address >> 17) & 0xFF);
668 command[4*nsg-1] = ((address >> 25) & 0xFF);
672 result = sddr09_send_scsi_command(us, command, 4*nsg+3);
675 usb_stor_dbg(us, "Result for send_control in sddr09_read_sg %d\n",
684 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
688 usb_stor_dbg(us, "Result for bulk_transfer in sddr09_read_sg %d\n",
693 return 0;
699 * byte 0: opcode: EC
702 * bit 0: 1: Error
709 sddr09_read_status(struct us_data *us, unsigned char *status) { in sddr09_read_status() argument
711 unsigned char *command = us->iobuf; in sddr09_read_status()
712 unsigned char *data = us->iobuf; in sddr09_read_status()
715 usb_stor_dbg(us, "Reading status...\n"); in sddr09_read_status()
717 memset(command, 0, 12); in sddr09_read_status()
718 command[0] = 0xEC; in sddr09_read_status()
721 result = sddr09_send_scsi_command(us, command, 12); in sddr09_read_status()
725 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, in sddr09_read_status()
727 *status = data[0]; in sddr09_read_status()
728 return (result == USB_STOR_XFER_GOOD ? 0 : -EIO); in sddr09_read_status()
732 sddr09_read_data(struct us_data *us, in sddr09_read_data() argument
736 struct sddr09_card_info *info = (struct sddr09_card_info *) us->extra; in sddr09_read_data()
763 result = 0; in sddr09_read_data()
764 offset = 0; in sddr09_read_data()
767 while (sectors > 0) { in sddr09_read_data()
775 usb_stor_dbg(us, "Error: Requested lba %u exceeds maximum %u\n", in sddr09_read_data()
786 usb_stor_dbg(us, "Read %d zero pages (LBA %d) page %d\n", in sddr09_read_data()
796 memset(buffer, 0, len); in sddr09_read_data()
799 usb_stor_dbg(us, "Read %d pages, from PBA %d (LBA %d) page %d\n", in sddr09_read_data()
805 result = sddr09_read20(us, address>>1, in sddr09_read_data()
806 pages, info->pageshift, buffer, 0); in sddr09_read_data()
812 usb_stor_access_xfer_buf(buffer, len, us->srb, in sddr09_read_data()
815 page = 0; in sddr09_read_data()
841 for (i = 0; i <= lastpba; i++) { in sddr09_find_unused_pba()
847 return 0; in sddr09_find_unused_pba()
851 sddr09_write_lba(struct us_data *us, unsigned int lba, in sddr09_write_lba() argument
855 struct sddr09_card_info *info = (struct sddr09_card_info *) us->extra; in sddr09_write_lba()
863 lbap = ((lba % 1000) << 1) | 0x1000; in sddr09_write_lba()
885 return 0; in sddr09_write_lba()
892 result = sddr09_read22(us, address>>1, info->blocksize, in sddr09_write_lba()
893 info->pageshift, blockbuffer, 0); in sddr09_write_lba()
898 for (i = 0; i < info->blocksize; i++) { in sddr09_write_lba()
903 usb_stor_dbg(us, "Warning: bad ecc in page %d- of pba %d\n", in sddr09_write_lba()
909 usb_stor_dbg(us, "Warning: bad ecc in page %d+ of pba %d\n", in sddr09_write_lba()
930 usb_stor_dbg(us, "Rewrite PBA %d (LBA %d)\n", pba, lba); in sddr09_write_lba()
932 result = sddr09_write_inplace(us, address>>1, info->blocksize, in sddr09_write_lba()
933 info->pageshift, blockbuffer, 0); in sddr09_write_lba()
935 usb_stor_dbg(us, "sddr09_write_inplace returns %d\n", result); in sddr09_write_lba()
937 #if 0 in sddr09_write_lba()
939 unsigned char status = 0; in sddr09_write_lba()
940 int result2 = sddr09_read_status(us, &status); in sddr09_write_lba()
942 usb_stor_dbg(us, "cannot read status\n"); in sddr09_write_lba()
943 else if (status != 0xc0) in sddr09_write_lba()
944 usb_stor_dbg(us, "status after write: 0x%x\n", status); in sddr09_write_lba()
948 #if 0 in sddr09_write_lba()
950 int result2 = sddr09_test_unit_ready(us); in sddr09_write_lba()
958 sddr09_write_data(struct us_data *us, in sddr09_write_data() argument
962 struct sddr09_card_info *info = (struct sddr09_card_info *) us->extra; in sddr09_write_data()
1007 result = 0; in sddr09_write_data()
1008 offset = 0; in sddr09_write_data()
1011 while (sectors > 0) { in sddr09_write_data()
1020 usb_stor_dbg(us, "Error: Requested lba %u exceeds maximum %u\n", in sddr09_write_data()
1027 usb_stor_access_xfer_buf(buffer, len, us->srb, in sddr09_write_data()
1030 result = sddr09_write_lba(us, lba, page, pages, in sddr09_write_data()
1035 page = 0; in sddr09_write_data()
1047 sddr09_read_control(struct us_data *us, in sddr09_read_control() argument
1053 usb_stor_dbg(us, "Read control address %lu, blocks %d\n", in sddr09_read_control()
1056 return sddr09_read21(us, address, blocks, in sddr09_read_control()
1062 * byte 0: opcode: ED
1071 sddr09_read_deviceID(struct us_data *us, unsigned char *deviceID) { in sddr09_read_deviceID() argument
1072 unsigned char *command = us->iobuf; in sddr09_read_deviceID()
1073 unsigned char *content = us->iobuf; in sddr09_read_deviceID()
1076 memset(command, 0, 12); in sddr09_read_deviceID()
1077 command[0] = 0xED; in sddr09_read_deviceID()
1080 result = sddr09_send_scsi_command(us, command, 12); in sddr09_read_deviceID()
1084 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, in sddr09_read_deviceID()
1087 for (i = 0; i < 4; i++) in sddr09_read_deviceID()
1090 return (result == USB_STOR_XFER_GOOD ? 0 : -EIO); in sddr09_read_deviceID()
1094 sddr09_get_wp(struct us_data *us, struct sddr09_card_info *info) { in sddr09_get_wp() argument
1099 result = sddr09_read_status(us, &status); in sddr09_get_wp()
1101 usb_stor_dbg(us, "read_status fails\n"); in sddr09_get_wp()
1104 if ((status & 0x80) == 0) { in sddr09_get_wp()
1110 usb_stor_dbg(us, "status 0x%02X%s%s%s%s\n", status, wp_fmt, in sddr09_get_wp()
1111 status & 0x40 ? " Ready" : "", in sddr09_get_wp()
1113 status & 0x01 ? " Error" : ""); in sddr09_get_wp()
1115 return 0; in sddr09_get_wp()
1118 #if 0
1121 * byte 0: opcode: EB
1124 sddr09_reset(struct us_data *us) {
1126 unsigned char *command = us->iobuf;
1128 memset(command, 0, 12);
1129 command[0] = 0xEB;
1132 return sddr09_send_scsi_command(us, command, 12);
1137 sddr09_get_cardinfo(struct us_data *us, unsigned char flags) { in sddr09_get_cardinfo() argument
1143 usb_stor_dbg(us, "Reading capacity...\n"); in sddr09_get_cardinfo()
1145 result = sddr09_read_deviceID(us, deviceID); in sddr09_get_cardinfo()
1148 usb_stor_dbg(us, "Result of read_deviceID is %d\n", result); in sddr09_get_cardinfo()
1155 /* Byte 0 is the manufacturer */ in sddr09_get_cardinfo()
1158 nand_flash_manufacturer(deviceID[0])); in sddr09_get_cardinfo()
1176 if (deviceID[2] == 0xa5) { in sddr09_get_cardinfo()
1182 if (deviceID[3] == 0xc0) { in sddr09_get_cardinfo()
1197 sddr09_read_map(struct us_data *us) { in sddr09_read_map() argument
1199 struct sddr09_card_info *info = (struct sddr09_card_info *) us->extra; in sddr09_read_map()
1244 for (i = 0; i < numblocks; i++) in sddr09_read_map()
1252 for (i = 0; i < numblocks; i++) { in sddr09_read_map()
1259 us, address>>1, in sddr09_read_map()
1261 buffer, 0); in sddr09_read_map()
1269 if (i == 0 || i == 1) { in sddr09_read_map()
1274 /* special PBAs have control field 0^16 */ in sddr09_read_map()
1275 for (j = 0; j < 16; j++) in sddr09_read_map()
1276 if (ptr[j] != 0) in sddr09_read_map()
1285 for (j = 0; j < 16; j++) in sddr09_read_map()
1286 if (ptr[j] != 0xff) in sddr09_read_map()
1297 i, ptr[0], ptr[1], ptr[2], ptr[3], in sddr09_read_map()
1303 if ((ptr[6] >> 4) != 0x01) { in sddr09_read_map()
1322 lba = (lba & 0x07FF) >> 1; in sddr09_read_map()
1328 * In other words, in PBA 1024-2047 you will find LBA 0-999 in sddr09_read_map()
1340 lba += 1000*(i/0x400); in sddr09_read_map()
1358 sddr09_erase(us, address>>1); in sddr09_read_map()
1370 lbact = 0; in sddr09_read_map()
1371 for (i = 0; i < numblocks; i += 1024) { in sddr09_read_map()
1372 int ct = 0; in sddr09_read_map()
1374 for (j = 0; j < 1024 && i+j < numblocks; j++) { in sddr09_read_map()
1385 usb_stor_dbg(us, "Found %d LBA's\n", lbact); in sddr09_read_map()
1386 result = 0; in sddr09_read_map()
1389 if (result != 0) { in sddr09_read_map()
1411 sddr09_common_init(struct us_data *us) { in sddr09_common_init() argument
1415 if (us->pusb_dev->actconfig->desc.bConfigurationValue != 1) { in sddr09_common_init()
1416 usb_stor_dbg(us, "active config #%d != 1 ??\n", in sddr09_common_init()
1417 us->pusb_dev->actconfig->desc.bConfigurationValue); in sddr09_common_init()
1421 result = usb_reset_configuration(us->pusb_dev); in sddr09_common_init()
1422 usb_stor_dbg(us, "Result of usb_reset_configuration is %d\n", result); in sddr09_common_init()
1424 usb_stor_dbg(us, "-- stall on control interface\n"); in sddr09_common_init()
1425 } else if (result != 0) { in sddr09_common_init()
1427 usb_stor_dbg(us, "-- Unknown error. Rejecting device\n"); in sddr09_common_init()
1431 us->extra = kzalloc(sizeof(struct sddr09_card_info), GFP_NOIO); in sddr09_common_init()
1432 if (!us->extra) in sddr09_common_init()
1434 us->extra_destructor = sddr09_card_info_destructor; in sddr09_common_init()
1437 return 0; in sddr09_common_init()
1443 * unusual devices list but called from here then LUN 0 of the combo reader
1447 usb_stor_sddr09_dpcm_init(struct us_data *us) { in usb_stor_sddr09_dpcm_init() argument
1449 unsigned char *data = us->iobuf; in usb_stor_sddr09_dpcm_init()
1451 result = sddr09_common_init(us); in usb_stor_sddr09_dpcm_init()
1455 result = sddr09_send_command(us, 0x01, USB_DIR_IN, data, 2); in usb_stor_sddr09_dpcm_init()
1457 usb_stor_dbg(us, "send_command fails\n"); in usb_stor_sddr09_dpcm_init()
1461 usb_stor_dbg(us, "%02X %02X\n", data[0], data[1]); in usb_stor_sddr09_dpcm_init()
1464 result = sddr09_send_command(us, 0x08, USB_DIR_IN, data, 2); in usb_stor_sddr09_dpcm_init()
1466 usb_stor_dbg(us, "2nd send_command fails\n"); in usb_stor_sddr09_dpcm_init()
1470 usb_stor_dbg(us, "%02X %02X\n", data[0], data[1]); in usb_stor_sddr09_dpcm_init()
1473 result = sddr09_request_sense(us, data, 18); in usb_stor_sddr09_dpcm_init()
1474 if (result == 0 && data[2] != 0) { in usb_stor_sddr09_dpcm_init()
1476 for (j=0; j<18; j++) in usb_stor_sddr09_dpcm_init()
1481 // sense key 0, sense code 0, extd sense code 0 in usb_stor_sddr09_dpcm_init()
1483 // Or: 70 00 06 00 00 00 00 0b 00 00 00 00 28 00 00 00 00 00 in usb_stor_sddr09_dpcm_init()
1490 return 0; /* not result */ in usb_stor_sddr09_dpcm_init()
1496 static int dpcm_transport(struct scsi_cmnd *srb, struct us_data *us) in dpcm_transport() argument
1500 usb_stor_dbg(us, "LUN=%d\n", (u8)srb->device->lun); in dpcm_transport()
1503 case 0: in dpcm_transport()
1506 * LUN 0 corresponds to the CompactFlash card reader. in dpcm_transport()
1508 ret = usb_stor_CB_transport(srb, us); in dpcm_transport()
1518 * Set the LUN to 0 (just in case). in dpcm_transport()
1520 srb->device->lun = 0; in dpcm_transport()
1521 ret = sddr09_transport(srb, us); in dpcm_transport()
1526 usb_stor_dbg(us, "Invalid LUN %d\n", (u8)srb->device->lun); in dpcm_transport()
1537 static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us) in sddr09_transport() argument
1539 static unsigned char sensekey = 0, sensecode = 0; in sddr09_transport()
1540 static unsigned char havefakesense = 0; in sddr09_transport()
1542 unsigned char *ptr = us->iobuf; in sddr09_transport()
1549 0x00, 0x80, 0x00, 0x02, 0x1F, 0x00, 0x00, 0x00 in sddr09_transport()
1554 0x00, 0x0F, 0x00, 0x0, 0x0, 0x0, 0x00, in sddr09_transport()
1555 0x01, 0x0A, in sddr09_transport()
1556 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 in sddr09_transport()
1559 info = (struct sddr09_card_info *)us->extra; in sddr09_transport()
1561 if (srb->cmnd[0] == REQUEST_SENSE && havefakesense) { in sddr09_transport()
1563 memset(ptr, 0, 18); in sddr09_transport()
1564 ptr[0] = 0x70; in sddr09_transport()
1569 sensekey = sensecode = havefakesense = 0; in sddr09_transport()
1580 if (srb->cmnd[0] == INQUIRY) { in sddr09_transport()
1582 fill_inquiry_response(us, ptr, 36); in sddr09_transport()
1586 if (srb->cmnd[0] == READ_CAPACITY) { in sddr09_transport()
1589 sddr09_get_wp(us, info); /* read WP bit */ in sddr09_transport()
1591 cardinfo = sddr09_get_cardinfo(us, info->flags); in sddr09_transport()
1595 sensekey = 0x02; /* not ready */ in sddr09_transport()
1596 sensecode = 0x3a; /* medium not present */ in sddr09_transport()
1608 if (sddr09_read_map(us)) { in sddr09_transport()
1617 ((__be32 *) ptr)[0] = cpu_to_be32(capacity); in sddr09_transport()
1627 if (srb->cmnd[0] == MODE_SENSE_10) { in sddr09_transport()
1628 int modepage = (srb->cmnd[2] & 0x3F); in sddr09_transport()
1635 if (modepage == 0x01 || modepage == 0x3F) { in sddr09_transport()
1636 usb_stor_dbg(us, "Dummy up request for mode page 0x%x\n", in sddr09_transport()
1640 ((__be16*)ptr)[0] = cpu_to_be16(sizeof(mode_page_01) - 2); in sddr09_transport()
1641 ptr[3] = (info->flags & SDDR09_WP) ? 0x80 : 0; in sddr09_transport()
1646 sensekey = 0x05; /* illegal request */ in sddr09_transport()
1647 sensecode = 0x24; /* invalid field in CDB */ in sddr09_transport()
1651 if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) in sddr09_transport()
1654 havefakesense = 0; in sddr09_transport()
1656 if (srb->cmnd[0] == READ_10) { in sddr09_transport()
1663 usb_stor_dbg(us, "READ_10: read page %d pagect %d\n", in sddr09_transport()
1666 result = sddr09_read_data(us, page, pages); in sddr09_transport()
1667 return (result == 0 ? USB_STOR_TRANSPORT_GOOD : in sddr09_transport()
1671 if (srb->cmnd[0] == WRITE_10) { in sddr09_transport()
1678 usb_stor_dbg(us, "WRITE_10: write page %d pagect %d\n", in sddr09_transport()
1681 result = sddr09_write_data(us, page, pages); in sddr09_transport()
1682 return (result == 0 ? USB_STOR_TRANSPORT_GOOD : in sddr09_transport()
1690 if (srb->cmnd[0] != TEST_UNIT_READY && in sddr09_transport()
1691 srb->cmnd[0] != REQUEST_SENSE) { in sddr09_transport()
1692 sensekey = 0x05; /* illegal request */ in sddr09_transport()
1693 sensecode = 0x20; /* invalid command */ in sddr09_transport()
1699 srb->cmnd[srb->cmd_len] = 0; in sddr09_transport()
1703 ptr[0] = 0; in sddr09_transport()
1704 for (i=0; i<12; i++) in sddr09_transport()
1707 usb_stor_dbg(us, "Send control for command %s\n", ptr); in sddr09_transport()
1709 result = sddr09_send_scsi_command(us, srb->cmnd, 12); in sddr09_transport()
1711 usb_stor_dbg(us, "sddr09_send_scsi_command returns %d\n", in sddr09_transport()
1716 if (scsi_bufflen(srb) == 0) in sddr09_transport()
1722 ? us->send_bulk_pipe : us->recv_bulk_pipe; in sddr09_transport()
1724 usb_stor_dbg(us, "%s %d bytes\n", in sddr09_transport()
1729 result = usb_stor_bulk_srb(us, pipe, srb); in sddr09_transport()
1742 usb_stor_sddr09_init(struct us_data *us) { in usb_stor_sddr09_init() argument
1743 return sddr09_common_init(us); in usb_stor_sddr09_init()
1751 struct us_data *us; in sddr09_probe() local
1754 result = usb_stor_probe1(&us, intf, id, in sddr09_probe()
1760 if (us->protocol == USB_PR_DPCM_USB) { in sddr09_probe()
1761 us->transport_name = "Control/Bulk-EUSB/SDDR09"; in sddr09_probe()
1762 us->transport = dpcm_transport; in sddr09_probe()
1763 us->transport_reset = usb_stor_CB_reset; in sddr09_probe()
1764 us->max_lun = 1; in sddr09_probe()
1766 us->transport_name = "EUSB/SDDR09"; in sddr09_probe()
1767 us->transport = sddr09_transport; in sddr09_probe()
1768 us->transport_reset = usb_stor_CB_reset; in sddr09_probe()
1769 us->max_lun = 0; in sddr09_probe()
1772 result = usb_stor_probe2(us); in sddr09_probe()