hc
2024-05-16 8d2a02b24d66aa359e83eebc1ed3c0f85367a1cb
kernel/drivers/usb/image/microtek.c
....@@ -389,7 +389,7 @@
389389 res = usb_submit_urb( transfer, GFP_ATOMIC );
390390 if ( unlikely(res) ) {
391391 MTS_INT_ERROR( "could not submit URB! Error was %d\n",(int)res );
392
- context->srb->result = DID_ERROR << 16;
392
+ set_host_byte(context->srb, DID_ERROR);
393393 mts_transfer_cleanup(transfer);
394394 }
395395 }
....@@ -438,7 +438,7 @@
438438 scsi_set_resid(context->srb, context->data_length -
439439 transfer->actual_length);
440440 } else if ( unlikely(status) ) {
441
- context->srb->result = (status == -ENOENT ? DID_ABORT : DID_ERROR)<<16;
441
+ set_host_byte(context->srb, (status == -ENOENT ? DID_ABORT : DID_ERROR));
442442 }
443443
444444 mts_get_status(transfer);
....@@ -455,12 +455,12 @@
455455 if (status == -ENOENT) {
456456 /* We are being killed */
457457 MTS_DEBUG_GOT_HERE();
458
- context->srb->result = DID_ABORT<<16;
458
+ set_host_byte(context->srb, DID_ABORT);
459459 } else {
460460 /* A genuine error has occurred */
461461 MTS_DEBUG_GOT_HERE();
462462
463
- context->srb->result = DID_ERROR<<16;
463
+ set_host_byte(context->srb, DID_ERROR);
464464 }
465465 mts_transfer_cleanup(transfer);
466466
....@@ -488,7 +488,6 @@
488488
489489 static void mts_do_sg (struct urb* transfer)
490490 {
491
- struct scatterlist * sg;
492491 int status = transfer->status;
493492 MTS_INT_INIT();
494493
....@@ -496,17 +495,16 @@
496495 scsi_sg_count(context->srb));
497496
498497 if (unlikely(status)) {
499
- context->srb->result = (status == -ENOENT ? DID_ABORT : DID_ERROR)<<16;
498
+ set_host_byte(context->srb, (status == -ENOENT ? DID_ABORT : DID_ERROR));
500499 mts_transfer_cleanup(transfer);
501500 }
502501
503
- sg = scsi_sglist(context->srb);
504
- context->fragment++;
502
+ context->curr_sg = sg_next(context->curr_sg);
505503 mts_int_submit_urb(transfer,
506504 context->data_pipe,
507
- sg_virt(&sg[context->fragment]),
508
- sg[context->fragment].length,
509
- context->fragment + 1 == scsi_sg_count(context->srb) ?
505
+ sg_virt(context->curr_sg),
506
+ context->curr_sg->length,
507
+ sg_is_last(context->curr_sg) ?
510508 mts_data_done : mts_do_sg);
511509 }
512510
....@@ -526,22 +524,20 @@
526524 mts_build_transfer_context(struct scsi_cmnd *srb, struct mts_desc* desc)
527525 {
528526 int pipe;
529
- struct scatterlist * sg;
530
-
527
+
531528 MTS_DEBUG_GOT_HERE();
532529
533530 desc->context.instance = desc;
534531 desc->context.srb = srb;
535
- desc->context.fragment = 0;
536532
537533 if (!scsi_bufflen(srb)) {
538534 desc->context.data = NULL;
539535 desc->context.data_length = 0;
540536 return;
541537 } else {
542
- sg = scsi_sglist(srb);
543
- desc->context.data = sg_virt(&sg[0]);
544
- desc->context.data_length = sg[0].length;
538
+ desc->context.curr_sg = scsi_sglist(srb);
539
+ desc->context.data = sg_virt(desc->context.curr_sg);
540
+ desc->context.data_length = desc->context.curr_sg->length;
545541 }
546542
547543
....@@ -570,7 +566,6 @@
570566 mts_scsi_queuecommand_lck(struct scsi_cmnd *srb, mts_scsi_cmnd_callback callback)
571567 {
572568 struct mts_desc* desc = (struct mts_desc*)(srb->device->host->hostdata[0]);
573
- int err = 0;
574569 int res;
575570
576571 MTS_DEBUG_GOT_HERE();
....@@ -583,7 +578,7 @@
583578
584579 MTS_DEBUG("this device doesn't exist\n");
585580
586
- srb->result = DID_BAD_TARGET << 16;
581
+ set_host_byte(srb, DID_BAD_TARGET);
587582
588583 if(likely(callback != NULL))
589584 callback(srb);
....@@ -610,14 +605,14 @@
610605
611606 if(unlikely(res)){
612607 MTS_ERROR("error %d submitting URB\n",(int)res);
613
- srb->result = DID_ERROR << 16;
608
+ set_host_byte(srb, DID_ERROR);
614609
615610 if(likely(callback != NULL))
616611 callback(srb);
617612
618613 }
619614 out:
620
- return err;
615
+ return 0;
621616 }
622617
623618 static DEF_SCSI_QCMD(mts_scsi_queuecommand)
....@@ -632,7 +627,6 @@
632627 .sg_tablesize = SG_ALL,
633628 .can_queue = 1,
634629 .this_id = -1,
635
- .use_clustering = 1,
636630 .emulated = 1,
637631 .slave_alloc = mts_slave_alloc,
638632 .slave_configure = mts_slave_configure,