aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/stex.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
index 72f6d8015358..4b6861cf0417 100644
--- a/drivers/scsi/stex.c
+++ b/drivers/scsi/stex.c
@@ -461,23 +461,6 @@ static void stex_internal_copy(struct scsi_cmnd *cmd,
461 } 461 }
462} 462}
463 463
464static int stex_direct_copy(struct scsi_cmnd *cmd,
465 const void *src, size_t count)
466{
467 size_t cp_len = count;
468 int n_elem = 0;
469
470 n_elem = scsi_dma_map(cmd);
471 if (n_elem < 0)
472 return 0;
473
474 stex_internal_copy(cmd, src, &cp_len, n_elem, ST_TO_CMD);
475
476 scsi_dma_unmap(cmd);
477
478 return cp_len == count;
479}
480
481static void stex_controller_info(struct st_hba *hba, struct st_ccb *ccb) 464static void stex_controller_info(struct st_hba *hba, struct st_ccb *ccb)
482{ 465{
483 struct st_frame *p; 466 struct st_frame *p;
@@ -569,8 +552,10 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *))
569 unsigned char page; 552 unsigned char page;
570 page = cmd->cmnd[2] & 0x3f; 553 page = cmd->cmnd[2] & 0x3f;
571 if (page == 0x8 || page == 0x3f) { 554 if (page == 0x8 || page == 0x3f) {
572 stex_direct_copy(cmd, ms10_caching_page, 555 size_t cp_len = sizeof(ms10_caching_page);
573 sizeof(ms10_caching_page)); 556 stex_internal_copy(cmd, ms10_caching_page,
557 &cp_len, scsi_sg_count(cmd),
558 ST_TO_CMD);
574 cmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; 559 cmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
575 done(cmd); 560 done(cmd);
576 } else 561 } else
@@ -599,8 +584,10 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *))
599 if (id != host->max_id - 1) 584 if (id != host->max_id - 1)
600 break; 585 break;
601 if (lun == 0 && (cmd->cmnd[1] & INQUIRY_EVPD) == 0) { 586 if (lun == 0 && (cmd->cmnd[1] & INQUIRY_EVPD) == 0) {
602 stex_direct_copy(cmd, console_inq_page, 587 size_t cp_len = sizeof(console_inq_page);
603 sizeof(console_inq_page)); 588 stex_internal_copy(cmd, console_inq_page,
589 &cp_len, scsi_sg_count(cmd),
590 ST_TO_CMD);
604 cmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; 591 cmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
605 done(cmd); 592 done(cmd);
606 } else 593 } else
@@ -609,6 +596,7 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *))
609 case PASSTHRU_CMD: 596 case PASSTHRU_CMD:
610 if (cmd->cmnd[1] == PASSTHRU_GET_DRVVER) { 597 if (cmd->cmnd[1] == PASSTHRU_GET_DRVVER) {
611 struct st_drvver ver; 598 struct st_drvver ver;
599 size_t cp_len = sizeof(ver);
612 ver.major = ST_VER_MAJOR; 600 ver.major = ST_VER_MAJOR;
613 ver.minor = ST_VER_MINOR; 601 ver.minor = ST_VER_MINOR;
614 ver.oem = ST_OEM; 602 ver.oem = ST_OEM;
@@ -616,7 +604,9 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *))
616 ver.signature[0] = PASSTHRU_SIGNATURE; 604 ver.signature[0] = PASSTHRU_SIGNATURE;
617 ver.console_id = host->max_id - 1; 605 ver.console_id = host->max_id - 1;
618 ver.host_no = hba->host->host_no; 606 ver.host_no = hba->host->host_no;
619 cmd->result = stex_direct_copy(cmd, &ver, sizeof(ver)) ? 607 stex_internal_copy(cmd, &ver, &cp_len,
608 scsi_sg_count(cmd), ST_TO_CMD);
609 cmd->result = sizeof(ver) == cp_len ?
620 DID_OK << 16 | COMMAND_COMPLETE << 8 : 610 DID_OK << 16 | COMMAND_COMPLETE << 8 :
621 DID_ERROR << 16 | COMMAND_COMPLETE << 8; 611 DID_ERROR << 16 | COMMAND_COMPLETE << 8;
622 done(cmd); 612 done(cmd);