Lines Matching +full:0 +full:us
70 static int datafab_determine_lun(struct us_data *us,
114 datafab_bulk_read(struct us_data *us, unsigned char *data, unsigned int len) { in datafab_bulk_read() argument
115 if (len == 0) in datafab_bulk_read()
118 usb_stor_dbg(us, "len = %d\n", len); in datafab_bulk_read()
119 return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, in datafab_bulk_read()
125 datafab_bulk_write(struct us_data *us, unsigned char *data, unsigned int len) { in datafab_bulk_write() argument
126 if (len == 0) in datafab_bulk_write()
129 usb_stor_dbg(us, "len = %d\n", len); in datafab_bulk_write()
130 return usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, in datafab_bulk_write()
135 static int datafab_read_data(struct us_data *us, in datafab_read_data() argument
140 unsigned char *command = us->iobuf; in datafab_read_data()
145 unsigned int sg_offset = 0; in datafab_read_data()
153 if (sectors > 0x0FFFFFFF) in datafab_read_data()
157 result = datafab_determine_lun(us, info); in datafab_read_data()
178 thistime = (len / info->ssize) & 0xff; in datafab_read_data()
180 command[0] = 0; in datafab_read_data()
182 command[2] = sector & 0xFF; in datafab_read_data()
183 command[3] = (sector >> 8) & 0xFF; in datafab_read_data()
184 command[4] = (sector >> 16) & 0xFF; in datafab_read_data()
186 command[5] = 0xE0 + (info->lun << 4); in datafab_read_data()
187 command[5] |= (sector >> 24) & 0x0F; in datafab_read_data()
188 command[6] = 0x20; in datafab_read_data()
189 command[7] = 0x01; in datafab_read_data()
192 result = datafab_bulk_write(us, command, 8); in datafab_read_data()
197 result = datafab_bulk_read(us, buffer, len); in datafab_read_data()
202 usb_stor_access_xfer_buf(buffer, len, us->srb, in datafab_read_data()
207 } while (totallen > 0); in datafab_read_data()
218 static int datafab_write_data(struct us_data *us, in datafab_write_data() argument
223 unsigned char *command = us->iobuf; in datafab_write_data()
224 unsigned char *reply = us->iobuf; in datafab_write_data()
229 unsigned int sg_offset = 0; in datafab_write_data()
237 if (sectors > 0x0FFFFFFF) in datafab_write_data()
241 result = datafab_determine_lun(us, info); in datafab_write_data()
262 thistime = (len / info->ssize) & 0xff; in datafab_write_data()
265 usb_stor_access_xfer_buf(buffer, len, us->srb, in datafab_write_data()
268 command[0] = 0; in datafab_write_data()
270 command[2] = sector & 0xFF; in datafab_write_data()
271 command[3] = (sector >> 8) & 0xFF; in datafab_write_data()
272 command[4] = (sector >> 16) & 0xFF; in datafab_write_data()
274 command[5] = 0xE0 + (info->lun << 4); in datafab_write_data()
275 command[5] |= (sector >> 24) & 0x0F; in datafab_write_data()
276 command[6] = 0x30; in datafab_write_data()
277 command[7] = 0x02; in datafab_write_data()
280 result = datafab_bulk_write(us, command, 8); in datafab_write_data()
285 result = datafab_bulk_write(us, buffer, len); in datafab_write_data()
290 result = datafab_bulk_read(us, reply, 2); in datafab_write_data()
294 if (reply[0] != 0x50 && reply[1] != 0) { in datafab_write_data()
295 usb_stor_dbg(us, "Gah! write return code: %02x %02x\n", in datafab_write_data()
296 reply[0], reply[1]); in datafab_write_data()
302 } while (totallen > 0); in datafab_write_data()
313 static int datafab_determine_lun(struct us_data *us, in datafab_determine_lun() argument
322 static unsigned char scommand[8] = { 0, 1, 0, 0, 0, 0xa0, 0xec, 1 }; in datafab_determine_lun()
323 unsigned char *command = us->iobuf; in datafab_determine_lun()
325 int count = 0, rc; in datafab_determine_lun()
335 usb_stor_dbg(us, "locating...\n"); in datafab_determine_lun()
340 command[5] = 0xa0; in datafab_determine_lun()
342 rc = datafab_bulk_write(us, command, 8); in datafab_determine_lun()
348 rc = datafab_bulk_read(us, buf, 512); in datafab_determine_lun()
350 info->lun = 0; in datafab_determine_lun()
355 command[5] = 0xb0; in datafab_determine_lun()
357 rc = datafab_bulk_write(us, command, 8); in datafab_determine_lun()
363 rc = datafab_bulk_read(us, buf, 512); in datafab_determine_lun()
380 static int datafab_id_device(struct us_data *us, in datafab_id_device() argument
387 static unsigned char scommand[8] = { 0, 1, 0, 0, 0, 0xa0, 0xec, 1 }; in datafab_id_device()
388 unsigned char *command = us->iobuf; in datafab_id_device()
396 rc = datafab_determine_lun(us, info); in datafab_id_device()
408 rc = datafab_bulk_write(us, command, 8); in datafab_id_device()
416 rc = datafab_bulk_read(us, reply, 512); in datafab_id_device()
436 static int datafab_handle_mode_sense(struct us_data *us, in datafab_handle_mode_sense() argument
441 0x1, 0xA, 0x21, 1, 0, 0, 0, 0, 1, 0, 0, 0 in datafab_handle_mode_sense()
444 0x8, 0xA, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0 in datafab_handle_mode_sense()
447 0x1B, 0xA, 0, 0x81, 0, 0, 0, 0, 0, 0, 0, 0 in datafab_handle_mode_sense()
450 0x1C, 0x6, 0, 0, 0, 0 in datafab_handle_mode_sense()
453 unsigned int i = 0; in datafab_handle_mode_sense()
454 struct datafab_info *info = (struct datafab_info *) (us->extra); in datafab_handle_mode_sense()
455 unsigned char *ptr = us->iobuf; in datafab_handle_mode_sense()
463 page_code = srb->cmnd[2] & 0x3F; in datafab_handle_mode_sense()
466 case 0x0: in datafab_handle_mode_sense()
467 usb_stor_dbg(us, "Current values\n"); in datafab_handle_mode_sense()
469 case 0x1: in datafab_handle_mode_sense()
470 usb_stor_dbg(us, "Changeable values\n"); in datafab_handle_mode_sense()
472 case 0x2: in datafab_handle_mode_sense()
473 usb_stor_dbg(us, "Default values\n"); in datafab_handle_mode_sense()
475 case 0x3: in datafab_handle_mode_sense()
476 usb_stor_dbg(us, "Saves values\n"); in datafab_handle_mode_sense()
480 memset(ptr, 0, 8); in datafab_handle_mode_sense()
482 ptr[2] = 0x00; // WP enable: 0x80 in datafab_handle_mode_sense()
485 ptr[3] = 0x00; // WP enable: 0x80 in datafab_handle_mode_sense()
492 info->sense_key = 0x05; in datafab_handle_mode_sense()
493 info->sense_asc = 0x24; in datafab_handle_mode_sense()
494 info->sense_ascq = 0x00; in datafab_handle_mode_sense()
497 case 0x1: in datafab_handle_mode_sense()
502 case 0x8: in datafab_handle_mode_sense()
507 case 0x1B: in datafab_handle_mode_sense()
512 case 0x1C: in datafab_handle_mode_sense()
517 case 0x3F: // retrieve all pages in datafab_handle_mode_sense()
530 ptr[0] = i - 1; in datafab_handle_mode_sense()
532 ((__be16 *) ptr)[0] = cpu_to_be16(i - 2); in datafab_handle_mode_sense()
547 static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us) in datafab_transport() argument
552 unsigned char *ptr = us->iobuf; in datafab_transport()
554 0x00, 0x80, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x00 in datafab_transport()
557 if (!us->extra) { in datafab_transport()
558 us->extra = kzalloc(sizeof(struct datafab_info), GFP_NOIO); in datafab_transport()
559 if (!us->extra) in datafab_transport()
562 us->extra_destructor = datafab_info_destructor; in datafab_transport()
563 ((struct datafab_info *)us->extra)->lun = -1; in datafab_transport()
566 info = (struct datafab_info *) (us->extra); in datafab_transport()
568 if (srb->cmnd[0] == INQUIRY) { in datafab_transport()
569 usb_stor_dbg(us, "INQUIRY - Returning bogus response\n"); in datafab_transport()
571 fill_inquiry_response(us, ptr, 36); in datafab_transport()
575 if (srb->cmnd[0] == READ_CAPACITY) { in datafab_transport()
576 info->ssize = 0x200; // hard coded 512 byte sectors as per ATA spec in datafab_transport()
577 rc = datafab_id_device(us, info); in datafab_transport()
581 usb_stor_dbg(us, "READ_CAPACITY: %ld sectors, %ld bytes per sector\n", in datafab_transport()
586 ((__be32 *) ptr)[0] = cpu_to_be32(info->sectors - 1); in datafab_transport()
593 if (srb->cmnd[0] == MODE_SELECT_10) { in datafab_transport()
594 usb_stor_dbg(us, "Gah! MODE_SELECT_10\n"); in datafab_transport()
600 if (srb->cmnd[0] == READ_10) { in datafab_transport()
606 usb_stor_dbg(us, "READ_10: read block 0x%04lx count %ld\n", in datafab_transport()
608 return datafab_read_data(us, info, block, blocks); in datafab_transport()
611 if (srb->cmnd[0] == READ_12) { in datafab_transport()
620 usb_stor_dbg(us, "READ_12: read block 0x%04lx count %ld\n", in datafab_transport()
622 return datafab_read_data(us, info, block, blocks); in datafab_transport()
625 if (srb->cmnd[0] == WRITE_10) { in datafab_transport()
631 usb_stor_dbg(us, "WRITE_10: write block 0x%04lx count %ld\n", in datafab_transport()
633 return datafab_write_data(us, info, block, blocks); in datafab_transport()
636 if (srb->cmnd[0] == WRITE_12) { in datafab_transport()
645 usb_stor_dbg(us, "WRITE_12: write block 0x%04lx count %ld\n", in datafab_transport()
647 return datafab_write_data(us, info, block, blocks); in datafab_transport()
650 if (srb->cmnd[0] == TEST_UNIT_READY) { in datafab_transport()
651 usb_stor_dbg(us, "TEST_UNIT_READY\n"); in datafab_transport()
652 return datafab_id_device(us, info); in datafab_transport()
655 if (srb->cmnd[0] == REQUEST_SENSE) { in datafab_transport()
656 usb_stor_dbg(us, "REQUEST_SENSE - Returning faked response\n"); in datafab_transport()
662 memset(ptr, 0, 18); in datafab_transport()
663 ptr[0] = 0xF0; in datafab_transport()
673 if (srb->cmnd[0] == MODE_SENSE) { in datafab_transport()
674 usb_stor_dbg(us, "MODE_SENSE_6 detected\n"); in datafab_transport()
675 return datafab_handle_mode_sense(us, srb, 1); in datafab_transport()
678 if (srb->cmnd[0] == MODE_SENSE_10) { in datafab_transport()
679 usb_stor_dbg(us, "MODE_SENSE_10 detected\n"); in datafab_transport()
680 return datafab_handle_mode_sense(us, srb, 0); in datafab_transport()
683 if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { in datafab_transport()
691 if (srb->cmnd[0] == START_STOP) { in datafab_transport()
696 usb_stor_dbg(us, "START_STOP\n"); in datafab_transport()
701 rc = datafab_id_device(us, info); in datafab_transport()
712 usb_stor_dbg(us, "Gah! Unknown command: %d (0x%x)\n", in datafab_transport()
713 srb->cmnd[0], srb->cmnd[0]); in datafab_transport()
714 info->sense_key = 0x05; in datafab_transport()
715 info->sense_asc = 0x20; in datafab_transport()
716 info->sense_ascq = 0x00; in datafab_transport()
725 struct us_data *us; in datafab_probe() local
728 result = usb_stor_probe1(&us, intf, id, in datafab_probe()
734 us->transport_name = "Datafab Bulk-Only"; in datafab_probe()
735 us->transport = datafab_transport; in datafab_probe()
736 us->transport_reset = usb_stor_Bulk_reset; in datafab_probe()
737 us->max_lun = 1; in datafab_probe()
739 result = usb_stor_probe2(us); in datafab_probe()