aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage/uas.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/storage/uas.c')
-rw-r--r--drivers/usb/storage/uas.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index b27fe21d866d..d1dbe8833b4a 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -412,20 +412,22 @@ static void uas_cmd_cmplt(struct urb *urb)
412} 412}
413 413
414static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp, 414static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp,
415 unsigned int pipe, u16 stream_id,
416 struct scsi_cmnd *cmnd, 415 struct scsi_cmnd *cmnd,
417 enum dma_data_direction dir) 416 enum dma_data_direction dir)
418{ 417{
419 struct usb_device *udev = devinfo->udev; 418 struct usb_device *udev = devinfo->udev;
419 struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
420 struct urb *urb = usb_alloc_urb(0, gfp); 420 struct urb *urb = usb_alloc_urb(0, gfp);
421 struct scsi_data_buffer *sdb = (dir == DMA_FROM_DEVICE) 421 struct scsi_data_buffer *sdb = (dir == DMA_FROM_DEVICE)
422 ? scsi_in(cmnd) : scsi_out(cmnd); 422 ? scsi_in(cmnd) : scsi_out(cmnd);
423 unsigned int pipe = (dir == DMA_FROM_DEVICE)
424 ? devinfo->data_in_pipe : devinfo->data_out_pipe;
423 425
424 if (!urb) 426 if (!urb)
425 goto out; 427 goto out;
426 usb_fill_bulk_urb(urb, udev, pipe, NULL, sdb->length, 428 usb_fill_bulk_urb(urb, udev, pipe, NULL, sdb->length,
427 uas_data_cmplt, cmnd); 429 uas_data_cmplt, cmnd);
428 urb->stream_id = stream_id; 430 urb->stream_id = cmdinfo->stream;
429 urb->num_sgs = udev->bus->sg_tablesize ? sdb->table.nents : 0; 431 urb->num_sgs = udev->bus->sg_tablesize ? sdb->table.nents : 0;
430 urb->sg = sdb->table.sgl; 432 urb->sg = sdb->table.sgl;
431 out: 433 out:
@@ -433,9 +435,10 @@ static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp,
433} 435}
434 436
435static struct urb *uas_alloc_sense_urb(struct uas_dev_info *devinfo, gfp_t gfp, 437static struct urb *uas_alloc_sense_urb(struct uas_dev_info *devinfo, gfp_t gfp,
436 struct Scsi_Host *shost, u16 stream_id) 438 struct scsi_cmnd *cmnd)
437{ 439{
438 struct usb_device *udev = devinfo->udev; 440 struct usb_device *udev = devinfo->udev;
441 struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
439 struct urb *urb = usb_alloc_urb(0, gfp); 442 struct urb *urb = usb_alloc_urb(0, gfp);
440 struct sense_iu *iu; 443 struct sense_iu *iu;
441 444
@@ -447,8 +450,8 @@ static struct urb *uas_alloc_sense_urb(struct uas_dev_info *devinfo, gfp_t gfp,
447 goto free; 450 goto free;
448 451
449 usb_fill_bulk_urb(urb, udev, devinfo->status_pipe, iu, sizeof(*iu), 452 usb_fill_bulk_urb(urb, udev, devinfo->status_pipe, iu, sizeof(*iu),
450 uas_stat_cmplt, shost); 453 uas_stat_cmplt, cmnd->device->host);
451 urb->stream_id = stream_id; 454 urb->stream_id = cmdinfo->stream;
452 urb->transfer_flags |= URB_FREE_BUFFER; 455 urb->transfer_flags |= URB_FREE_BUFFER;
453 out: 456 out:
454 return urb; 457 return urb;
@@ -500,15 +503,13 @@ static struct urb *uas_alloc_cmd_urb(struct uas_dev_info *devinfo, gfp_t gfp,
500 * daft to me. 503 * daft to me.
501 */ 504 */
502 505
503static struct urb *uas_submit_sense_urb(struct scsi_cmnd *cmnd, 506static struct urb *uas_submit_sense_urb(struct scsi_cmnd *cmnd, gfp_t gfp)
504 gfp_t gfp, unsigned int stream)
505{ 507{
506 struct Scsi_Host *shost = cmnd->device->host; 508 struct uas_dev_info *devinfo = cmnd->device->hostdata;
507 struct uas_dev_info *devinfo = (struct uas_dev_info *)shost->hostdata;
508 struct urb *urb; 509 struct urb *urb;
509 int err; 510 int err;
510 511
511 urb = uas_alloc_sense_urb(devinfo, gfp, shost, stream); 512 urb = uas_alloc_sense_urb(devinfo, gfp, cmnd);
512 if (!urb) 513 if (!urb)
513 return NULL; 514 return NULL;
514 usb_anchor_urb(urb, &devinfo->sense_urbs); 515 usb_anchor_urb(urb, &devinfo->sense_urbs);
@@ -531,7 +532,7 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
531 532
532 lockdep_assert_held(&devinfo->lock); 533 lockdep_assert_held(&devinfo->lock);
533 if (cmdinfo->state & SUBMIT_STATUS_URB) { 534 if (cmdinfo->state & SUBMIT_STATUS_URB) {
534 urb = uas_submit_sense_urb(cmnd, gfp, cmdinfo->stream); 535 urb = uas_submit_sense_urb(cmnd, gfp);
535 if (!urb) 536 if (!urb)
536 return SCSI_MLQUEUE_DEVICE_BUSY; 537 return SCSI_MLQUEUE_DEVICE_BUSY;
537 cmdinfo->state &= ~SUBMIT_STATUS_URB; 538 cmdinfo->state &= ~SUBMIT_STATUS_URB;
@@ -539,8 +540,7 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
539 540
540 if (cmdinfo->state & ALLOC_DATA_IN_URB) { 541 if (cmdinfo->state & ALLOC_DATA_IN_URB) {
541 cmdinfo->data_in_urb = uas_alloc_data_urb(devinfo, gfp, 542 cmdinfo->data_in_urb = uas_alloc_data_urb(devinfo, gfp,
542 devinfo->data_in_pipe, cmdinfo->stream, 543 cmnd, DMA_FROM_DEVICE);
543 cmnd, DMA_FROM_DEVICE);
544 if (!cmdinfo->data_in_urb) 544 if (!cmdinfo->data_in_urb)
545 return SCSI_MLQUEUE_DEVICE_BUSY; 545 return SCSI_MLQUEUE_DEVICE_BUSY;
546 cmdinfo->state &= ~ALLOC_DATA_IN_URB; 546 cmdinfo->state &= ~ALLOC_DATA_IN_URB;
@@ -560,8 +560,7 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
560 560
561 if (cmdinfo->state & ALLOC_DATA_OUT_URB) { 561 if (cmdinfo->state & ALLOC_DATA_OUT_URB) {
562 cmdinfo->data_out_urb = uas_alloc_data_urb(devinfo, gfp, 562 cmdinfo->data_out_urb = uas_alloc_data_urb(devinfo, gfp,
563 devinfo->data_out_pipe, cmdinfo->stream, 563 cmnd, DMA_TO_DEVICE);
564 cmnd, DMA_TO_DEVICE);
565 if (!cmdinfo->data_out_urb) 564 if (!cmdinfo->data_out_urb)
566 return SCSI_MLQUEUE_DEVICE_BUSY; 565 return SCSI_MLQUEUE_DEVICE_BUSY;
567 cmdinfo->state &= ~ALLOC_DATA_OUT_URB; 566 cmdinfo->state &= ~ALLOC_DATA_OUT_URB;