| .. | .. |
|---|
| 279 | 279 | |
|---|
| 280 | 280 | switch (response_code) { |
|---|
| 281 | 281 | case RC_INCORRECT_LUN: |
|---|
| 282 | | - cmnd->result = DID_BAD_TARGET << 16; |
|---|
| 282 | + set_host_byte(cmnd, DID_BAD_TARGET); |
|---|
| 283 | 283 | break; |
|---|
| 284 | 284 | case RC_TMF_SUCCEEDED: |
|---|
| 285 | | - cmnd->result = DID_OK << 16; |
|---|
| 285 | + set_host_byte(cmnd, DID_OK); |
|---|
| 286 | 286 | break; |
|---|
| 287 | 287 | case RC_TMF_NOT_SUPPORTED: |
|---|
| 288 | | - cmnd->result = DID_TARGET_FAILURE << 16; |
|---|
| 288 | + set_host_byte(cmnd, DID_TARGET_FAILURE); |
|---|
| 289 | 289 | break; |
|---|
| 290 | 290 | default: |
|---|
| 291 | 291 | uas_log_cmd_state(cmnd, "response iu", response_code); |
|---|
| 292 | | - cmnd->result = DID_ERROR << 16; |
|---|
| 292 | + set_host_byte(cmnd, DID_ERROR); |
|---|
| 293 | 293 | break; |
|---|
| 294 | 294 | } |
|---|
| 295 | 295 | |
|---|
| .. | .. |
|---|
| 396 | 396 | struct scsi_cmnd *cmnd = urb->context; |
|---|
| 397 | 397 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; |
|---|
| 398 | 398 | struct uas_dev_info *devinfo = (void *)cmnd->device->hostdata; |
|---|
| 399 | | - struct scsi_data_buffer *sdb = NULL; |
|---|
| 399 | + struct scsi_data_buffer *sdb = &cmnd->sdb; |
|---|
| 400 | 400 | unsigned long flags; |
|---|
| 401 | 401 | int status = urb->status; |
|---|
| 402 | 402 | |
|---|
| 403 | 403 | spin_lock_irqsave(&devinfo->lock, flags); |
|---|
| 404 | 404 | |
|---|
| 405 | 405 | if (cmdinfo->data_in_urb == urb) { |
|---|
| 406 | | - sdb = scsi_in(cmnd); |
|---|
| 407 | 406 | cmdinfo->state &= ~DATA_IN_URB_INFLIGHT; |
|---|
| 408 | 407 | cmdinfo->data_in_urb = NULL; |
|---|
| 409 | 408 | } else if (cmdinfo->data_out_urb == urb) { |
|---|
| 410 | | - sdb = scsi_out(cmnd); |
|---|
| 411 | 409 | cmdinfo->state &= ~DATA_OUT_URB_INFLIGHT; |
|---|
| 412 | 410 | cmdinfo->data_out_urb = NULL; |
|---|
| 413 | | - } |
|---|
| 414 | | - if (sdb == NULL) { |
|---|
| 415 | | - WARN_ON_ONCE(1); |
|---|
| 416 | | - goto out; |
|---|
| 417 | 411 | } |
|---|
| 418 | 412 | |
|---|
| 419 | 413 | if (devinfo->resetting) |
|---|
| .. | .. |
|---|
| 429 | 423 | if (status != -ENOENT && status != -ECONNRESET && status != -ESHUTDOWN) |
|---|
| 430 | 424 | uas_log_cmd_state(cmnd, "data cmplt err", status); |
|---|
| 431 | 425 | /* error: no data transfered */ |
|---|
| 432 | | - sdb->resid = sdb->length; |
|---|
| 426 | + scsi_set_resid(cmnd, sdb->length); |
|---|
| 433 | 427 | } else { |
|---|
| 434 | | - sdb->resid = sdb->length - urb->actual_length; |
|---|
| 428 | + scsi_set_resid(cmnd, sdb->length - urb->actual_length); |
|---|
| 435 | 429 | } |
|---|
| 436 | 430 | uas_try_complete(cmnd, __func__); |
|---|
| 437 | 431 | out: |
|---|
| .. | .. |
|---|
| 454 | 448 | struct usb_device *udev = devinfo->udev; |
|---|
| 455 | 449 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; |
|---|
| 456 | 450 | struct urb *urb = usb_alloc_urb(0, gfp); |
|---|
| 457 | | - struct scsi_data_buffer *sdb = (dir == DMA_FROM_DEVICE) |
|---|
| 458 | | - ? scsi_in(cmnd) : scsi_out(cmnd); |
|---|
| 451 | + struct scsi_data_buffer *sdb = &cmnd->sdb; |
|---|
| 459 | 452 | unsigned int pipe = (dir == DMA_FROM_DEVICE) |
|---|
| 460 | 453 | ? devinfo->data_in_pipe : devinfo->data_out_pipe; |
|---|
| 461 | 454 | |
|---|
| .. | .. |
|---|
| 667 | 660 | spin_lock_irqsave(&devinfo->lock, flags); |
|---|
| 668 | 661 | |
|---|
| 669 | 662 | if (devinfo->resetting) { |
|---|
| 670 | | - cmnd->result = DID_ERROR << 16; |
|---|
| 663 | + set_host_byte(cmnd, DID_ERROR); |
|---|
| 671 | 664 | cmnd->scsi_done(cmnd); |
|---|
| 672 | 665 | goto zombie; |
|---|
| 673 | 666 | } |
|---|
| .. | .. |
|---|
| 694 | 687 | break; |
|---|
| 695 | 688 | case DMA_BIDIRECTIONAL: |
|---|
| 696 | 689 | cmdinfo->state |= ALLOC_DATA_IN_URB | SUBMIT_DATA_IN_URB; |
|---|
| 697 | | - /* fall through */ |
|---|
| 690 | + fallthrough; |
|---|
| 698 | 691 | case DMA_TO_DEVICE: |
|---|
| 699 | 692 | cmdinfo->state |= ALLOC_DATA_OUT_URB | SUBMIT_DATA_OUT_URB; |
|---|
| 700 | 693 | case DMA_NONE: |
|---|
| .. | .. |
|---|
| 711 | 704 | * of queueing, no matter how fatal the error |
|---|
| 712 | 705 | */ |
|---|
| 713 | 706 | if (err == -ENODEV) { |
|---|
| 714 | | - cmnd->result = DID_ERROR << 16; |
|---|
| 707 | + set_host_byte(cmnd, DID_ERROR); |
|---|
| 715 | 708 | cmnd->scsi_done(cmnd); |
|---|
| 716 | 709 | goto zombie; |
|---|
| 717 | 710 | } |
|---|
| .. | .. |
|---|
| 917 | 910 | .eh_abort_handler = uas_eh_abort_handler, |
|---|
| 918 | 911 | .eh_device_reset_handler = uas_eh_device_reset_handler, |
|---|
| 919 | 912 | .this_id = -1, |
|---|
| 920 | | - .sg_tablesize = SG_NONE, |
|---|
| 921 | 913 | .skip_settle_delay = 1, |
|---|
| 914 | + .dma_boundary = PAGE_SIZE - 1, |
|---|
| 922 | 915 | }; |
|---|
| 923 | 916 | |
|---|
| 924 | 917 | #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \ |
|---|
| .. | .. |
|---|
| 1289 | 1282 | module_exit(uas_exit); |
|---|
| 1290 | 1283 | |
|---|
| 1291 | 1284 | MODULE_LICENSE("GPL"); |
|---|
| 1285 | +MODULE_IMPORT_NS(USB_STORAGE); |
|---|
| 1292 | 1286 | MODULE_AUTHOR( |
|---|
| 1293 | 1287 | "Hans de Goede <hdegoede@redhat.com>, Matthew Wilcox and Sarah Sharp"); |
|---|