···11721172 of 0 implies a successfully completed command (and all11731173 data (if any) has been transferred to or from the SCSI11741174 target device). 'result' is a 32 bit unsigned integer that11751175- can be viewed as 4 related bytes. The SCSI status value is11761176- in the LSB. See include/scsi/scsi.h status_byte(),11771177- msg_byte(), host_byte() and driver_byte() macros and11781178- related constants.11751175+ can be viewed as 2 related bytes. The SCSI status value is11761176+ in the LSB. See include/scsi/scsi.h status_byte() and11771177+ host_byte() macros and related constants.11791178 sense_buffer11801179 - an array (maximum size: SCSI_SENSE_BUFFERSIZE bytes) that11811180 should be written when the SCSI status (LSB of 'result')
···196196 if (!cmd)197197 return;198198199199- cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;200200-201201- scsi_build_sense_buffer(d_sense, cmd->sense_buffer, sk, asc, ascq);199199+ scsi_build_sense(cmd, d_sense, sk, asc, ascq);202200}203201204202void ata_scsi_set_sense_information(struct ata_device *dev,···407409 cmd_result = scsi_execute(scsidev, scsi_cmd, data_dir, argbuf, argsize,408410 sensebuf, &sshdr, (10*HZ), 5, 0, 0, NULL);409411410410- if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */412412+ if (cmd_result < 0) {413413+ rc = cmd_result;414414+ goto error;415415+ }416416+ if (scsi_sense_valid(&sshdr)) {/* sense data available */411417 u8 *desc = sensebuf + 8;412412- cmd_result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */413418414419 /* If we set cc then ATA pass-through will cause a415420 * check condition even if no error. Filter that. */416416- if (cmd_result & SAM_STAT_CHECK_CONDITION) {421421+ if (scsi_status_is_check_condition(cmd_result)) {417422 if (sshdr.sense_key == RECOVERED_ERROR &&418423 sshdr.asc == 0 && sshdr.ascq == 0x1d)419424 cmd_result &= ~SAM_STAT_CHECK_CONDITION;···491490 cmd_result = scsi_execute(scsidev, scsi_cmd, DMA_NONE, NULL, 0,492491 sensebuf, &sshdr, (10*HZ), 5, 0, 0, NULL);493492494494- if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */493493+ if (cmd_result < 0) {494494+ rc = cmd_result;495495+ goto error;496496+ }497497+ if (scsi_sense_valid(&sshdr)) {/* sense data available */495498 u8 *desc = sensebuf + 8;496496- cmd_result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */497499498500 /* If we set cc then ATA pass-through will cause a499501 * check condition even if no error. Filter that. */···642638 if (cmd->request->rq_flags & RQF_QUIET)643639 qc->flags |= ATA_QCFLAG_QUIET;644640 } else {645645- cmd->result = (DID_OK << 16) | (QUEUE_FULL << 1);641641+ cmd->result = (DID_OK << 16) | SAM_STAT_TASK_SET_FULL;646642 cmd->scsi_done(cmd);647643 }648644···862858863859 memset(sb, 0, SCSI_SENSE_BUFFERSIZE);864860865865- cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;866866-867861 /*868862 * Use ata_to_sense_error() to map status register bits869863 * onto sense key, asc & ascq.···876874 * ATA PASS-THROUGH INFORMATION AVAILABLE877875 * Always in descriptor format sense.878876 */879879- scsi_build_sense_buffer(1, cmd->sense_buffer,880880- RECOVERED_ERROR, 0, 0x1D);877877+ scsi_build_sense(cmd, 1, RECOVERED_ERROR, 0, 0x1D);881878 }882879883880 if ((cmd->sense_buffer[0] & 0x7f) >= 0x72) {···957956 u8 sense_key, asc, ascq;958957959958 memset(sb, 0, SCSI_SENSE_BUFFERSIZE);960960-961961- cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;962959963960 if (ata_dev_disabled(dev)) {964961 /* Device disabled after error recovery */···4195419641964197 case REQUEST_SENSE:41974198 ata_scsi_set_sense(dev, cmd, 0, 0, 0);41984198- cmd->result = (DRIVER_SENSE << 24);41994199 break;4200420042014201 /* if we reach this, then writeback caching is disabled,
···794794795795 acornscsi_dma_cleanup(host);796796797797- SCpnt->result = result << 16 | host->scsi.SCp.Message << 8 | host->scsi.SCp.Status;797797+ set_host_byte(SCpnt, result);798798+ if (result == DID_OK)799799+ scsi_msg_to_host_byte(SCpnt, host->scsi.SCp.Message);800800+ set_status_byte(SCpnt, host->scsi.SCp.Status);798801799802 /*800803 * In theory, this should not happen. In practice, it seems to.···836833 xfer_warn = 0;837834838835 if (xfer_warn) {839839- switch (status_byte(SCpnt->result)) {840840- case CHECK_CONDITION:841841- case COMMAND_TERMINATED:842842- case BUSY:843843- case QUEUE_FULL:844844- case RESERVATION_CONFLICT:836836+ switch (get_status_byte(SCpnt)) {837837+ case SAM_STAT_CHECK_CONDITION:838838+ case SAM_STAT_COMMAND_TERMINATED:839839+ case SAM_STAT_BUSY:840840+ case SAM_STAT_TASK_SET_FULL:841841+ case SAM_STAT_RESERVATION_CONFLICT:845842 break;846843847844 default:···24732470 if (acornscsi_cmdtype(SCpnt->cmnd[0]) == CMD_WRITE && (NO_WRITE & (1 << SCpnt->device->id))) {24742471 printk(KERN_CRIT "scsi%d.%c: WRITE attempted with NO_WRITE flag set\n",24752472 host->host->host_no, '0' + SCpnt->device->id);24762476- SCpnt->result = DID_NO_CONNECT << 16;24732473+ set_host_byte(SCpnt, DID_NO_CONNECT);24772474 done(SCpnt);24782475 return 0;24792476 }···24952492 unsigned long flags;2496249324972494 if (!queue_add_cmd_ordered(&host->queues.issue, SCpnt)) {24982498- SCpnt->result = DID_ERROR << 16;24952495+ set_host_byte(SCpnt, DID_ERROR);24992496 done(SCpnt);25002497 return 0;25012498 }···25082505}2509250625102507DEF_SCSI_QCMD(acornscsi_queuecmd)25112511-25122512-/*25132513- * Prototype: void acornscsi_reportstatus(struct scsi_cmnd **SCpntp1, struct scsi_cmnd **SCpntp2, int result)25142514- * Purpose : pass a result to *SCpntp1, and check if *SCpntp1 = *SCpntp225152515- * Params : SCpntp1 - pointer to command to return25162516- * SCpntp2 - pointer to command to check25172517- * result - result to pass back to mid-level done function25182518- * Returns : *SCpntp2 = NULL if *SCpntp1 is the same command structure as *SCpntp2.25192519- */25202520-static inline void acornscsi_reportstatus(struct scsi_cmnd **SCpntp1,25212521- struct scsi_cmnd **SCpntp2,25222522- int result)25232523-{25242524- struct scsi_cmnd *SCpnt = *SCpntp1;25252525-25262526- if (SCpnt) {25272527- *SCpntp1 = NULL;25282528-25292529- SCpnt->result = result;25302530- SCpnt->scsi_done(SCpnt);25312531- }25322532-25332533- if (SCpnt == *SCpntp2)25342534- *SCpntp2 = NULL;25352535-}2536250825372509enum res_abort { res_not_running, res_success, res_success_clear, res_snooze };25382510
+8-7
drivers/scsi/arm/fas216.c
···20422042{20432043 info->stats.fins += 1;2044204420452045- SCpnt->result = result << 16 | info->scsi.SCp.Message << 8 |20462046- info->scsi.SCp.Status;20452045+ set_host_byte(SCpnt, result);20462046+ if (result == DID_OK)20472047+ scsi_msg_to_host_byte(SCpnt, info->scsi.SCp.Message);20482048+ set_status_byte(SCpnt, info->scsi.SCp.Status);2047204920482050 fas216_log_command(info, LOG_CONNECT, SCpnt,20492051 "command complete, result=0x%08x", SCpnt->result);···20532051 /*20542052 * If the driver detected an error, we're all done.20552053 */20562056- if (host_byte(SCpnt->result) != DID_OK ||20572057- msg_byte(SCpnt->result) != COMMAND_COMPLETE)20542054+ if (get_host_byte(SCpnt) != DID_OK)20582055 goto done;2059205620602057 /*20612058 * If the command returned CHECK_CONDITION or COMMAND_TERMINATED20622059 * status, request the sense information.20632060 */20642064- if (status_byte(SCpnt->result) == CHECK_CONDITION ||20652065- status_byte(SCpnt->result) == COMMAND_TERMINATED)20612061+ if (get_status_byte(SCpnt) == SAM_STAT_CHECK_CONDITION ||20622062+ get_status_byte(SCpnt) == SAM_STAT_COMMAND_TERMINATED)20662063 goto request_sense;2067206420682065 /*20692066 * If the command did not complete with GOOD status,20702067 * we are all done here.20712068 */20722072- if (status_byte(SCpnt->result) != GOOD)20692069+ if (get_status_byte(SCpnt) != SAM_STAT_GOOD)20732070 goto done;2074207120752072 /*
+3-2
drivers/scsi/ch.c
···198198 result = scsi_execute_req(ch->device, cmd, direction, buffer,199199 buflength, &sshdr, timeout * HZ,200200 MAX_RETRIES, NULL);201201-202202- if (driver_byte(result) == DRIVER_SENSE) {201201+ if (result < 0)202202+ return result;203203+ if (scsi_sense_valid(&sshdr)) {203204 if (debug)204205 scsi_print_sense_hdr(ch->device, ch->name, &sshdr);205206 errno = ch_find_errno(&sshdr);
···369369 goto out;370370 }371371372372- if (driver_byte(result) == DRIVER_SENSE) {373373- result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */372372+ if (result > 0 && scsi_sense_valid(&sshdr)) {374373 if (result & SAM_STAT_CHECK_CONDITION) {375374 switch (sshdr.sense_key) {376375 case NO_SENSE:
···44 Use at your own risk. Support Tort Reform so you won't have to read all55 these silly disclaimers.6677- Copyright 1994, Tom Zerucha. 77+ Copyright 1994, Tom Zerucha.88 tz@execpc.com99-99+1010 Additional Code, and much appreciated help by1111 Michael A. Griffith1212 grif@cs.ucr.edu···22222323 Functions as standalone, loadable, and PCMCIA driver, the latter from2424 Dave Hinds' PCMCIA package.2525-2525+2626 Cleaned up 26/10/2002 by Alan Cox <alan@lxorguk.ukuu.org.uk> as part of the 2.52727 SCSI driver cleanup and audit. This driver still needs work on the2828 following2929- - Non terminating hardware waits3030- - Some layering violations with its pcmcia stub2929+ - Non terminating hardware waits3030+ - Some layering violations with its pcmcia stub31313232 Redistributable under terms of the GNU General Public License3333···9292/*9393 * Do a pseudo-dma tranfer9494 */9595-9696-static int ql_pdma(struct qlogicfas408_priv *priv, int phase, char *request, int reqlen)9595+9696+static int ql_pdma(struct qlogicfas408_priv *priv, int phase, char *request,9797+ int reqlen)9798{9899 int j;99100 int qbase = priv->qbase;···109108 request += 128;110109 }111110 while (reqlen >= 84 && !(j & 0xc0)) /* 2/3 */112112- if ((j = inb(qbase + 8)) & 4) 111111+ if ((j = inb(qbase + 8)) & 4)113112 {114113 insl(qbase + 4, request, 21);115114 reqlen -= 84;···124123 /* until both empty and int (or until reclen is 0) */125124 rtrc(7)126125 j = 0;127127- while (reqlen && !((j & 0x10) && (j & 0xc0))) 126126+ while (reqlen && !((j & 0x10) && (j & 0xc0)))128127 {129128 /* while bytes to receive and not empty */130129 j &= 0xc0;131131- while (reqlen && !((j = inb(qbase + 8)) & 0x10)) 130130+ while (reqlen && !((j = inb(qbase + 8)) & 0x10))132131 {133132 *request++ = inb(qbase + 4);134133 reqlen--;···162161 j = 0;163162 while (reqlen && !((j & 2) && (j & 0xc0))) {164163 /* while bytes to send and not full */165165- while (reqlen && !((j = inb(qbase + 8)) & 2)) 164164+ while (reqlen && !((j = inb(qbase + 8)) & 2))166165 {167166 outb(*request++, qbase + 4);168167 reqlen--;···176175}177176178177/*179179- * Wait for interrupt flag (polled - not real hardware interrupt) 178178+ * Wait for interrupt flag (polled - not real hardware interrupt)180179 */181180182181static int ql_wai(struct qlogicfas408_priv *priv)···206205}207206208207/*209209- * Initiate scsi command - queueing handler 208208+ * Initiate scsi command - queueing handler210209 * caller must hold host lock211210 */212211213212static void ql_icmd(struct scsi_cmnd *cmd)214213{215214 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd);216216- int qbase = priv->qbase;215215+ int qbase = priv->qbase;217216 int int_type = priv->int_type;218217 unsigned int i;219218···254253}255254256255/*257257- * Process scsi command - usually after interrupt 256256+ * Process scsi command - usually after interrupt258257 */259258260260-static unsigned int ql_pcmd(struct scsi_cmnd *cmd)259259+static void ql_pcmd(struct scsi_cmnd *cmd)261260{262261 unsigned int i, j;263262 unsigned long k;264264- unsigned int result; /* ultimate return result */265263 unsigned int status; /* scsi returned status */266264 unsigned int message; /* scsi returned message */267265 unsigned int phase; /* recorded scsi phase */···274274 j = inb(qbase + 6);275275 i = inb(qbase + 5);276276 if (i == 0x20) {277277- return (DID_NO_CONNECT << 16);277277+ set_host_byte(cmd, DID_NO_CONNECT);278278+ return;278279 }279280 i |= inb(qbase + 5); /* the 0x10 bit can be set after the 0x08 */280281 if (i != 0x18) {281282 printk(KERN_ERR "Ql:Bad Interrupt status:%02x\n", i);282283 ql_zap(priv);283283- return (DID_BAD_INTR << 16);284284+ set_host_byte(cmd, DID_BAD_INTR);285285+ return;284286 }285287 j &= 7; /* j = inb( qbase + 7 ) >> 5; */286288···295293 printk(KERN_ERR "Ql:Bad sequence for command %d, int %02X, cmdleft = %d\n",296294 j, i, inb(qbase + 7) & 0x1f);297295 ql_zap(priv);298298- return (DID_ERROR << 16);296296+ set_host_byte(cmd, DID_ERROR);297297+ return;299298 }300300- result = DID_OK;299299+301300 if (inb(qbase + 7) & 0x1f) /* if some bytes in fifo */302301 outb(1, qbase + 3); /* clear fifo */303302 /* note that request_bufflen is the total xfer size when sg is used */···317314 scsi_for_each_sg(cmd, sg, scsi_sg_count(cmd), i) {318315 if (priv->qabort) {319316 REG0;320320- return ((priv->qabort == 1 ?321321- DID_ABORT : DID_RESET) << 16);317317+ set_host_byte(cmd,318318+ priv->qabort == 1 ?319319+ DID_ABORT : DID_RESET);322320 }323321 buf = sg_virt(sg);324322 if (ql_pdma(priv, phase, buf, sg->length))325323 break;326324 }327325 REG0;328328- rtrc(2)326326+ rtrc(2);329327 /*330328 * Wait for irq (split into second state of irq handler331331- * if this can take time) 329329+ * if this can take time)332330 */333333- if ((k = ql_wai(priv)))334334- return (k << 16);331331+ if ((k = ql_wai(priv))) {332332+ set_host_byte(cmd, k);333333+ return;334334+ }335335 k = inb(qbase + 5); /* should be 0x10, bus service */336336 }337337338338 /*339339- * Enter Status (and Message In) Phase 339339+ * Enter Status (and Message In) Phase340340 */341341-341341+342342 k = jiffies + WATCHDOG;343343344344 while (time_before(jiffies, k) && !priv->qabort &&···350344351345 if (time_after_eq(jiffies, k)) {352346 ql_zap(priv);353353- return (DID_TIME_OUT << 16);347347+ set_host_byte(cmd, DID_TIME_OUT);348348+ return;354349 }355350356351 /* FIXME: timeout ?? */357352 while (inb(qbase + 5))358353 cpu_relax(); /* clear pending ints */359354360360- if (priv->qabort)361361- return ((priv->qabort == 1 ? DID_ABORT : DID_RESET) << 16);355355+ if (priv->qabort) {356356+ set_host_byte(cmd,357357+ priv->qabort == 1 ? DID_ABORT : DID_RESET);358358+ return;359359+ }362360363361 outb(0x11, qbase + 3); /* get status and message */364364- if ((k = ql_wai(priv)))365365- return (k << 16);362362+ if ((k = ql_wai(priv))) {363363+ set_host_byte(cmd, k);364364+ return;365365+ }366366 i = inb(qbase + 5); /* get chip irq stat */367367 j = inb(qbase + 7) & 0x1f; /* and bytes rec'd */368368 status = inb(qbase + 2);369369 message = inb(qbase + 2);370370371371 /*372372- * Should get function complete int if Status and message, else 373373- * bus serv if only status 372372+ * Should get function complete int if Status and message, else373373+ * bus serv if only status374374 */375375 if (!((i == 8 && j == 2) || (i == 0x10 && j == 1))) {376376 printk(KERN_ERR "Ql:Error during status phase, int=%02X, %d bytes recd\n", i, j);377377- result = DID_ERROR;377377+ set_host_byte(cmd, DID_ERROR);378378 }379379 outb(0x12, qbase + 3); /* done, disconnect */380380- rtrc(1)381381- if ((k = ql_wai(priv)))382382- return (k << 16);380380+ rtrc(1);381381+ if ((k = ql_wai(priv))) {382382+ set_host_byte(cmd, k);383383+ return;384384+ }383385384386 /*385385- * Should get bus service interrupt and disconnect interrupt 387387+ * Should get bus service interrupt and disconnect interrupt386388 */387387-389389+388390 i = inb(qbase + 5); /* should be bus service */389391 while (!priv->qabort && ((i & 0x20) != 0x20)) {390392 barrier();391393 cpu_relax();392394 i |= inb(qbase + 5);393395 }394394- rtrc(0)396396+ rtrc(0);395397396396- if (priv->qabort)397397- return ((priv->qabort == 1 ? DID_ABORT : DID_RESET) << 16);398398-399399- return (result << 16) | (message << 8) | (status & STATUS_MASK);398398+ if (priv->qabort) {399399+ set_host_byte(cmd,400400+ priv->qabort == 1 ? DID_ABORT : DID_RESET);401401+ return;402402+ }403403+404404+ set_host_byte(cmd, DID_OK);405405+ if (message != COMMAND_COMPLETE)406406+ scsi_msg_to_host_byte(cmd, message);407407+ set_status_byte(cmd, status);408408+ return;400409}401410402411/*403403- * Interrupt handler 412412+ * Interrupt handler404413 */405414406415static void ql_ihandl(void *dev_id)···436415 return;437416 }438417 icmd = priv->qlcmd;439439- icmd->result = ql_pcmd(icmd);418418+ ql_pcmd(icmd);440419 priv->qlcmd = NULL;441420 /*442442- * If result is CHECK CONDITION done calls qcommand to request 443443- * sense 421421+ * If result is CHECK CONDITION done calls qcommand to request422422+ * sense444423 */445424 (icmd->scsi_done) (icmd);446425}···464443 void (*done) (struct scsi_cmnd *))465444{466445 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd);446446+447447+ set_host_byte(cmd, DID_OK);448448+ set_status_byte(cmd, SAM_STAT_GOOD);467449 if (scmd_id(cmd) == priv->qinitid) {468468- cmd->result = DID_BAD_TARGET << 16;450450+ set_host_byte(cmd, DID_BAD_TARGET);469451 done(cmd);470452 return 0;471453 }···485461486462DEF_SCSI_QCMD(qlogicfas408_queuecommand)487463488488-/* 489489- * Return bios parameters 464464+/*465465+ * Return bios parameters490466 */491467492468int qlogicfas408_biosparam(struct scsi_device *disk, struct block_device *dev,···511487/*512488 * Abort a command in progress513489 */514514-490490+515491int qlogicfas408_abort(struct scsi_cmnd *cmd)516492{517493 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd);···590566591567int qlogicfas408_detect(int qbase, int int_type)592568{593593- REG1;569569+ REG1;594570 return (((inb(qbase + 0xe) ^ inb(qbase + 0xe)) == 7) &&595595- ((inb(qbase + 0xe) ^ inb(qbase + 0xe)) == 7)); 571571+ ((inb(qbase + 0xe) ^ inb(qbase + 0xe)) == 7));596572}597573598574/*
+3-8
drivers/scsi/scsi.c
···144144 (level > 1)) {145145 scsi_print_result(cmd, "Done", disposition);146146 scsi_print_command(cmd);147147- if (status_byte(cmd->result) == CHECK_CONDITION)147147+ if (scsi_status_is_check_condition(cmd->result))148148 scsi_print_sense(cmd);149149 if (level > 3)150150 scmd_printk(KERN_INFO, cmd,···184184 atomic_set(&starget->target_blocked, 0);185185 if (atomic_read(&sdev->device_blocked))186186 atomic_set(&sdev->device_blocked, 0);187187-188188- /*189189- * If we have valid sense information, then some kind of recovery190190- * must have taken place. Make a note of this.191191- */192192- if (SCSI_SENSE_VALID(cmd))193193- cmd->result |= (DRIVER_SENSE << 24);194187195188 SCSI_LOG_MLCOMPLETE(4, sdev_printk(KERN_INFO, sdev,196189 "Notifying upper driver of completion "···501508 result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len,502509 &sshdr, 30 * HZ, 3, NULL);503510511511+ if (result < 0)512512+ return result;504513 if (result && scsi_sense_valid(&sshdr) &&505514 sshdr.sense_key == ILLEGAL_REQUEST &&506515 (sshdr.asc == 0x20 || sshdr.asc == 0x24) && sshdr.ascq == 0x00)
···742742 return FAILED;743743744744 /*745745- * next, check the message byte.746746- */747747- if (msg_byte(scmd->result) != COMMAND_COMPLETE)748748- return FAILED;749749-750750- /*751745 * now, check the status byte to see if this indicates752746 * anything special.753747 */754754- switch (status_byte(scmd->result)) {755755- case GOOD:748748+ switch (get_status_byte(scmd)) {749749+ case SAM_STAT_GOOD:756750 scsi_handle_queue_ramp_up(scmd->device);757751 fallthrough;758758- case COMMAND_TERMINATED:752752+ case SAM_STAT_COMMAND_TERMINATED:759753 return SUCCESS;760760- case CHECK_CONDITION:754754+ case SAM_STAT_CHECK_CONDITION:761755 return scsi_check_sense(scmd);762762- case CONDITION_GOOD:763763- case INTERMEDIATE_GOOD:764764- case INTERMEDIATE_C_GOOD:756756+ case SAM_STAT_CONDITION_MET:757757+ case SAM_STAT_INTERMEDIATE:758758+ case SAM_STAT_INTERMEDIATE_CONDITION_MET:765759 /*766760 * who knows? FIXME(eric)767761 */768762 return SUCCESS;769769- case RESERVATION_CONFLICT:763763+ case SAM_STAT_RESERVATION_CONFLICT:770764 if (scmd->cmnd[0] == TEST_UNIT_READY)771765 /* it is a success, we probed the device and772766 * found it */773767 return SUCCESS;774768 /* otherwise, we failed to send the command */775769 return FAILED;776776- case QUEUE_FULL:770770+ case SAM_STAT_TASK_SET_FULL:777771 scsi_handle_queue_full(scmd->device);778772 fallthrough;779779- case BUSY:773773+ case SAM_STAT_BUSY:780774 return NEEDS_RETRY;781775 default:782776 return FAILED;···12521258 current->comm));12531259 break;12541260 }12551255- if (status_byte(scmd->result) != CHECK_CONDITION)12611261+ if (!scsi_status_is_check_condition(scmd->result))12561262 /*12571263 * don't request sense if there's no check condition12581264 * status because the error we're processing isn't one···17601766 case DID_PARITY:17611767 return (scmd->request->cmd_flags & REQ_FAILFAST_DEV);17621768 case DID_ERROR:17631763- if (msg_byte(scmd->result) == COMMAND_COMPLETE &&17641764- status_byte(scmd->result) == RESERVATION_CONFLICT)17691769+ if (get_status_byte(scmd) == SAM_STAT_RESERVATION_CONFLICT)17651770 return 0;17661771 fallthrough;17671772 case DID_SOFT_ERROR:17681773 return (scmd->request->cmd_flags & REQ_FAILFAST_DRIVER);17691774 }1770177517711771- if (status_byte(scmd->result) != CHECK_CONDITION)17761776+ if (!scsi_status_is_check_condition(scmd->result))17721777 return 0;1773177817741779check_type:···18761883 */18771884 return SUCCESS;18781885 case DID_ERROR:18791879- if (msg_byte(scmd->result) == COMMAND_COMPLETE &&18801880- status_byte(scmd->result) == RESERVATION_CONFLICT)18861886+ if (get_status_byte(scmd) == SAM_STAT_RESERVATION_CONFLICT)18811887 /*18821888 * execute reservation conflict processing code18831889 * lower down···19051913 }1906191419071915 /*19081908- * next, check the message byte.19091909- */19101910- if (msg_byte(scmd->result) != COMMAND_COMPLETE)19111911- return FAILED;19121912-19131913- /*19141916 * check the status byte to see if this indicates anything special.19151917 */19161916- switch (status_byte(scmd->result)) {19171917- case QUEUE_FULL:19181918+ switch (get_status_byte(scmd)) {19191919+ case SAM_STAT_TASK_SET_FULL:19181920 scsi_handle_queue_full(scmd->device);19191921 /*19201922 * the case of trying to send too many commands to a19211923 * tagged queueing device.19221924 */19231925 fallthrough;19241924- case BUSY:19261926+ case SAM_STAT_BUSY:19251927 /*19261928 * device can't talk to us at the moment. Should only19271929 * occur (SAM-3) when the task queue is empty, so will cause···19231937 * device.19241938 */19251939 return ADD_TO_MLQUEUE;19261926- case GOOD:19401940+ case SAM_STAT_GOOD:19271941 if (scmd->cmnd[0] == REPORT_LUNS)19281942 scmd->device->sdev_target->expecting_lun_change = 0;19291943 scsi_handle_queue_ramp_up(scmd->device);19301944 fallthrough;19311931- case COMMAND_TERMINATED:19451945+ case SAM_STAT_COMMAND_TERMINATED:19321946 return SUCCESS;19331933- case TASK_ABORTED:19471947+ case SAM_STAT_TASK_ABORTED:19341948 goto maybe_retry;19351935- case CHECK_CONDITION:19491949+ case SAM_STAT_CHECK_CONDITION:19361950 rtn = scsi_check_sense(scmd);19371951 if (rtn == NEEDS_RETRY)19381952 goto maybe_retry;···19411955 * to collect the sense and redo the decide19421956 * disposition */19431957 return rtn;19441944- case CONDITION_GOOD:19451945- case INTERMEDIATE_GOOD:19461946- case INTERMEDIATE_C_GOOD:19471947- case ACA_ACTIVE:19581958+ case SAM_STAT_CONDITION_MET:19591959+ case SAM_STAT_INTERMEDIATE:19601960+ case SAM_STAT_INTERMEDIATE_CONDITION_MET:19611961+ case SAM_STAT_ACA_ACTIVE:19481962 /*19491963 * who knows? FIXME(eric)19501964 */19511965 return SUCCESS;1952196619531953- case RESERVATION_CONFLICT:19671967+ case SAM_STAT_RESERVATION_CONFLICT:19541968 sdev_printk(KERN_INFO, scmd->device,19551969 "reservation conflict\n");19561970 set_host_byte(scmd, DID_NEXUS_FAILURE);···21232137 /*21242138 * If just we got sense for the device (called21252139 * scsi_eh_get_sense), scmd->result is already21262126- * set, do not set DRIVER_TIMEOUT.21402140+ * set, do not set DID_TIME_OUT.21272141 */21282142 if (!scmd->result)21292129- scmd->result |= (DRIVER_TIMEOUT << 24);21432143+ scmd->result |= (DID_TIME_OUT << 16);21302144 SCSI_LOG_ERROR_RECOVERY(3,21312145 scmd_printk(KERN_INFO, scmd,21322146 "%s: flush finish cmd\n",
+4-3
drivers/scsi/scsi_ioctl.c
···101101 SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev,102102 "Ioctl returned 0x%x\n", result));103103104104- if (driver_byte(result) == DRIVER_SENSE &&105105- scsi_sense_valid(&sshdr)) {104104+ if (result < 0)105105+ goto out;106106+ if (scsi_sense_valid(&sshdr)) {106107 switch (sshdr.sense_key) {107108 case ILLEGAL_REQUEST:108109 if (cmd[0] == ALLOW_MEDIUM_REMOVAL)···134133 break;135134 }136135 }137137-136136+out:138137 SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev,139138 "IOCTL Releasing command\n"));140139 return result;
+66-51
drivers/scsi/scsi_lib.c
···211211{212212 struct request *req;213213 struct scsi_request *rq;214214- int ret = DRIVER_ERROR << 24;214214+ int ret;215215216216 req = blk_get_request(sdev->request_queue,217217 data_direction == DMA_TO_DEVICE ?218218 REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN,219219 rq_flags & RQF_PM ? BLK_MQ_REQ_PM : 0);220220 if (IS_ERR(req))221221- return ret;221221+ return PTR_ERR(req);222222+222223 rq = scsi_req(req);223224224224- if (bufflen && blk_rq_map_kern(sdev->request_queue, req,225225- buffer, bufflen, GFP_NOIO))226226- goto out;227227-225225+ if (bufflen) {226226+ ret = blk_rq_map_kern(sdev->request_queue, req,227227+ buffer, bufflen, GFP_NOIO);228228+ if (ret)229229+ goto out;230230+ }228231 rq->cmd_len = COMMAND_SIZE(cmd[0]);229232 memcpy(rq->cmd, cmd, rq->cmd_len);230233 rq->retries = retries;···591588{592589 switch (host_byte(result)) {593590 case DID_OK:594594- /*595595- * Also check the other bytes than the status byte in result596596- * to handle the case when a SCSI LLD sets result to597597- * DRIVER_SENSE << 24 without setting SAM_STAT_CHECK_CONDITION.598598- */599599- if (scsi_status_is_good(result) && (result & ~0xff) == 0)591591+ if (scsi_status_is_good(result))600592 return BLK_STS_OK;601593 return BLK_STS_IOERR;602594 case DID_TRANSPORT_FAILFAST:···785787 */786788 if (!level && __ratelimit(&_rs)) {787789 scsi_print_result(cmd, NULL, FAILED);788788- if (driver_byte(result) == DRIVER_SENSE)790790+ if (sense_valid)789791 scsi_print_sense(cmd);790792 scsi_print_command(cmd);791793 }···873875 * if it can't fit). Treat SAM_STAT_CONDITION_MET and the related874876 * intermediate statuses (both obsolete in SAM-4) as good.875877 */876876- if (status_byte(result) && scsi_status_is_good(result)) {878878+ if ((result & 0xff) && scsi_status_is_good(result)) {877879 result = 0;878880 *blk_statp = BLK_STS_OK;879881 }···20912093 * @sshdr: place to put sense data (or NULL if no sense to be collected).20922094 * must be SCSI_SENSE_BUFFERSIZE big.20932095 *20942094- * Returns zero if unsuccessful, or the header offset (either 420952095- * or 8 depending on whether a six or ten byte command was20962096- * issued) if successful.20962096+ * Returns zero if successful, or a negative error number on failure20972097 */20982098int20992099scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,···2138214221392143 result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len,21402144 sshdr, timeout, retries, NULL);21452145+ if (result < 0)21462146+ return result;2141214721422148 /* This code looks awful: what it's doing is making sure an21432149 * ILLEGAL REQUEST sense return identifies the actual command21442150 * byte as the problem. MODE_SENSE commands can return21452151 * ILLEGAL REQUEST if the code page isn't supported */2146215221472147- if (use_10_for_ms && !scsi_status_is_good(result) &&21482148- driver_byte(result) == DRIVER_SENSE) {21532153+ if (!scsi_status_is_good(result)) {21492154 if (scsi_sense_valid(sshdr)) {21502155 if ((sshdr->sense_key == ILLEGAL_REQUEST) &&21512156 (sshdr->asc == 0x20) && (sshdr->ascq == 0)) {21522157 /*21532158 * Invalid command operation code21542159 */21552155- sdev->use_10_for_ms = 0;21602160+ if (use_10_for_ms) {21612161+ sdev->use_10_for_ms = 0;21622162+ goto retry;21632163+ }21642164+ }21652165+ if (scsi_status_is_check_condition(result) &&21662166+ sshdr->sense_key == UNIT_ATTENTION &&21672167+ retry_count) {21682168+ retry_count--;21562169 goto retry;21572170 }21582171 }21722172+ return -EIO;21592173 }21602160-21612161- if (scsi_status_is_good(result)) {21622162- if (unlikely(buffer[0] == 0x86 && buffer[1] == 0x0b &&21632163- (modepage == 6 || modepage == 8))) {21642164- /* Initio breakage? */21652165- header_length = 0;21662166- data->length = 13;21672167- data->medium_type = 0;21682168- data->device_specific = 0;21692169- data->longlba = 0;21702170- data->block_descriptor_length = 0;21712171- } else if (use_10_for_ms) {21722172- data->length = buffer[0]*256 + buffer[1] + 2;21732173- data->medium_type = buffer[2];21742174- data->device_specific = buffer[3];21752175- data->longlba = buffer[4] & 0x01;21762176- data->block_descriptor_length = buffer[6]*25621772177- + buffer[7];21782178- } else {21792179- data->length = buffer[0] + 1;21802180- data->medium_type = buffer[1];21812181- data->device_specific = buffer[2];21822182- data->block_descriptor_length = buffer[3];21832183- }21842184- data->header_length = header_length;21852185- } else if ((status_byte(result) == CHECK_CONDITION) &&21862186- scsi_sense_valid(sshdr) &&21872187- sshdr->sense_key == UNIT_ATTENTION && retry_count) {21882188- retry_count--;21892189- goto retry;21742174+ if (unlikely(buffer[0] == 0x86 && buffer[1] == 0x0b &&21752175+ (modepage == 6 || modepage == 8))) {21762176+ /* Initio breakage? */21772177+ header_length = 0;21782178+ data->length = 13;21792179+ data->medium_type = 0;21802180+ data->device_specific = 0;21812181+ data->longlba = 0;21822182+ data->block_descriptor_length = 0;21832183+ } else if (use_10_for_ms) {21842184+ data->length = buffer[0]*256 + buffer[1] + 2;21852185+ data->medium_type = buffer[2];21862186+ data->device_specific = buffer[3];21872187+ data->longlba = buffer[4] & 0x01;21882188+ data->block_descriptor_length = buffer[6]*25621892189+ + buffer[7];21902190+ } else {21912191+ data->length = buffer[0] + 1;21922192+ data->medium_type = buffer[1];21932193+ data->device_specific = buffer[2];21942194+ data->block_descriptor_length = buffer[3];21902195 }21962196+ data->header_length = header_length;2191219721922192- return result;21982198+ return 0;21932199}21942200EXPORT_SYMBOL(scsi_mode_sense);21952201···32163218 return group_id;32173219}32183220EXPORT_SYMBOL(scsi_vpd_tpg_id);32213221+32223222+/**32233223+ * scsi_build_sense - build sense data for a command32243224+ * @scmd: scsi command for which the sense should be formatted32253225+ * @desc: Sense format (non-zero == descriptor format,32263226+ * 0 == fixed format)32273227+ * @key: Sense key32283228+ * @asc: Additional sense code32293229+ * @ascq: Additional sense code qualifier32303230+ *32313231+ **/32323232+void scsi_build_sense(struct scsi_cmnd *scmd, int desc, u8 key, u8 asc, u8 ascq)32333233+{32343234+ scsi_build_sense_buffer(desc, scmd->sense_buffer, key, asc, ascq);32353235+ scmd->result = SAM_STAT_CHECK_CONDITION;32363236+}32373237+EXPORT_SYMBOL_GPL(scsi_build_sense);
···616616 "scsi scan: INQUIRY %s with code 0x%x\n",617617 result ? "failed" : "successful", result));618618619619- if (result) {619619+ if (result > 0) {620620 /*621621 * not-ready to ready transition [asc/ascq=0x28/0x0]622622 * or power-on, reset [asc/ascq=0x29/0x0], continue.623623 * INQUIRY should not yield UNIT_ATTENTION624624 * but many buggy devices do so anyway. 625625 */626626- if (driver_byte(result) == DRIVER_SENSE &&626626+ if (scsi_status_is_check_condition(result) &&627627 scsi_sense_valid(&sshdr)) {628628 if ((sshdr.sense_key == UNIT_ATTENTION) &&629629 ((sshdr.asc == 0x28) ||···631631 (sshdr.ascq == 0))632632 continue;633633 }634634- } else {634634+ } else if (result == 0) {635635 /*636636 * if nothing was transferred, we try637637 * again. It's a workaround for some USB
···86058605 sdev_printk(KERN_WARNING, sdp,86068606 "START_STOP failed for power mode: %d, result %x\n",86078607 pwr_mode, ret);86088608- if (driver_byte(ret) == DRIVER_SENSE)86088608+ if (ret > 0 && scsi_sense_valid(&sshdr))86098609 scsi_print_sense_hdr(sdp, NULL, &sshdr);86108610 }86118611
+2-3
drivers/scsi/virtio_scsi.c
···161161 min_t(u32,162162 virtio32_to_cpu(vscsi->vdev, resp->sense_len),163163 VIRTIO_SCSI_SENSE_SIZE));164164- if (resp->sense_len)165165- set_driver_byte(sc, DRIVER_SENSE);164164+ set_status_byte(sc, SAM_STAT_CHECK_CONDITION);166165 }167166168167 sc->scsi_done(sc);···354355 if (result == 0 && inq_result[0] >> 5) {355356 /* PQ indicates the LUN is not attached */356357 scsi_remove_device(sdev);357357- } else if (host_byte(result) == DID_BAD_TARGET) {358358+ } else if (result > 0 && host_byte(result) == DID_BAD_TARGET) {358359 /*359360 * If all LUNs of a virtio-scsi device are unplugged360361 * it will respond with BAD TARGET on any INQUIRY
-6
drivers/scsi/vmw_pvscsi.c
···576576 cmd->result = (DID_RESET << 16);577577 } else {578578 cmd->result = (DID_OK << 16) | sdstat;579579- if (sdstat == SAM_STAT_CHECK_CONDITION &&580580- cmd->sense_buffer)581581- cmd->result |= (DRIVER_SENSE << 24);582579 }583580 } else584581 switch (btstat) {···601604 case BTSTAT_LUNMISMATCH:602605 case BTSTAT_TAGREJECT:603606 case BTSTAT_BADMSG:604604- cmd->result = (DRIVER_INVALID << 24);605605- fallthrough;606606-607607 case BTSTAT_HAHARDWARE:608608 case BTSTAT_INVPHASE:609609 case BTSTAT_HATIMEOUT:
+23-20
drivers/scsi/wd33c93.c
···11761176 if (cmd->SCp.Status == ILLEGAL_STATUS_BYTE)11771177 cmd->SCp.Status = lun;11781178 if (cmd->cmnd[0] == REQUEST_SENSE11791179- && cmd->SCp.Status != SAM_STAT_GOOD)11801180- cmd->result =11811181- (cmd->11821182- result & 0x00ffff) | (DID_ERROR << 16);11831183- else11841184- cmd->result =11851185- cmd->SCp.Status | (cmd->SCp.Message << 8);11791179+ && cmd->SCp.Status != SAM_STAT_GOOD) {11801180+ set_host_byte(cmd, DID_ERROR);11811181+ } else {11821182+ set_host_byte(cmd, DID_OK);11831183+ scsi_msg_to_host_byte(cmd, cmd->SCp.Message);11841184+ set_status_byte(cmd, cmd->SCp.Status);11851185+ }11861186 cmd->scsi_done(cmd);1187118711881188/* We are no longer connected to a target - check to see if···12621262 hostdata->connected = NULL;12631263 hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff));12641264 hostdata->state = S_UNCONNECTED;12651265- if (cmd->cmnd[0] == REQUEST_SENSE && cmd->SCp.Status != SAM_STAT_GOOD)12661266- cmd->result =12671267- (cmd->result & 0x00ffff) | (DID_ERROR << 16);12681268- else12691269- cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);12651265+ if (cmd->cmnd[0] == REQUEST_SENSE &&12661266+ cmd->SCp.Status != SAM_STAT_GOOD) {12671267+ set_host_byte(cmd, DID_ERROR);12681268+ } else {12691269+ set_host_byte(cmd, DID_OK);12701270+ scsi_msg_to_host_byte(cmd, cmd->SCp.Message);12711271+ set_status_byte(cmd, cmd->SCp.Status);12721272+ }12701273 cmd->scsi_done(cmd);1271127412721275/* We are no longer connected to a target - check to see if···12981295 hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff));12991296 hostdata->state = S_UNCONNECTED;13001297 DB(DB_INTR, printk(":%d", cmd->SCp.Status))13011301- if (cmd->cmnd[0] == REQUEST_SENSE13021302- && cmd->SCp.Status != SAM_STAT_GOOD)13031303- cmd->result =13041304- (cmd->13051305- result & 0x00ffff) | (DID_ERROR << 16);13061306- else13071307- cmd->result =13081308- cmd->SCp.Status | (cmd->SCp.Message << 8);12981298+ if (cmd->cmnd[0] == REQUEST_SENSE12991299+ && cmd->SCp.Status != SAM_STAT_GOOD) {13001300+ set_host_byte(cmd, DID_ERROR);13011301+ } else {13021302+ set_host_byte(cmd, DID_OK);13031303+ scsi_msg_to_host_byte(cmd, cmd->SCp.Message);13041304+ set_status_byte(cmd, cmd->SCp.Status);13051305+ }13091306 cmd->scsi_done(cmd);13101307 break;13111308 case S_PRE_TMP_DISC:
+7-1
drivers/scsi/xen-scsifront.c
···251251 struct scsi_cmnd *sc;252252 uint32_t id;253253 uint8_t sense_len;254254+ int result;254255255256 id = ring_rsp->rqid;256257 shadow = info->shadow[id];···262261 scsifront_gnttab_done(info, shadow);263262 scsifront_put_rqid(info, id);264263265265- sc->result = ring_rsp->rslt;264264+ result = ring_rsp->rslt;265265+ if (result >> 24)266266+ set_host_byte(sc, DID_ERROR);267267+ else268268+ set_host_byte(sc, host_byte(result));269269+ set_status_byte(sc, result & 0xff);266270 scsi_set_resid(sc, ring_rsp->residual_len);267271268272 sense_len = min_t(uint8_t, VSCSIIF_SENSE_BUFFERSIZE,
···6262 return (lun & 0xff00) == SCSI_W_LUN_BASE;6363}64646565+/**6666+ * scsi_status_is_check_condition - check the status return.6767+ *6868+ * @status: the status passed up from the driver (including host and6969+ * driver components)7070+ *7171+ * This returns true if the status code is SAM_STAT_CHECK_CONDITION.7272+ */7373+static inline int scsi_status_is_check_condition(int status)7474+{7575+ if (status < 0)7676+ return false;7777+ status &= 0xfe;7878+ return status == SAM_STAT_CHECK_CONDITION;7979+}65806681/*6782 * MESSAGE CODES···153138#define DRIVER_OK 0x00 /* Driver status */154139155140/*156156- * These indicate the error that occurred, and what is available.157157- */158158-159159-#define DRIVER_BUSY 0x01160160-#define DRIVER_SOFT 0x02161161-#define DRIVER_MEDIA 0x03162162-#define DRIVER_ERROR 0x04163163-164164-#define DRIVER_INVALID 0x05165165-#define DRIVER_TIMEOUT 0x06166166-#define DRIVER_HARD 0x07167167-#define DRIVER_SENSE 0x08168168-169169-/*170141 * Internal return values.171142 */172143enum scsi_disposition {···181180 * These are set by:182181 *183182 * status byte = set from target device184184- * msg_byte = return status from host adapter itself.183183+ * msg_byte (unused)185184 * host_byte = set by low-level driver to indicate status.186186- * driver_byte = set by mid-level.187185 */188188-#define status_byte(result) (((result) >> 1) & 0x7f)189189-#define msg_byte(result) (((result) >> 8) & 0xff)190186#define host_byte(result) (((result) >> 16) & 0xff)191191-#define driver_byte(result) (((result) >> 24) & 0xff)192187193188#define sense_class(sense) (((sense) >> 4) & 0x7)194189#define sense_error(sense) ((sense) & 0xf)···256259 * This returns true for known good conditions that may be treated as257260 * command completed normally258261 */259259-static inline int scsi_status_is_good(int status)262262+static inline bool scsi_status_is_good(int status)260263{264264+ if (status < 0)265265+ return false;266266+261267 if (host_byte(status) == DID_NO_CONNECT)262262- return 0;268268+ return false;263269264270 /*265271 * FIXME: bit0 is listed as reserved in SCSI-2, but is
+34-4
include/scsi/scsi_cmnd.h
···315315 cmd->result = (cmd->result & 0xffffff00) | status;316316}317317318318-static inline void set_msg_byte(struct scsi_cmnd *cmd, char status)318318+static inline u8 get_status_byte(struct scsi_cmnd *cmd)319319{320320- cmd->result = (cmd->result & 0xffff00ff) | (status << 8);320320+ return cmd->result & 0xff;321321}322322323323static inline void set_host_byte(struct scsi_cmnd *cmd, char status)···325325 cmd->result = (cmd->result & 0xff00ffff) | (status << 16);326326}327327328328-static inline void set_driver_byte(struct scsi_cmnd *cmd, char status)328328+static inline u8 get_host_byte(struct scsi_cmnd *cmd)329329{330330- cmd->result = (cmd->result & 0x00ffffff) | (status << 24);330330+ return (cmd->result >> 16) & 0xff;331331+}332332+333333+/**334334+ * scsi_msg_to_host_byte() - translate message byte335335+ *336336+ * Translate the SCSI parallel message byte to a matching337337+ * host byte setting. A message of COMMAND_COMPLETE indicates338338+ * a successful command execution, any other message indicate339339+ * an error. As the messages themselves only have a meaning340340+ * for the SCSI parallel protocol this function translates341341+ * them into a matching host byte value for SCSI EH.342342+ */343343+static inline void scsi_msg_to_host_byte(struct scsi_cmnd *cmd, u8 msg)344344+{345345+ switch (msg) {346346+ case COMMAND_COMPLETE:347347+ break;348348+ case ABORT_TASK_SET:349349+ set_host_byte(cmd, DID_ABORT);350350+ break;351351+ case TARGET_RESET:352352+ set_host_byte(cmd, DID_RESET);353353+ break;354354+ default:355355+ set_host_byte(cmd, DID_ERROR);356356+ break;357357+ }331358}332359333360static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)···367340368341 return xfer_len;369342}343343+344344+extern void scsi_build_sense(struct scsi_cmnd *scmd, int desc,345345+ u8 key, u8 asc, u8 ascq);370346371347#endif /* _SCSI_SCSI_CMND_H */
+1-21
include/scsi/scsi_proto.h
···202202#define SAM_STAT_ACA_ACTIVE 0x30203203#define SAM_STAT_TASK_ABORTED 0x40204204205205-/*206206- * Status codes. These are deprecated as they are shifted 1 bit right207207- * from those found in the SCSI standards. This causes confusion for208208- * applications that are ported to several OSes. Prefer SAM Status codes209209- * above.210210- */211211-212212-#define GOOD 0x00213213-#define CHECK_CONDITION 0x01214214-#define CONDITION_GOOD 0x02215215-#define BUSY 0x04216216-#define INTERMEDIATE_GOOD 0x08217217-#define INTERMEDIATE_C_GOOD 0x0a218218-#define RESERVATION_CONFLICT 0x0c219219-#define COMMAND_TERMINATED 0x11220220-#define QUEUE_FULL 0x14221221-#define ACA_ACTIVE 0x18222222-#define TASK_ABORTED 0x20223223-224224-#define STATUS_MASK 0xfe225225-205205+#define STATUS_MASK 0xfe226206/*227207 * SENSE KEYS228208 */
+33
include/scsi/sg.h
···131131#define SG_INFO_DIRECT_IO 0x2 /* direct IO requested and performed */132132#define SG_INFO_MIXED_IO 0x4 /* part direct, part indirect IO */133133134134+/*135135+ * Obsolete DRIVER_SENSE driver byte136136+ *137137+ * Originally the SCSI midlayer would set the DRIVER_SENSE driver byte when138138+ * a sense code was generated and a sense buffer was allocated.139139+ * However, as nowadays every scsi command has a sense code allocated this140140+ * distinction became moot as one could check the sense buffer directly.141141+ * Consequently this byte is not set anymore from the midlayer, but SG will142142+ * keep setting this byte to be compatible with previous releases.143143+ */144144+#define DRIVER_SENSE 0x08145145+/* Obsolete driver_byte() declaration */146146+#define driver_byte(result) (((result) >> 24) & 0xff)147147+148148+/*149149+ * Original linux SCSI Status codes. They are shifted 1 bit right150150+ * from those found in the SCSI standards.151151+ */152152+153153+#define GOOD 0x00154154+#define CHECK_CONDITION 0x01155155+#define CONDITION_GOOD 0x02156156+#define BUSY 0x04157157+#define INTERMEDIATE_GOOD 0x08158158+#define INTERMEDIATE_C_GOOD 0x0a159159+#define RESERVATION_CONFLICT 0x0c160160+#define COMMAND_TERMINATED 0x11161161+#define QUEUE_FULL 0x14162162+#define ACA_ACTIVE 0x18163163+#define TASK_ABORTED 0x20164164+165165+/* Obsolete status_byte() declaration */166166+#define status_byte(result) (((result) >> 1) & 0x7f)134167135168typedef struct sg_scsi_id { /* used by SG_GET_SCSI_ID ioctl() */136169 int host_no; /* as in "scsi<n>" where 'n' is one of 0, 1, 2 etc */