Lines Matching +full:0 +full:us
105 static inline int jumpshot_bulk_read(struct us_data *us, in jumpshot_bulk_read() argument
109 if (len == 0) in jumpshot_bulk_read()
112 usb_stor_dbg(us, "len = %d\n", len); in jumpshot_bulk_read()
113 return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, in jumpshot_bulk_read()
118 static inline int jumpshot_bulk_write(struct us_data *us, in jumpshot_bulk_write() argument
122 if (len == 0) in jumpshot_bulk_write()
125 usb_stor_dbg(us, "len = %d\n", len); in jumpshot_bulk_write()
126 return usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, in jumpshot_bulk_write()
131 static int jumpshot_get_status(struct us_data *us) in jumpshot_get_status() argument
135 if (!us) in jumpshot_get_status()
139 rc = usb_stor_ctrl_transfer(us, us->recv_ctrl_pipe, in jumpshot_get_status()
140 0, 0xA0, 0, 7, us->iobuf, 1); in jumpshot_get_status()
145 if (us->iobuf[0] != 0x50) { in jumpshot_get_status()
146 usb_stor_dbg(us, "0x%2x\n", us->iobuf[0]); in jumpshot_get_status()
153 static int jumpshot_read_data(struct us_data *us, in jumpshot_read_data() argument
158 unsigned char *command = us->iobuf; in jumpshot_read_data()
163 unsigned int sg_offset = 0; in jumpshot_read_data()
171 if (sector > 0x0FFFFFFF) in jumpshot_read_data()
189 thistime = (len / info->ssize) & 0xff; in jumpshot_read_data()
191 command[0] = 0; in jumpshot_read_data()
193 command[2] = sector & 0xFF; in jumpshot_read_data()
194 command[3] = (sector >> 8) & 0xFF; in jumpshot_read_data()
195 command[4] = (sector >> 16) & 0xFF; in jumpshot_read_data()
197 command[5] = 0xE0 | ((sector >> 24) & 0x0F); in jumpshot_read_data()
198 command[6] = 0x20; in jumpshot_read_data()
201 result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe, in jumpshot_read_data()
202 0, 0x20, 0, 1, command, 7); in jumpshot_read_data()
207 result = jumpshot_bulk_read(us, buffer, len); in jumpshot_read_data()
211 usb_stor_dbg(us, "%d bytes\n", len); in jumpshot_read_data()
214 usb_stor_access_xfer_buf(buffer, len, us->srb, in jumpshot_read_data()
219 } while (totallen > 0); in jumpshot_read_data()
230 static int jumpshot_write_data(struct us_data *us, in jumpshot_write_data() argument
235 unsigned char *command = us->iobuf; in jumpshot_write_data()
240 unsigned int sg_offset = 0; in jumpshot_write_data()
248 if (sector > 0x0FFFFFFF) in jumpshot_write_data()
267 thistime = (len / info->ssize) & 0xff; in jumpshot_write_data()
270 usb_stor_access_xfer_buf(buffer, len, us->srb, in jumpshot_write_data()
273 command[0] = 0; in jumpshot_write_data()
275 command[2] = sector & 0xFF; in jumpshot_write_data()
276 command[3] = (sector >> 8) & 0xFF; in jumpshot_write_data()
277 command[4] = (sector >> 16) & 0xFF; in jumpshot_write_data()
279 command[5] = 0xE0 | ((sector >> 24) & 0x0F); in jumpshot_write_data()
280 command[6] = 0x30; in jumpshot_write_data()
283 result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe, in jumpshot_write_data()
284 0, 0x20, 0, 1, command, 7); in jumpshot_write_data()
289 result = jumpshot_bulk_write(us, buffer, len); in jumpshot_write_data()
296 waitcount = 0; in jumpshot_write_data()
298 result = jumpshot_get_status(us); in jumpshot_write_data()
307 usb_stor_dbg(us, "Gah! Waitcount = 10. Bad write!?\n"); in jumpshot_write_data()
311 } while (totallen > 0); in jumpshot_write_data()
321 static int jumpshot_id_device(struct us_data *us, in jumpshot_id_device() argument
324 unsigned char *command = us->iobuf; in jumpshot_id_device()
331 command[0] = 0xE0; in jumpshot_id_device()
332 command[1] = 0xEC; in jumpshot_id_device()
338 rc = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe, in jumpshot_id_device()
339 0, 0x20, 0, 6, command, 2); in jumpshot_id_device()
342 usb_stor_dbg(us, "Gah! send_control for read_capacity failed\n"); in jumpshot_id_device()
348 rc = jumpshot_bulk_read(us, reply, 512); in jumpshot_id_device()
366 static int jumpshot_handle_mode_sense(struct us_data *us, in jumpshot_handle_mode_sense() argument
371 0x1, 0xA, 0x21, 1, 0, 0, 0, 0, 1, 0, 0, 0 in jumpshot_handle_mode_sense()
374 0x8, 0xA, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0 in jumpshot_handle_mode_sense()
377 0x1B, 0xA, 0, 0x81, 0, 0, 0, 0, 0, 0, 0, 0 in jumpshot_handle_mode_sense()
380 0x1C, 0x6, 0, 0, 0, 0 in jumpshot_handle_mode_sense()
383 unsigned int i = 0; in jumpshot_handle_mode_sense()
384 struct jumpshot_info *info = (struct jumpshot_info *) (us->extra); in jumpshot_handle_mode_sense()
385 unsigned char *ptr = us->iobuf; in jumpshot_handle_mode_sense()
388 page_code = srb->cmnd[2] & 0x3F; in jumpshot_handle_mode_sense()
391 case 0x0: in jumpshot_handle_mode_sense()
392 usb_stor_dbg(us, "Current values\n"); in jumpshot_handle_mode_sense()
394 case 0x1: in jumpshot_handle_mode_sense()
395 usb_stor_dbg(us, "Changeable values\n"); in jumpshot_handle_mode_sense()
397 case 0x2: in jumpshot_handle_mode_sense()
398 usb_stor_dbg(us, "Default values\n"); in jumpshot_handle_mode_sense()
400 case 0x3: in jumpshot_handle_mode_sense()
401 usb_stor_dbg(us, "Saves values\n"); in jumpshot_handle_mode_sense()
405 memset(ptr, 0, 8); in jumpshot_handle_mode_sense()
407 ptr[2] = 0x00; // WP enable: 0x80 in jumpshot_handle_mode_sense()
410 ptr[3] = 0x00; // WP enable: 0x80 in jumpshot_handle_mode_sense()
415 case 0x0: in jumpshot_handle_mode_sense()
417 info->sense_key = 0x05; in jumpshot_handle_mode_sense()
418 info->sense_asc = 0x24; in jumpshot_handle_mode_sense()
419 info->sense_ascq = 0x00; in jumpshot_handle_mode_sense()
422 case 0x1: in jumpshot_handle_mode_sense()
427 case 0x8: in jumpshot_handle_mode_sense()
432 case 0x1B: in jumpshot_handle_mode_sense()
437 case 0x1C: in jumpshot_handle_mode_sense()
442 case 0x3F: in jumpshot_handle_mode_sense()
455 ptr[0] = i - 1; in jumpshot_handle_mode_sense()
457 ((__be16 *) ptr)[0] = cpu_to_be16(i - 2); in jumpshot_handle_mode_sense()
474 static int jumpshot_transport(struct scsi_cmnd *srb, struct us_data *us) in jumpshot_transport() argument
479 unsigned char *ptr = us->iobuf; in jumpshot_transport()
481 0x00, 0x80, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x00 in jumpshot_transport()
484 if (!us->extra) { in jumpshot_transport()
485 us->extra = kzalloc(sizeof(struct jumpshot_info), GFP_NOIO); in jumpshot_transport()
486 if (!us->extra) in jumpshot_transport()
489 us->extra_destructor = jumpshot_info_destructor; in jumpshot_transport()
492 info = (struct jumpshot_info *) (us->extra); in jumpshot_transport()
494 if (srb->cmnd[0] == INQUIRY) { in jumpshot_transport()
495 usb_stor_dbg(us, "INQUIRY - Returning bogus response\n"); in jumpshot_transport()
497 fill_inquiry_response(us, ptr, 36); in jumpshot_transport()
501 if (srb->cmnd[0] == READ_CAPACITY) { in jumpshot_transport()
502 info->ssize = 0x200; // hard coded 512 byte sectors as per ATA spec in jumpshot_transport()
504 rc = jumpshot_get_status(us); in jumpshot_transport()
508 rc = jumpshot_id_device(us, info); in jumpshot_transport()
512 usb_stor_dbg(us, "READ_CAPACITY: %ld sectors, %ld bytes per sector\n", in jumpshot_transport()
517 ((__be32 *) ptr)[0] = cpu_to_be32(info->sectors - 1); in jumpshot_transport()
524 if (srb->cmnd[0] == MODE_SELECT_10) { in jumpshot_transport()
525 usb_stor_dbg(us, "Gah! MODE_SELECT_10\n"); in jumpshot_transport()
529 if (srb->cmnd[0] == READ_10) { in jumpshot_transport()
535 usb_stor_dbg(us, "READ_10: read block 0x%04lx count %ld\n", in jumpshot_transport()
537 return jumpshot_read_data(us, info, block, blocks); in jumpshot_transport()
540 if (srb->cmnd[0] == READ_12) { in jumpshot_transport()
549 usb_stor_dbg(us, "READ_12: read block 0x%04lx count %ld\n", in jumpshot_transport()
551 return jumpshot_read_data(us, info, block, blocks); in jumpshot_transport()
554 if (srb->cmnd[0] == WRITE_10) { in jumpshot_transport()
560 usb_stor_dbg(us, "WRITE_10: write block 0x%04lx count %ld\n", in jumpshot_transport()
562 return jumpshot_write_data(us, info, block, blocks); in jumpshot_transport()
565 if (srb->cmnd[0] == WRITE_12) { in jumpshot_transport()
574 usb_stor_dbg(us, "WRITE_12: write block 0x%04lx count %ld\n", in jumpshot_transport()
576 return jumpshot_write_data(us, info, block, blocks); in jumpshot_transport()
580 if (srb->cmnd[0] == TEST_UNIT_READY) { in jumpshot_transport()
581 usb_stor_dbg(us, "TEST_UNIT_READY\n"); in jumpshot_transport()
582 return jumpshot_get_status(us); in jumpshot_transport()
585 if (srb->cmnd[0] == REQUEST_SENSE) { in jumpshot_transport()
586 usb_stor_dbg(us, "REQUEST_SENSE\n"); in jumpshot_transport()
588 memset(ptr, 0, 18); in jumpshot_transport()
589 ptr[0] = 0xF0; in jumpshot_transport()
599 if (srb->cmnd[0] == MODE_SENSE) { in jumpshot_transport()
600 usb_stor_dbg(us, "MODE_SENSE_6 detected\n"); in jumpshot_transport()
601 return jumpshot_handle_mode_sense(us, srb, 1); in jumpshot_transport()
604 if (srb->cmnd[0] == MODE_SENSE_10) { in jumpshot_transport()
605 usb_stor_dbg(us, "MODE_SENSE_10 detected\n"); in jumpshot_transport()
606 return jumpshot_handle_mode_sense(us, srb, 0); in jumpshot_transport()
609 if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { in jumpshot_transport()
617 if (srb->cmnd[0] == START_STOP) { in jumpshot_transport()
622 usb_stor_dbg(us, "START_STOP\n"); in jumpshot_transport()
627 rc = jumpshot_id_device(us, info); in jumpshot_transport()
638 usb_stor_dbg(us, "Gah! Unknown command: %d (0x%x)\n", in jumpshot_transport()
639 srb->cmnd[0], srb->cmnd[0]); in jumpshot_transport()
640 info->sense_key = 0x05; in jumpshot_transport()
641 info->sense_asc = 0x20; in jumpshot_transport()
642 info->sense_ascq = 0x00; in jumpshot_transport()
651 struct us_data *us; in jumpshot_probe() local
654 result = usb_stor_probe1(&us, intf, id, in jumpshot_probe()
660 us->transport_name = "Lexar Jumpshot Control/Bulk"; in jumpshot_probe()
661 us->transport = jumpshot_transport; in jumpshot_probe()
662 us->transport_reset = usb_stor_Bulk_reset; in jumpshot_probe()
663 us->max_lun = 1; in jumpshot_probe()
665 result = usb_stor_probe2(us); in jumpshot_probe()