Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch '5.14/scsi-result' into 5.14/scsi-staging

Include Hannes' SCSI command result rework in the staging branch.

[mkp: remove DRIVER_SENSE from mpi3mr]

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

+914 -1082
+3 -4
Documentation/scsi/scsi_mid_low_api.rst
··· 1172 1172 of 0 implies a successfully completed command (and all 1173 1173 data (if any) has been transferred to or from the SCSI 1174 1174 target device). 'result' is a 32 bit unsigned integer that 1175 - can be viewed as 4 related bytes. The SCSI status value is 1176 - in the LSB. See include/scsi/scsi.h status_byte(), 1177 - msg_byte(), host_byte() and driver_byte() macros and 1178 - related constants. 1175 + can be viewed as 2 related bytes. The SCSI status value is 1176 + in the LSB. See include/scsi/scsi.h status_byte() and 1177 + host_byte() macros and related constants. 1179 1178 sense_buffer 1180 1179 - an array (maximum size: SCSI_SENSE_BUFFERSIZE bytes) that 1181 1180 should be written when the SCSI status (LSB of 'result')
+1 -1
block/bsg-lib.c
··· 84 84 */ 85 85 hdr->device_status = job->result & 0xff; 86 86 hdr->transport_status = host_byte(job->result); 87 - hdr->driver_status = driver_byte(job->result); 87 + hdr->driver_status = 0; 88 88 hdr->info = 0; 89 89 if (hdr->device_status || hdr->transport_status || hdr->driver_status) 90 90 hdr->info |= SG_INFO_CHECK;
+3 -1
block/bsg.c
··· 96 96 */ 97 97 hdr->device_status = sreq->result & 0xff; 98 98 hdr->transport_status = host_byte(sreq->result); 99 - hdr->driver_status = driver_byte(sreq->result); 99 + hdr->driver_status = 0; 100 + if (scsi_status_is_check_condition(sreq->result)) 101 + hdr->driver_status = DRIVER_SENSE; 100 102 hdr->info = 0; 101 103 if (hdr->device_status || hdr->transport_status || hdr->driver_status) 102 104 hdr->info |= SG_INFO_CHECK;
+8 -5
block/scsi_ioctl.c
··· 254 254 */ 255 255 hdr->status = req->result & 0xff; 256 256 hdr->masked_status = status_byte(req->result); 257 - hdr->msg_status = msg_byte(req->result); 257 + hdr->msg_status = COMMAND_COMPLETE; 258 258 hdr->host_status = host_byte(req->result); 259 - hdr->driver_status = driver_byte(req->result); 259 + hdr->driver_status = 0; 260 + if (scsi_status_is_check_condition(hdr->status)) 261 + hdr->driver_status = DRIVER_SENSE; 260 262 hdr->info = 0; 261 263 if (hdr->masked_status || hdr->host_status || hdr->driver_status) 262 264 hdr->info |= SG_INFO_CHECK; ··· 486 484 break; 487 485 } 488 486 489 - if (bytes && blk_rq_map_kern(q, rq, buffer, bytes, GFP_NOIO)) { 490 - err = DRIVER_ERROR << 24; 491 - goto error; 487 + if (bytes) { 488 + err = blk_rq_map_kern(q, rq, buffer, bytes, GFP_NOIO); 489 + if (err) 490 + goto error; 492 491 } 493 492 494 493 blk_execute_rq(disk, rq, 0);
+14 -16
drivers/ata/libata-scsi.c
··· 196 196 if (!cmd) 197 197 return; 198 198 199 - cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; 200 - 201 - scsi_build_sense_buffer(d_sense, cmd->sense_buffer, sk, asc, ascq); 199 + scsi_build_sense(cmd, d_sense, sk, asc, ascq); 202 200 } 203 201 204 202 void ata_scsi_set_sense_information(struct ata_device *dev, ··· 407 409 cmd_result = scsi_execute(scsidev, scsi_cmd, data_dir, argbuf, argsize, 408 410 sensebuf, &sshdr, (10*HZ), 5, 0, 0, NULL); 409 411 410 - if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */ 412 + if (cmd_result < 0) { 413 + rc = cmd_result; 414 + goto error; 415 + } 416 + if (scsi_sense_valid(&sshdr)) {/* sense data available */ 411 417 u8 *desc = sensebuf + 8; 412 - cmd_result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */ 413 418 414 419 /* If we set cc then ATA pass-through will cause a 415 420 * check condition even if no error. Filter that. */ 416 - if (cmd_result & SAM_STAT_CHECK_CONDITION) { 421 + if (scsi_status_is_check_condition(cmd_result)) { 417 422 if (sshdr.sense_key == RECOVERED_ERROR && 418 423 sshdr.asc == 0 && sshdr.ascq == 0x1d) 419 424 cmd_result &= ~SAM_STAT_CHECK_CONDITION; ··· 491 490 cmd_result = scsi_execute(scsidev, scsi_cmd, DMA_NONE, NULL, 0, 492 491 sensebuf, &sshdr, (10*HZ), 5, 0, 0, NULL); 493 492 494 - if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */ 493 + if (cmd_result < 0) { 494 + rc = cmd_result; 495 + goto error; 496 + } 497 + if (scsi_sense_valid(&sshdr)) {/* sense data available */ 495 498 u8 *desc = sensebuf + 8; 496 - cmd_result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */ 497 499 498 500 /* If we set cc then ATA pass-through will cause a 499 501 * check condition even if no error. Filter that. */ ··· 642 638 if (cmd->request->rq_flags & RQF_QUIET) 643 639 qc->flags |= ATA_QCFLAG_QUIET; 644 640 } else { 645 - cmd->result = (DID_OK << 16) | (QUEUE_FULL << 1); 641 + cmd->result = (DID_OK << 16) | SAM_STAT_TASK_SET_FULL; 646 642 cmd->scsi_done(cmd); 647 643 } 648 644 ··· 862 858 863 859 memset(sb, 0, SCSI_SENSE_BUFFERSIZE); 864 860 865 - cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; 866 - 867 861 /* 868 862 * Use ata_to_sense_error() to map status register bits 869 863 * onto sense key, asc & ascq. ··· 876 874 * ATA PASS-THROUGH INFORMATION AVAILABLE 877 875 * Always in descriptor format sense. 878 876 */ 879 - scsi_build_sense_buffer(1, cmd->sense_buffer, 880 - RECOVERED_ERROR, 0, 0x1D); 877 + scsi_build_sense(cmd, 1, RECOVERED_ERROR, 0, 0x1D); 881 878 } 882 879 883 880 if ((cmd->sense_buffer[0] & 0x7f) >= 0x72) { ··· 957 956 u8 sense_key, asc, ascq; 958 957 959 958 memset(sb, 0, SCSI_SENSE_BUFFERSIZE); 960 - 961 - cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; 962 959 963 960 if (ata_dev_disabled(dev)) { 964 961 /* Device disabled after error recovery */ ··· 4195 4196 4196 4197 case REQUEST_SENSE: 4197 4198 ata_scsi_set_sense(dev, cmd, 0, 0, 0); 4198 - cmd->result = (DRIVER_SENSE << 24); 4199 4199 break; 4200 4200 4201 4201 /* if we reach this, then writeback caching is disabled,
+1 -1
drivers/infiniband/ulp/srp/ib_srp.c
··· 2232 2232 * to reduce queue depth temporarily. 2233 2233 */ 2234 2234 scmnd->result = len == -ENOMEM ? 2235 - DID_OK << 16 | QUEUE_FULL << 1 : DID_ERROR << 16; 2235 + DID_OK << 16 | SAM_STAT_TASK_SET_FULL : DID_ERROR << 16; 2236 2236 goto err_iu; 2237 2237 } 2238 2238
+1 -4
drivers/s390/scsi/zfcp_scsi.c
··· 856 856 */ 857 857 void zfcp_scsi_dif_sense_error(struct scsi_cmnd *scmd, int ascq) 858 858 { 859 - scsi_build_sense_buffer(1, scmd->sense_buffer, 860 - ILLEGAL_REQUEST, 0x10, ascq); 861 - set_driver_byte(scmd, DRIVER_SENSE); 862 - scmd->result |= SAM_STAT_CHECK_CONDITION; 859 + scsi_build_sense(scmd, 1, ILLEGAL_REQUEST, 0x10, ascq); 863 860 set_host_byte(scmd, DID_SOFT_ERROR); 864 861 } 865 862
+1 -1
drivers/scsi/3w-9xxx.c
··· 1338 1338 /* If error, command failed */ 1339 1339 if (error == 1) { 1340 1340 /* Ask for a host reset */ 1341 - cmd->result = (DID_OK << 16) | (CHECK_CONDITION << 1); 1341 + cmd->result = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION; 1342 1342 } 1343 1343 1344 1344 /* Report residual bytes for single sgl */
+3 -3
drivers/scsi/3w-xxxx.c
··· 429 429 /* Additional sense code qualifier */ 430 430 tw_dev->srb[request_id]->sense_buffer[13] = tw_sense_table[i][3]; 431 431 432 - tw_dev->srb[request_id]->result = (DID_OK << 16) | (CHECK_CONDITION << 1); 432 + tw_dev->srb[request_id]->result = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION; 433 433 return TW_ISR_DONT_RESULT; /* Special case for isr to not over-write result */ 434 434 } 435 435 } ··· 1977 1977 printk(KERN_NOTICE "3w-xxxx: scsi%d: Unknown scsi opcode: 0x%x\n", tw_dev->host->host_no, *command); 1978 1978 tw_dev->state[request_id] = TW_S_COMPLETED; 1979 1979 tw_state_request_finish(tw_dev, request_id); 1980 - scsi_build_sense_buffer(1, SCpnt->sense_buffer, ILLEGAL_REQUEST, 0x20, 0); 1980 + scsi_build_sense(SCpnt, 1, ILLEGAL_REQUEST, 0x20, 0); 1981 1981 done(SCpnt); 1982 1982 retval = 0; 1983 1983 } ··· 2159 2159 /* If error, command failed */ 2160 2160 if (error == 1) { 2161 2161 /* Ask for a host reset */ 2162 - tw_dev->srb[request_id]->result = (DID_OK << 16) | (CHECK_CONDITION << 1); 2162 + tw_dev->srb[request_id]->result = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION; 2163 2163 } 2164 2164 2165 2165 /* Now complete the io */
+3 -3
drivers/scsi/53c700.c
··· 978 978 if (NCR_700_get_tag_neg_state(SCp->device) == NCR_700_DURING_TAG_NEGOTIATION) 979 979 NCR_700_set_tag_neg_state(SCp->device, 980 980 NCR_700_FINISHED_TAG_NEGOTIATION); 981 - 981 + 982 982 /* check for contingent allegiance conditions */ 983 - if (hostdata->status[0] >> 1 == CHECK_CONDITION || 984 - hostdata->status[0] >> 1 == COMMAND_TERMINATED) { 983 + if (hostdata->status[0] == SAM_STAT_CHECK_CONDITION || 984 + hostdata->status[0] == SAM_STAT_COMMAND_TERMINATED) { 985 985 struct NCR_700_command_slot *slot = 986 986 (struct NCR_700_command_slot *)SCp->host_scribble; 987 987 if(slot->flags == NCR_700_FLAG_AUTOSENSE) {
+68 -95
drivers/scsi/FlashPoint.c
··· 304 304 305 305 } SCCBSCAM_INFO; 306 306 307 - #define SCSI_REQUEST_SENSE 0x03 308 - #define SCSI_READ 0x08 309 - #define SCSI_WRITE 0x0A 310 - #define SCSI_START_STOP_UNIT 0x1B 311 - #define SCSI_READ_EXTENDED 0x28 312 - #define SCSI_WRITE_EXTENDED 0x2A 313 - #define SCSI_WRITE_AND_VERIFY 0x2E 314 - 315 - #define SSGOOD 0x00 316 - #define SSCHECK 0x02 317 - #define SSQ_FULL 0x28 318 - 319 - #define SMCMD_COMP 0x00 320 - #define SMEXT 0x01 321 - #define SMSAVE_DATA_PTR 0x02 322 - #define SMREST_DATA_PTR 0x03 323 - #define SMDISC 0x04 324 - #define SMABORT 0x06 325 - #define SMREJECT 0x07 326 - #define SMNO_OP 0x08 327 - #define SMPARITY 0x09 328 - #define SMDEV_RESET 0x0C 329 - #define SMABORT_TAG 0x0D 330 - #define SMINIT_RECOVERY 0x0F 331 - #define SMREL_RECOVERY 0x10 332 307 333 308 #define SMIDENT 0x80 334 309 #define DISC_PRIV 0x40 335 310 336 - #define SMSYNC 0x01 337 - #define SMWDTR 0x03 338 311 #define SM8BIT 0x00 339 312 #define SM16BIT 0x01 340 - #define SMIGNORWR 0x23 /* Ignore Wide Residue */ 341 313 342 314 #define SIX_BYTE_CMD 0x06 343 315 #define TWELVE_BYTE_CMD 0x0C ··· 1632 1660 p_Sccb->Sccb_scsistat = 1633 1661 ABORT_ST; 1634 1662 p_Sccb->Sccb_scsimsg = 1635 - SMABORT_TAG; 1663 + ABORT_TASK; 1636 1664 1637 1665 if (((struct sccb_card *) 1638 1666 pCurrCard)->currentSCCB == ··· 1784 1812 FPT_phaseChkFifo(ioport, thisCard); 1785 1813 1786 1814 if (RD_HARPOON(ioport + hp_gp_reg_1) == 1787 - SMSAVE_DATA_PTR) { 1815 + SAVE_POINTERS) { 1788 1816 1789 1817 WR_HARPOON(ioport + hp_gp_reg_1, 0x00); 1790 1818 currSCCB->Sccb_XferState |= F_NO_DATA_YET; ··· 1837 1865 FPT_phaseChkFifo(ioport, thisCard); 1838 1866 1839 1867 if (RD_HARPOON(ioport + hp_gp_reg_1) == 1840 - SMSAVE_DATA_PTR) { 1868 + SAVE_POINTERS) { 1841 1869 WR_HARPOON(ioport + hp_gp_reg_1, 0x00); 1842 1870 currSCCB->Sccb_XferState |= 1843 1871 F_NO_DATA_YET; ··· 2230 2258 WR_HARPOON(port + hp_fiforead, 0); 2231 2259 WR_HARPOON(port + hp_fifowrite, 0); 2232 2260 if (pCurrSCCB != NULL) { 2233 - pCurrSCCB->Sccb_scsimsg = SMPARITY; 2261 + pCurrSCCB->Sccb_scsimsg = MSG_PARITY_ERROR; 2234 2262 } 2235 2263 message = 0x00; 2236 2264 do { ··· 2383 2411 2384 2412 WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + NP); 2385 2413 2386 - currSCCB->Sccb_scsimsg = SMDEV_RESET; 2414 + currSCCB->Sccb_scsimsg = TARGET_RESET; 2387 2415 2388 2416 WR_HARPOON(port + hp_autostart_3, (SELECT + SELCHK_STRT)); 2389 2417 auto_loaded = 1; ··· 2730 2758 if (message == 0) { 2731 2759 msgRetryCount++; 2732 2760 if (msgRetryCount == 1) { 2733 - FPT_SendMsg(port, SMPARITY); 2761 + FPT_SendMsg(port, MSG_PARITY_ERROR); 2734 2762 } else { 2735 - FPT_SendMsg(port, SMDEV_RESET); 2763 + FPT_SendMsg(port, TARGET_RESET); 2736 2764 2737 2765 FPT_sssyncv(port, our_target, NARROW_SCSI, 2738 2766 currTar_Info); ··· 2832 2860 2833 2861 WR_HARPOON(port + hp_portctrl_0, 0x00); 2834 2862 2835 - if ((message == SMABORT) || (message == SMDEV_RESET) || 2836 - (message == SMABORT_TAG)) { 2863 + if ((message == ABORT_TASK_SET) || (message == TARGET_RESET) || 2864 + (message == ABORT_TASK)) { 2837 2865 while (! 2838 2866 (RDW_HARPOON((port + hp_intstat)) & 2839 2867 (BUS_FREE | PHASE))) { ··· 2865 2893 2866 2894 currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; 2867 2895 2868 - if (message == SMREST_DATA_PTR) { 2896 + if (message == RESTORE_POINTERS) { 2869 2897 if (!(currSCCB->Sccb_XferState & F_NO_DATA_YET)) { 2870 2898 currSCCB->Sccb_ATC = currSCCB->Sccb_savedATC; 2871 2899 ··· 2877 2905 (AUTO_IMMED + DISCONNECT_START)); 2878 2906 } 2879 2907 2880 - else if (message == SMCMD_COMP) { 2908 + else if (message == COMMAND_COMPLETE) { 2881 2909 2882 2910 if (currSCCB->Sccb_scsistat == SELECT_Q_ST) { 2883 2911 currTar_Info->TarStatus &= ··· 2889 2917 2890 2918 } 2891 2919 2892 - else if ((message == SMNO_OP) || (message >= SMIDENT) 2893 - || (message == SMINIT_RECOVERY) || (message == SMREL_RECOVERY)) { 2920 + else if ((message == NOP) || (message >= IDENTIFY_BASE) || 2921 + (message == INITIATE_RECOVERY) || 2922 + (message == RELEASE_RECOVERY)) { 2894 2923 2895 2924 ACCEPT_MSG(port); 2896 2925 WR_HARPOON(port + hp_autostart_1, 2897 2926 (AUTO_IMMED + DISCONNECT_START)); 2898 2927 } 2899 2928 2900 - else if (message == SMREJECT) { 2929 + else if (message == MESSAGE_REJECT) { 2901 2930 2902 2931 if ((currSCCB->Sccb_scsistat == SELECT_SN_ST) || 2903 2932 (currSCCB->Sccb_scsistat == SELECT_WN_ST) || ··· 2999 3026 } 3000 3027 } 3001 3028 3002 - else if (message == SMEXT) { 3029 + else if (message == EXTENDED_MESSAGE) { 3003 3030 3004 3031 ACCEPT_MSG(port); 3005 3032 FPT_shandem(port, p_card, currSCCB); 3006 3033 } 3007 3034 3008 - else if (message == SMIGNORWR) { 3035 + else if (message == IGNORE_WIDE_RESIDUE) { 3009 3036 3010 3037 ACCEPT_MSG(port); /* ACK the RESIDUE MSG */ 3011 3038 3012 3039 message = FPT_sfm(port, currSCCB); 3013 3040 3014 - if (currSCCB->Sccb_scsimsg != SMPARITY) 3041 + if (currSCCB->Sccb_scsimsg != MSG_PARITY_ERROR) 3015 3042 ACCEPT_MSG(port); 3016 3043 WR_HARPOON(port + hp_autostart_1, 3017 3044 (AUTO_IMMED + DISCONNECT_START)); ··· 3020 3047 else { 3021 3048 3022 3049 currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL; 3023 - currSCCB->Sccb_scsimsg = SMREJECT; 3050 + currSCCB->Sccb_scsimsg = MESSAGE_REJECT; 3024 3051 3025 3052 ACCEPT_MSG_ATN(port); 3026 3053 WR_HARPOON(port + hp_autostart_1, ··· 3046 3073 message = FPT_sfm(port, pCurrSCCB); 3047 3074 if (message) { 3048 3075 3049 - if (message == SMSYNC) { 3076 + if (message == EXTENDED_SDTR) { 3050 3077 3051 3078 if (length == 0x03) { 3052 3079 ··· 3054 3081 FPT_stsyncn(port, p_card); 3055 3082 } else { 3056 3083 3057 - pCurrSCCB->Sccb_scsimsg = SMREJECT; 3084 + pCurrSCCB->Sccb_scsimsg = MESSAGE_REJECT; 3058 3085 ACCEPT_MSG_ATN(port); 3059 3086 } 3060 - } else if (message == SMWDTR) { 3087 + } else if (message == EXTENDED_WDTR) { 3061 3088 3062 3089 if (length == 0x02) { 3063 3090 ··· 3065 3092 FPT_stwidn(port, p_card); 3066 3093 } else { 3067 3094 3068 - pCurrSCCB->Sccb_scsimsg = SMREJECT; 3095 + pCurrSCCB->Sccb_scsimsg = MESSAGE_REJECT; 3069 3096 ACCEPT_MSG_ATN(port); 3070 3097 3071 3098 WR_HARPOON(port + hp_autostart_1, ··· 3074 3101 } 3075 3102 } else { 3076 3103 3077 - pCurrSCCB->Sccb_scsimsg = SMREJECT; 3104 + pCurrSCCB->Sccb_scsimsg = MESSAGE_REJECT; 3078 3105 ACCEPT_MSG_ATN(port); 3079 3106 3080 3107 WR_HARPOON(port + hp_autostart_1, 3081 3108 (AUTO_IMMED + DISCONNECT_START)); 3082 3109 } 3083 3110 } else { 3084 - if (pCurrSCCB->Sccb_scsimsg != SMPARITY) 3111 + if (pCurrSCCB->Sccb_scsimsg != MSG_PARITY_ERROR) 3085 3112 ACCEPT_MSG(port); 3086 3113 WR_HARPOON(port + hp_autostart_1, 3087 3114 (AUTO_IMMED + DISCONNECT_START)); 3088 3115 } 3089 3116 } else { 3090 - if (pCurrSCCB->Sccb_scsimsg == SMPARITY) 3117 + if (pCurrSCCB->Sccb_scsimsg == MSG_PARITY_ERROR) 3091 3118 WR_HARPOON(port + hp_autostart_1, 3092 3119 (AUTO_IMMED + DISCONNECT_START)); 3093 3120 } ··· 3121 3148 WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + CMDPZ); 3122 3149 3123 3150 WRW_HARPOON((port + SYNC_MSGS + 0), 3124 - (MPM_OP + AMSG_OUT + SMEXT)); 3151 + (MPM_OP + AMSG_OUT + EXTENDED_MESSAGE)); 3125 3152 WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x03)); 3126 3153 WRW_HARPOON((port + SYNC_MSGS + 4), 3127 - (MPM_OP + AMSG_OUT + SMSYNC)); 3154 + (MPM_OP + AMSG_OUT + EXTENDED_SDTR)); 3128 3155 3129 3156 if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_20MB) 3130 3157 ··· 3194 3221 3195 3222 sync_msg = FPT_sfm(port, currSCCB); 3196 3223 3197 - if ((sync_msg == 0x00) && (currSCCB->Sccb_scsimsg == SMPARITY)) { 3224 + if ((sync_msg == 0x00) && (currSCCB->Sccb_scsimsg == MSG_PARITY_ERROR)) { 3198 3225 WR_HARPOON(port + hp_autostart_1, 3199 3226 (AUTO_IMMED + DISCONNECT_START)); 3200 3227 return; ··· 3204 3231 3205 3232 offset = FPT_sfm(port, currSCCB); 3206 3233 3207 - if ((offset == 0x00) && (currSCCB->Sccb_scsimsg == SMPARITY)) { 3234 + if ((offset == 0x00) && (currSCCB->Sccb_scsimsg == MSG_PARITY_ERROR)) { 3208 3235 WR_HARPOON(port + hp_autostart_1, 3209 3236 (AUTO_IMMED + DISCONNECT_START)); 3210 3237 return; ··· 3316 3343 unsigned char offset) 3317 3344 { 3318 3345 ARAM_ACCESS(port); 3319 - WRW_HARPOON((port + SYNC_MSGS + 0), (MPM_OP + AMSG_OUT + SMEXT)); 3346 + WRW_HARPOON((port + SYNC_MSGS + 0), 3347 + (MPM_OP + AMSG_OUT + EXTENDED_MESSAGE)); 3320 3348 WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x03)); 3321 - WRW_HARPOON((port + SYNC_MSGS + 4), (MPM_OP + AMSG_OUT + SMSYNC)); 3349 + WRW_HARPOON((port + SYNC_MSGS + 4), 3350 + (MPM_OP + AMSG_OUT + EXTENDED_SDTR)); 3322 3351 WRW_HARPOON((port + SYNC_MSGS + 6), (MPM_OP + AMSG_OUT + sync_pulse)); 3323 3352 WRW_HARPOON((port + SYNC_MSGS + 8), (RAT_OP)); 3324 3353 WRW_HARPOON((port + SYNC_MSGS + 10), (MPM_OP + AMSG_OUT + offset)); ··· 3363 3388 WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + CMDPZ); 3364 3389 3365 3390 WRW_HARPOON((port + SYNC_MSGS + 0), 3366 - (MPM_OP + AMSG_OUT + SMEXT)); 3391 + (MPM_OP + AMSG_OUT + EXTENDED_MESSAGE)); 3367 3392 WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x02)); 3368 3393 WRW_HARPOON((port + SYNC_MSGS + 4), 3369 - (MPM_OP + AMSG_OUT + SMWDTR)); 3394 + (MPM_OP + AMSG_OUT + EXTENDED_WDTR)); 3370 3395 WRW_HARPOON((port + SYNC_MSGS + 6), (RAT_OP)); 3371 3396 WRW_HARPOON((port + SYNC_MSGS + 8), 3372 3397 (MPM_OP + AMSG_OUT + SM16BIT)); ··· 3411 3436 3412 3437 width = FPT_sfm(port, currSCCB); 3413 3438 3414 - if ((width == 0x00) && (currSCCB->Sccb_scsimsg == SMPARITY)) { 3439 + if ((width == 0x00) && (currSCCB->Sccb_scsimsg == MSG_PARITY_ERROR)) { 3415 3440 WR_HARPOON(port + hp_autostart_1, 3416 3441 (AUTO_IMMED + DISCONNECT_START)); 3417 3442 return; ··· 3474 3499 static void FPT_siwidr(u32 port, unsigned char width) 3475 3500 { 3476 3501 ARAM_ACCESS(port); 3477 - WRW_HARPOON((port + SYNC_MSGS + 0), (MPM_OP + AMSG_OUT + SMEXT)); 3502 + WRW_HARPOON((port + SYNC_MSGS + 0), 3503 + (MPM_OP + AMSG_OUT + EXTENDED_MESSAGE)); 3478 3504 WRW_HARPOON((port + SYNC_MSGS + 2), (MPM_OP + AMSG_OUT + 0x02)); 3479 - WRW_HARPOON((port + SYNC_MSGS + 4), (MPM_OP + AMSG_OUT + SMWDTR)); 3505 + WRW_HARPOON((port + SYNC_MSGS + 4), 3506 + (MPM_OP + AMSG_OUT + EXTENDED_WDTR)); 3480 3507 WRW_HARPOON((port + SYNC_MSGS + 6), (RAT_OP)); 3481 3508 WRW_HARPOON((port + SYNC_MSGS + 8), (MPM_OP + AMSG_OUT + width)); 3482 3509 WRW_HARPOON((port + SYNC_MSGS + 10), (BRH_OP + ALWAYS + NP)); ··· 3659 3682 } 3660 3683 3661 3684 currSCCB->CdbLength = SIX_BYTE_CMD; 3662 - currSCCB->Cdb[0] = SCSI_REQUEST_SENSE; 3685 + currSCCB->Cdb[0] = REQUEST_SENSE; 3663 3686 currSCCB->Cdb[1] = currSCCB->Cdb[1] & (unsigned char)0xE0; /*Keep LUN. */ 3664 3687 currSCCB->Cdb[2] = 0x00; 3665 3688 currSCCB->Cdb[3] = 0x00; ··· 3916 3939 */ 3917 3940 if ((currTar_Info->TarStatus & TAR_ALLOW_DISC) || 3918 3941 (currTar_Info->TarStatus & TAG_Q_TRYING)) { 3919 - p_sccb->Sccb_idmsg = 3920 - (unsigned char)(SMIDENT | DISC_PRIV) | p_sccb->Lun; 3921 - } 3922 - 3923 - else { 3924 - 3925 - p_sccb->Sccb_idmsg = (unsigned char)SMIDENT | p_sccb->Lun; 3942 + p_sccb->Sccb_idmsg = IDENTIFY(true, p_sccb->Lun); 3943 + } else { 3944 + p_sccb->Sccb_idmsg = IDENTIFY(false, p_sccb->Lun); 3926 3945 } 3927 3946 3928 3947 p_sccb->HostStatus = 0x00; ··· 3935 3962 */ 3936 3963 p_sccb->Sccb_scsistat = BUS_FREE_ST; 3937 3964 p_sccb->SccbStatus = SCCB_IN_PROCESS; 3938 - p_sccb->Sccb_scsimsg = SMNO_OP; 3965 + p_sccb->Sccb_scsimsg = NOP; 3939 3966 3940 3967 } 3941 3968 ··· 4140 4167 message = currSCCB->Sccb_scsimsg; 4141 4168 scsiID = currSCCB->TargID; 4142 4169 4143 - if (message == SMDEV_RESET) { 4170 + if (message == TARGET_RESET) { 4144 4171 4145 4172 currTar_Info = &FPT_sccbMgrTbl[p_card][scsiID]; 4146 4173 currTar_Info->TarSyncCtrl = 0; ··· 4176 4203 4177 4204 else if (currSCCB->Sccb_scsistat < COMMAND_ST) { 4178 4205 4179 - if (message == SMNO_OP) { 4206 + if (message == NOP) { 4180 4207 currSCCB->Sccb_MGRFlags |= F_DEV_SELECTED; 4181 4208 4182 4209 FPT_ssel(port, p_card); ··· 4184 4211 } 4185 4212 } else { 4186 4213 4187 - if (message == SMABORT) 4214 + if (message == ABORT_TASK_SET) 4188 4215 4189 4216 FPT_queueFlushSccb(p_card, SCCB_COMPLETE); 4190 4217 } 4191 4218 4192 4219 } else { 4193 - message = SMABORT; 4220 + message = ABORT_TASK_SET; 4194 4221 } 4195 4222 4196 4223 WRW_HARPOON((port + hp_intstat), (BUS_FREE | PHASE | XFER_CNT_0)); ··· 4205 4232 4206 4233 WR_HARPOON(port + hp_portctrl_0, 0x00); 4207 4234 4208 - if ((message == SMABORT) || (message == SMDEV_RESET) || 4209 - (message == SMABORT_TAG)) { 4235 + if ((message == ABORT_TASK_SET) || (message == TARGET_RESET) || 4236 + (message == ABORT_TASK)) { 4210 4237 4211 4238 while (!(RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | PHASE))) { 4212 4239 } ··· 4248 4275 4249 4276 else { 4250 4277 4251 - if (message == SMPARITY) { 4252 - currSCCB->Sccb_scsimsg = SMNO_OP; 4278 + if (message == MSG_PARITY_ERROR) { 4279 + currSCCB->Sccb_scsimsg = NOP; 4253 4280 WR_HARPOON(port + hp_autostart_1, 4254 4281 (AUTO_IMMED + DISCONNECT_START)); 4255 4282 } else { ··· 4279 4306 } 4280 4307 4281 4308 message = RD_HARPOON(port + hp_scsidata_0); 4282 - if ((message == SMDISC) || (message == SMSAVE_DATA_PTR)) { 4309 + if ((message == DISCONNECT) || (message == SAVE_POINTERS)) { 4283 4310 4284 4311 WR_HARPOON(port + hp_autostart_1, 4285 4312 (AUTO_IMMED + END_DATA_START)); ··· 4294 4321 FPT_sdecm(message, port, p_card); 4295 4322 4296 4323 } else { 4297 - if (currSCCB->Sccb_scsimsg != SMPARITY) 4324 + if (currSCCB->Sccb_scsimsg != MSG_PARITY_ERROR) 4298 4325 ACCEPT_MSG(port); 4299 4326 WR_HARPOON(port + hp_autostart_1, 4300 4327 (AUTO_IMMED + DISCONNECT_START)); ··· 4324 4351 4325 4352 currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL; 4326 4353 currSCCB->Sccb_scsistat = ABORT_ST; 4327 - currSCCB->Sccb_scsimsg = SMABORT; 4354 + currSCCB->Sccb_scsimsg = ABORT_TASK_SET; 4328 4355 } 4329 4356 4330 4357 ACCEPT_MSG_ATN(port); ··· 4623 4650 4624 4651 FPT_sccbMgrTbl[p_card][currSCCB->TargID].TarLUN_CA = 0; 4625 4652 4626 - if (status_byte != SSGOOD) { 4653 + if (status_byte != SAM_STAT_GOOD) { 4627 4654 4628 - if (status_byte == SSQ_FULL) { 4655 + if (status_byte == SAM_STAT_TASK_SET_FULL) { 4629 4656 4630 4657 if (((FPT_BL_Card[p_card].globalFlags & F_CONLUN_IO) && 4631 4658 ((FPT_sccbMgrTbl[p_card][currSCCB->TargID]. ··· 4757 4784 4758 4785 } 4759 4786 4760 - if (status_byte == SSCHECK) { 4787 + if (status_byte == SAM_STAT_CHECK_CONDITION) { 4761 4788 if (FPT_BL_Card[p_card].globalFlags & F_DO_RENEGO) { 4762 4789 if (FPT_sccbMgrTbl[p_card][currSCCB->TargID]. 4763 4790 TarEEValue & EE_SYNC_MASK) { ··· 4779 4806 currSCCB->SccbStatus = SCCB_ERROR; 4780 4807 currSCCB->TargetStatus = status_byte; 4781 4808 4782 - if (status_byte == SSCHECK) { 4809 + if (status_byte == SAM_STAT_CHECK_CONDITION) { 4783 4810 4784 4811 FPT_sccbMgrTbl[p_card][currSCCB->TargID]. 4785 4812 TarLUN_CA = 1; ··· 6841 6868 if ((p_sccb-> 6842 6869 ControlByte & (SCCB_DATA_XFER_OUT | SCCB_DATA_XFER_IN)) 6843 6870 && (p_sccb->HostStatus == SCCB_COMPLETE) 6844 - && (p_sccb->TargetStatus != SSCHECK)) 6871 + && (p_sccb->TargetStatus != SAM_STAT_CHECK_CONDITION)) 6845 6872 6846 - if ((SCSIcmd == SCSI_READ) || 6847 - (SCSIcmd == SCSI_WRITE) || 6848 - (SCSIcmd == SCSI_READ_EXTENDED) || 6849 - (SCSIcmd == SCSI_WRITE_EXTENDED) || 6850 - (SCSIcmd == SCSI_WRITE_AND_VERIFY) || 6851 - (SCSIcmd == SCSI_START_STOP_UNIT) || 6873 + if ((SCSIcmd == READ_6) || 6874 + (SCSIcmd == WRITE_6) || 6875 + (SCSIcmd == READ_10) || 6876 + (SCSIcmd == WRITE_10) || 6877 + (SCSIcmd == WRITE_VERIFY) || 6878 + (SCSIcmd == START_STOP) || 6852 6879 (pCurrCard->globalFlags & F_NO_FILTER) 6853 6880 ) 6854 6881 p_sccb->HostStatus = SCCB_DATA_UNDER_RUN;
+5 -5
drivers/scsi/NCR5380.c
··· 538 538 539 539 if (hostdata->sensing == cmd) { 540 540 /* Autosense processing ends here */ 541 - if (status_byte(cmd->result) != GOOD) { 541 + if (get_status_byte(cmd) != SAM_STAT_GOOD) { 542 542 scsi_eh_restore_cmnd(cmd, &hostdata->ses); 543 543 } else { 544 544 scsi_eh_restore_cmnd(cmd, &hostdata->ses); 545 - set_driver_byte(cmd, DRIVER_SENSE); 545 + set_status_byte(cmd, SAM_STAT_CHECK_CONDITION); 546 546 } 547 547 hostdata->sensing = NULL; 548 548 } ··· 1815 1815 1816 1816 switch (tmp) { 1817 1817 case ABORT: 1818 + set_host_byte(cmd, DID_ABORT); 1819 + /* fallthrough */ 1818 1820 case COMMAND_COMPLETE: 1819 1821 /* Accept message by clearing ACK */ 1820 1822 sink = 1; ··· 1828 1826 hostdata->connected = NULL; 1829 1827 hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun); 1830 1828 1831 - cmd->result &= ~0xffff; 1832 - cmd->result |= cmd->SCp.Status; 1833 - cmd->result |= cmd->SCp.Message << 8; 1829 + set_status_byte(cmd, cmd->SCp.Status); 1834 1830 1835 1831 set_resid_from_SCp(cmd); 1836 1832
-4
drivers/scsi/advansys.c
··· 5964 5964 ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n"); 5965 5965 ASC_DBG_PRT_SENSE(2, scp->sense_buffer, 5966 5966 SCSI_SENSE_BUFFERSIZE); 5967 - set_driver_byte(scp, DRIVER_SENSE); 5968 5967 } 5969 5968 break; 5970 5969 ··· 6714 6715 ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n"); 6715 6716 ASC_DBG_PRT_SENSE(2, scp->sense_buffer, 6716 6717 SCSI_SENSE_BUFFERSIZE); 6717 - set_driver_byte(scp, DRIVER_SENSE); 6718 6718 } 6719 6719 break; 6720 6720 ··· 6728 6730 case QD_ABORTED_BY_HOST: 6729 6731 ASC_DBG(1, "QD_ABORTED_BY_HOST\n"); 6730 6732 set_status_byte(scp, qdonep->d3.scsi_stat); 6731 - set_msg_byte(scp, qdonep->d3.scsi_msg); 6732 6733 set_host_byte(scp, DID_ABORT); 6733 6734 break; 6734 6735 6735 6736 default: 6736 6737 ASC_DBG(1, "done_stat 0x%x\n", qdonep->d3.done_stat); 6737 6738 set_status_byte(scp, qdonep->d3.scsi_stat); 6738 - set_msg_byte(scp, qdonep->d3.scsi_msg); 6739 6739 set_host_byte(scp, DID_ERROR); 6740 6740 break; 6741 6741 }
+18 -15
drivers/scsi/aha152x.c
··· 619 619 static irqreturn_t intr(int irq, void *dev_id); 620 620 static void reset_ports(struct Scsi_Host *shpnt); 621 621 static void aha152x_error(struct Scsi_Host *shpnt, char *msg); 622 - static void done(struct Scsi_Host *shpnt, int error); 622 + static void done(struct Scsi_Host *shpnt, unsigned char status_byte, 623 + unsigned char host_byte); 623 624 624 625 /* diagnostics */ 625 626 static void show_command(struct scsi_cmnd * ptr); ··· 1272 1271 * Internal done function 1273 1272 * 1274 1273 */ 1275 - static void done(struct Scsi_Host *shpnt, int error) 1274 + static void done(struct Scsi_Host *shpnt, unsigned char status_byte, 1275 + unsigned char host_byte) 1276 1276 { 1277 1277 if (CURRENT_SC) { 1278 1278 if(DONE_SC) ··· 1283 1281 1284 1282 DONE_SC = CURRENT_SC; 1285 1283 CURRENT_SC = NULL; 1286 - DONE_SC->result = error; 1284 + set_status_byte(DONE_SC, status_byte); 1285 + set_host_byte(DONE_SC, host_byte); 1287 1286 } else 1288 1287 printk(KERN_ERR "aha152x: done() called outside of command\n"); 1289 1288 } ··· 1379 1376 1380 1377 if(CURRENT_SC->SCp.phase & completed) { 1381 1378 /* target sent COMMAND COMPLETE */ 1382 - done(shpnt, (CURRENT_SC->SCp.Status & 0xff) | ((CURRENT_SC->SCp.Message & 0xff) << 8) | (DID_OK << 16)); 1379 + done(shpnt, CURRENT_SC->SCp.Status, DID_OK); 1383 1380 1384 1381 } else if(CURRENT_SC->SCp.phase & aborted) { 1385 - done(shpnt, (CURRENT_SC->SCp.Status & 0xff) | ((CURRENT_SC->SCp.Message & 0xff) << 8) | (DID_ABORT << 16)); 1382 + done(shpnt, CURRENT_SC->SCp.Status, DID_ABORT); 1386 1383 1387 1384 } else if(CURRENT_SC->SCp.phase & resetted) { 1388 - done(shpnt, (CURRENT_SC->SCp.Status & 0xff) | ((CURRENT_SC->SCp.Message & 0xff) << 8) | (DID_RESET << 16)); 1385 + done(shpnt, CURRENT_SC->SCp.Status, DID_RESET); 1389 1386 1390 1387 } else if(CURRENT_SC->SCp.phase & disconnected) { 1391 1388 /* target sent DISCONNECT */ ··· 1397 1394 CURRENT_SC = NULL; 1398 1395 1399 1396 } else { 1400 - done(shpnt, DID_ERROR << 16); 1397 + done(shpnt, SAM_STAT_GOOD, DID_ERROR); 1401 1398 } 1402 1399 #if defined(AHA152X_STAT) 1403 1400 } else { ··· 1518 1515 if (TESTLO(SSTAT0, SELDO)) { 1519 1516 scmd_printk(KERN_ERR, CURRENT_SC, 1520 1517 "aha152x: passing bus free condition\n"); 1521 - done(shpnt, DID_NO_CONNECT << 16); 1518 + done(shpnt, SAM_STAT_GOOD, DID_NO_CONNECT); 1522 1519 return; 1523 1520 } 1524 1521 ··· 1555 1552 CURRENT_SC->SCp.phase &= ~selecting; 1556 1553 1557 1554 if (CURRENT_SC->SCp.phase & aborted) 1558 - done(shpnt, DID_ABORT << 16); 1555 + done(shpnt, SAM_STAT_GOOD, DID_ABORT); 1559 1556 else if (TESTLO(SSTAT0, SELINGO)) 1560 - done(shpnt, DID_BUS_BUSY << 16); 1557 + done(shpnt, SAM_STAT_GOOD, DID_BUS_BUSY); 1561 1558 else 1562 1559 /* ARBITRATION won, but SELECTION failed */ 1563 - done(shpnt, DID_NO_CONNECT << 16); 1560 + done(shpnt, SAM_STAT_GOOD, DID_NO_CONNECT); 1564 1561 } 1565 1562 1566 1563 /* ··· 1894 1891 if (CURRENT_SC->SCp.sent_command) { 1895 1892 scmd_printk(KERN_ERR, CURRENT_SC, 1896 1893 "command already sent\n"); 1897 - done(shpnt, DID_ERROR << 16); 1894 + done(shpnt, SAM_STAT_GOOD, DID_ERROR); 1898 1895 return; 1899 1896 } 1900 1897 ··· 2234 2231 static void parerr_run(struct Scsi_Host *shpnt) 2235 2232 { 2236 2233 scmd_printk(KERN_ERR, CURRENT_SC, "parity error\n"); 2237 - done(shpnt, DID_PARITY << 16); 2234 + done(shpnt, SAM_STAT_GOOD, DID_PARITY); 2238 2235 } 2239 2236 2240 2237 /* ··· 2257 2254 kfree(ptr->host_scribble); 2258 2255 ptr->host_scribble=NULL; 2259 2256 2260 - ptr->result = DID_RESET << 16; 2257 + set_host_byte(ptr, DID_RESET); 2261 2258 ptr->scsi_done(ptr); 2262 2259 } 2263 2260 ··· 2265 2262 } 2266 2263 2267 2264 if(CURRENT_SC && !CURRENT_SC->device->soft_reset) 2268 - done(shpnt, DID_RESET << 16 ); 2265 + done(shpnt, SAM_STAT_GOOD, DID_RESET); 2269 2266 } 2270 2267 2271 2268
+7 -12
drivers/scsi/aic7xxx/aic79xx_osm.c
··· 1928 1928 memcpy(cmd->sense_buffer, 1929 1929 ahd_get_sense_buf(ahd, scb) 1930 1930 + sense_offset, sense_size); 1931 - cmd->result |= (DRIVER_SENSE << 24); 1931 + set_status_byte(cmd, SAM_STAT_CHECK_CONDITION); 1932 1932 1933 1933 #ifdef AHD_DEBUG 1934 1934 if (ahd_debug & AHD_SHOW_SENSE) { ··· 2018 2018 int new_status = DID_OK; 2019 2019 int do_fallback = 0; 2020 2020 int scsi_status; 2021 + struct scsi_sense_data *sense; 2021 2022 2022 2023 /* 2023 2024 * Map CAM error codes into Linux Error codes. We ··· 2042 2041 switch(scsi_status) { 2043 2042 case SAM_STAT_COMMAND_TERMINATED: 2044 2043 case SAM_STAT_CHECK_CONDITION: 2045 - if ((cmd->result >> 24) != DRIVER_SENSE) { 2044 + sense = (struct scsi_sense_data *) 2045 + cmd->sense_buffer; 2046 + if (sense->extra_len >= 5 && 2047 + (sense->add_sense_code == 0x47 2048 + || sense->add_sense_code == 0x48)) 2046 2049 do_fallback = 1; 2047 - } else { 2048 - struct scsi_sense_data *sense; 2049 - 2050 - sense = (struct scsi_sense_data *) 2051 - cmd->sense_buffer; 2052 - if (sense->extra_len >= 5 && 2053 - (sense->add_sense_code == 0x47 2054 - || sense->add_sense_code == 0x48)) 2055 - do_fallback = 1; 2056 - } 2057 2050 break; 2058 2051 default: 2059 2052 break;
-1
drivers/scsi/aic7xxx/aic7xxx_osm.c
··· 1838 1838 if (sense_size < SCSI_SENSE_BUFFERSIZE) 1839 1839 memset(&cmd->sense_buffer[sense_size], 0, 1840 1840 SCSI_SENSE_BUFFERSIZE - sense_size); 1841 - cmd->result |= (DRIVER_SENSE << 24); 1842 1841 #ifdef AHC_DEBUG 1843 1842 if (ahc_debug & AHC_SHOW_SENSE) { 1844 1843 int i;
+2 -3
drivers/scsi/arcmsr/arcmsr_hba.c
··· 1326 1326 1327 1327 struct scsi_cmnd *pcmd = ccb->pcmd; 1328 1328 struct SENSE_DATA *sensebuffer = (struct SENSE_DATA *)pcmd->sense_buffer; 1329 - pcmd->result = (DID_OK << 16) | (CHECK_CONDITION << 1); 1329 + pcmd->result = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION; 1330 1330 if (sensebuffer) { 1331 1331 int sense_data_length = 1332 1332 sizeof(struct SENSE_DATA) < SCSI_SENSE_BUFFERSIZE ··· 1335 1335 memcpy(sensebuffer, ccb->arcmsr_cdb.SenseData, sense_data_length); 1336 1336 sensebuffer->ErrorCode = SCSI_SENSE_CURRENT_ERRORS; 1337 1337 sensebuffer->Valid = 1; 1338 - pcmd->result |= (DRIVER_SENSE << 24); 1339 1338 } 1340 1339 } 1341 1340 ··· 3253 3254 if (!ccb) 3254 3255 return SCSI_MLQUEUE_HOST_BUSY; 3255 3256 if (arcmsr_build_ccb( acb, ccb, cmd ) == FAILED) { 3256 - cmd->result = (DID_ERROR << 16) | (RESERVATION_CONFLICT << 1); 3257 + cmd->result = (DID_ERROR << 16) | SAM_STAT_RESERVATION_CONFLICT; 3257 3258 cmd->scsi_done(cmd); 3258 3259 return 0; 3259 3260 }
+12 -34
drivers/scsi/arm/acornscsi.c
··· 794 794 795 795 acornscsi_dma_cleanup(host); 796 796 797 - SCpnt->result = result << 16 | host->scsi.SCp.Message << 8 | host->scsi.SCp.Status; 797 + set_host_byte(SCpnt, result); 798 + if (result == DID_OK) 799 + scsi_msg_to_host_byte(SCpnt, host->scsi.SCp.Message); 800 + set_status_byte(SCpnt, host->scsi.SCp.Status); 798 801 799 802 /* 800 803 * In theory, this should not happen. In practice, it seems to. ··· 836 833 xfer_warn = 0; 837 834 838 835 if (xfer_warn) { 839 - switch (status_byte(SCpnt->result)) { 840 - case CHECK_CONDITION: 841 - case COMMAND_TERMINATED: 842 - case BUSY: 843 - case QUEUE_FULL: 844 - case RESERVATION_CONFLICT: 836 + switch (get_status_byte(SCpnt)) { 837 + case SAM_STAT_CHECK_CONDITION: 838 + case SAM_STAT_COMMAND_TERMINATED: 839 + case SAM_STAT_BUSY: 840 + case SAM_STAT_TASK_SET_FULL: 841 + case SAM_STAT_RESERVATION_CONFLICT: 845 842 break; 846 843 847 844 default: ··· 2473 2470 if (acornscsi_cmdtype(SCpnt->cmnd[0]) == CMD_WRITE && (NO_WRITE & (1 << SCpnt->device->id))) { 2474 2471 printk(KERN_CRIT "scsi%d.%c: WRITE attempted with NO_WRITE flag set\n", 2475 2472 host->host->host_no, '0' + SCpnt->device->id); 2476 - SCpnt->result = DID_NO_CONNECT << 16; 2473 + set_host_byte(SCpnt, DID_NO_CONNECT); 2477 2474 done(SCpnt); 2478 2475 return 0; 2479 2476 } ··· 2495 2492 unsigned long flags; 2496 2493 2497 2494 if (!queue_add_cmd_ordered(&host->queues.issue, SCpnt)) { 2498 - SCpnt->result = DID_ERROR << 16; 2495 + set_host_byte(SCpnt, DID_ERROR); 2499 2496 done(SCpnt); 2500 2497 return 0; 2501 2498 } ··· 2508 2505 } 2509 2506 2510 2507 DEF_SCSI_QCMD(acornscsi_queuecmd) 2511 - 2512 - /* 2513 - * Prototype: void acornscsi_reportstatus(struct scsi_cmnd **SCpntp1, struct scsi_cmnd **SCpntp2, int result) 2514 - * Purpose : pass a result to *SCpntp1, and check if *SCpntp1 = *SCpntp2 2515 - * Params : SCpntp1 - pointer to command to return 2516 - * SCpntp2 - pointer to command to check 2517 - * result - result to pass back to mid-level done function 2518 - * Returns : *SCpntp2 = NULL if *SCpntp1 is the same command structure as *SCpntp2. 2519 - */ 2520 - static inline void acornscsi_reportstatus(struct scsi_cmnd **SCpntp1, 2521 - struct scsi_cmnd **SCpntp2, 2522 - int result) 2523 - { 2524 - struct scsi_cmnd *SCpnt = *SCpntp1; 2525 - 2526 - if (SCpnt) { 2527 - *SCpntp1 = NULL; 2528 - 2529 - SCpnt->result = result; 2530 - SCpnt->scsi_done(SCpnt); 2531 - } 2532 - 2533 - if (SCpnt == *SCpntp2) 2534 - *SCpntp2 = NULL; 2535 - } 2536 2508 2537 2509 enum res_abort { res_not_running, res_success, res_success_clear, res_snooze }; 2538 2510
+8 -7
drivers/scsi/arm/fas216.c
··· 2042 2042 { 2043 2043 info->stats.fins += 1; 2044 2044 2045 - SCpnt->result = result << 16 | info->scsi.SCp.Message << 8 | 2046 - info->scsi.SCp.Status; 2045 + set_host_byte(SCpnt, result); 2046 + if (result == DID_OK) 2047 + scsi_msg_to_host_byte(SCpnt, info->scsi.SCp.Message); 2048 + set_status_byte(SCpnt, info->scsi.SCp.Status); 2047 2049 2048 2050 fas216_log_command(info, LOG_CONNECT, SCpnt, 2049 2051 "command complete, result=0x%08x", SCpnt->result); ··· 2053 2051 /* 2054 2052 * If the driver detected an error, we're all done. 2055 2053 */ 2056 - if (host_byte(SCpnt->result) != DID_OK || 2057 - msg_byte(SCpnt->result) != COMMAND_COMPLETE) 2054 + if (get_host_byte(SCpnt) != DID_OK) 2058 2055 goto done; 2059 2056 2060 2057 /* 2061 2058 * If the command returned CHECK_CONDITION or COMMAND_TERMINATED 2062 2059 * status, request the sense information. 2063 2060 */ 2064 - if (status_byte(SCpnt->result) == CHECK_CONDITION || 2065 - status_byte(SCpnt->result) == COMMAND_TERMINATED) 2061 + if (get_status_byte(SCpnt) == SAM_STAT_CHECK_CONDITION || 2062 + get_status_byte(SCpnt) == SAM_STAT_COMMAND_TERMINATED) 2066 2063 goto request_sense; 2067 2064 2068 2065 /* 2069 2066 * If the command did not complete with GOOD status, 2070 2067 * we are all done here. 2071 2068 */ 2072 - if (status_byte(SCpnt->result) != GOOD) 2069 + if (get_status_byte(SCpnt) != SAM_STAT_GOOD) 2073 2070 goto done; 2074 2071 2075 2072 /*
+3 -2
drivers/scsi/ch.c
··· 198 198 result = scsi_execute_req(ch->device, cmd, direction, buffer, 199 199 buflength, &sshdr, timeout * HZ, 200 200 MAX_RETRIES, NULL); 201 - 202 - if (driver_byte(result) == DRIVER_SENSE) { 201 + if (result < 0) 202 + return result; 203 + if (scsi_sense_valid(&sshdr)) { 203 204 if (debug) 204 205 scsi_print_sense_hdr(ch->device, ch->name, &sshdr); 205 206 errno = ch_find_errno(&sshdr);
-15
drivers/scsi/constants.c
··· 406 406 "DID_TRANSPORT_DISRUPTED", "DID_TRANSPORT_FAILFAST", "DID_TARGET_FAILURE", 407 407 "DID_NEXUS_FAILURE", "DID_ALLOC_FAILURE", "DID_MEDIUM_ERROR" }; 408 408 409 - static const char * const driverbyte_table[]={ 410 - "DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR", 411 - "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"}; 412 - 413 409 const char *scsi_hostbyte_string(int result) 414 410 { 415 411 const char *hb_string = NULL; ··· 416 420 return hb_string; 417 421 } 418 422 EXPORT_SYMBOL(scsi_hostbyte_string); 419 - 420 - const char *scsi_driverbyte_string(int result) 421 - { 422 - const char *db_string = NULL; 423 - int db = driver_byte(result); 424 - 425 - if (db < ARRAY_SIZE(driverbyte_table)) 426 - db_string = driverbyte_table[db]; 427 - return db_string; 428 - } 429 - EXPORT_SYMBOL(scsi_driverbyte_string); 430 423 431 424 #define scsi_mlreturn_name(result) { result, #result } 432 425 static const struct value_name_pair scsi_mlreturn_arr[] = {
+1 -2
drivers/scsi/cxlflash/superpipe.c
··· 369 369 goto out; 370 370 } 371 371 372 - if (driver_byte(result) == DRIVER_SENSE) { 373 - result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */ 372 + if (result > 0 && scsi_sense_valid(&sshdr)) { 374 373 if (result & SAM_STAT_CHECK_CONDITION) { 375 374 switch (sshdr.sense_key) { 376 375 case NO_SENSE:
+25 -55
drivers/scsi/dc395x.c
··· 160 160 #define DC395x_write16(acb,address,value) outw((value), acb->io_port_base + (address)) 161 161 #define DC395x_write32(acb,address,value) outl((value), acb->io_port_base + (address)) 162 162 163 - /* cmd->result */ 164 - #define RES_TARGET 0x000000FF /* Target State */ 165 - #define RES_TARGET_LNX STATUS_MASK /* Only official ... */ 166 - #define RES_ENDMSG 0x0000FF00 /* End Message */ 167 - #define RES_DID 0x00FF0000 /* DID_ codes */ 168 - #define RES_DRV 0xFF000000 /* DRIVER_ codes */ 169 - 170 - #define MK_RES(drv,did,msg,tgt) ((int)(drv)<<24 | (int)(did)<<16 | (int)(msg)<<8 | (int)(tgt)) 171 - #define MK_RES_LNX(drv,did,msg,tgt) ((int)(drv)<<24 | (int)(did)<<16 | (int)(msg)<<8 | (int)(tgt)<<1) 172 - 173 - #define SET_RES_TARGET(who,tgt) { who &= ~RES_TARGET; who |= (int)(tgt); } 174 - #define SET_RES_TARGET_LNX(who,tgt) { who &= ~RES_TARGET_LNX; who |= (int)(tgt) << 1; } 175 - #define SET_RES_MSG(who,msg) { who &= ~RES_ENDMSG; who |= (int)(msg) << 8; } 176 - #define SET_RES_DID(who,did) { who &= ~RES_DID; who |= (int)(did) << 16; } 177 - #define SET_RES_DRV(who,drv) { who &= ~RES_DRV; who |= (int)(drv) << 24; } 178 - 179 163 #define TAG_NONE 255 180 164 181 165 /* ··· 970 986 cmd, cmd->device->id, (u8)cmd->device->lun, cmd->cmnd[0]); 971 987 972 988 /* Assume BAD_TARGET; will be cleared later */ 973 - cmd->result = DID_BAD_TARGET << 16; 989 + set_host_byte(cmd, DID_BAD_TARGET); 974 990 975 991 /* ignore invalid targets */ 976 992 if (cmd->device->id >= acb->scsi_host->max_id || ··· 997 1013 998 1014 /* set callback and clear result in the command */ 999 1015 cmd->scsi_done = done; 1000 - cmd->result = 0; 1016 + set_host_byte(cmd, DID_OK); 1017 + set_status_byte(cmd, SAM_STAT_GOOD); 1001 1018 1002 1019 srb = list_first_entry_or_null(&acb->srb_free_list, 1003 1020 struct ScsiReqBlk, list); ··· 1235 1250 free_tag(dcb, srb); 1236 1251 list_add_tail(&srb->list, &acb->srb_free_list); 1237 1252 dprintkl(KERN_DEBUG, "eh_abort: Command was waiting\n"); 1238 - cmd->result = DID_ABORT << 16; 1253 + set_host_byte(cmd, DID_ABORT); 1239 1254 return SUCCESS; 1240 1255 } 1241 1256 srb = find_cmd(cmd, &dcb->srb_going_list); ··· 3163 3178 srb, scsi_sg_count(cmd), srb->sg_index, srb->sg_count, 3164 3179 scsi_sgtalbe(cmd)); 3165 3180 status = srb->target_status; 3181 + set_host_byte(cmd, DID_OK); 3182 + set_status_byte(cmd, SAM_STAT_GOOD); 3166 3183 if (srb->flag & AUTO_REQSENSE) { 3167 3184 dprintkdbg(DBG_0, "srb_done: AUTO_REQSENSE1\n"); 3168 3185 pci_unmap_srb_sense(acb, srb); ··· 3173 3186 */ 3174 3187 srb->flag &= ~AUTO_REQSENSE; 3175 3188 srb->adapter_status = 0; 3176 - srb->target_status = CHECK_CONDITION << 1; 3189 + srb->target_status = SAM_STAT_CHECK_CONDITION; 3177 3190 if (debug_enabled(DBG_1)) { 3178 3191 switch (cmd->sense_buffer[2] & 0x0f) { 3179 3192 case NOT_READY: ··· 3220 3233 *((unsigned int *)(cmd->sense_buffer + 3))); 3221 3234 } 3222 3235 3223 - if (status == (CHECK_CONDITION << 1)) { 3224 - cmd->result = DID_BAD_TARGET << 16; 3236 + if (status == SAM_STAT_CHECK_CONDITION) { 3237 + set_host_byte(cmd, DID_BAD_TARGET); 3225 3238 goto ckc_e; 3226 3239 } 3227 3240 dprintkdbg(DBG_0, "srb_done: AUTO_REQSENSE2\n"); 3228 3241 3229 - if (srb->total_xfer_length 3230 - && srb->total_xfer_length >= cmd->underflow) 3231 - cmd->result = 3232 - MK_RES_LNX(DRIVER_SENSE, DID_OK, 3233 - srb->end_message, CHECK_CONDITION); 3234 - /*SET_RES_DID(cmd->result,DID_OK) */ 3235 - else 3236 - cmd->result = 3237 - MK_RES_LNX(DRIVER_SENSE, DID_OK, 3238 - srb->end_message, CHECK_CONDITION); 3242 + set_status_byte(cmd, SAM_STAT_CHECK_CONDITION); 3239 3243 3240 3244 goto ckc_e; 3241 3245 } ··· 3236 3258 /* 3237 3259 * target status.......................... 3238 3260 */ 3239 - if (status >> 1 == CHECK_CONDITION) { 3261 + if (status == SAM_STAT_CHECK_CONDITION) { 3240 3262 request_sense(acb, dcb, srb); 3241 3263 return; 3242 - } else if (status >> 1 == QUEUE_FULL) { 3264 + } else if (status == SAM_STAT_TASK_SET_FULL) { 3243 3265 tempcnt = (u8)list_size(&dcb->srb_going_list); 3244 3266 dprintkl(KERN_INFO, "QUEUE_FULL for dev <%02i-%i> with %i cmnds\n", 3245 3267 dcb->target_id, dcb->target_lun, tempcnt); ··· 3255 3277 } else if (status == SCSI_STAT_SEL_TIMEOUT) { 3256 3278 srb->adapter_status = H_SEL_TIMEOUT; 3257 3279 srb->target_status = 0; 3258 - cmd->result = DID_NO_CONNECT << 16; 3280 + set_host_byte(cmd, DID_NO_CONNECT); 3259 3281 } else { 3260 3282 srb->adapter_status = 0; 3261 - SET_RES_DID(cmd->result, DID_ERROR); 3262 - SET_RES_MSG(cmd->result, srb->end_message); 3263 - SET_RES_TARGET(cmd->result, status); 3264 - 3283 + set_host_byte(cmd, DID_ERROR); 3284 + set_status_byte(cmd, status); 3265 3285 } 3266 3286 } else { 3267 3287 /* ··· 3268 3292 status = srb->adapter_status; 3269 3293 if (status & H_OVER_UNDER_RUN) { 3270 3294 srb->target_status = 0; 3271 - SET_RES_DID(cmd->result, DID_OK); 3272 - SET_RES_MSG(cmd->result, srb->end_message); 3295 + scsi_msg_to_host_byte(cmd, srb->end_message); 3273 3296 } else if (srb->status & PARITY_ERROR) { 3274 - SET_RES_DID(cmd->result, DID_PARITY); 3275 - SET_RES_MSG(cmd->result, srb->end_message); 3297 + set_host_byte(cmd, DID_PARITY); 3276 3298 } else { /* No error */ 3277 3299 3278 3300 srb->adapter_status = 0; 3279 3301 srb->target_status = 0; 3280 - SET_RES_DID(cmd->result, DID_OK); 3281 3302 } 3282 3303 } 3283 3304 ··· 3295 3322 base = scsi_kmap_atomic_sg(sg, scsi_sg_count(cmd), &offset, &len); 3296 3323 ptr = (struct ScsiInqData *)(base + offset); 3297 3324 3298 - if (!ckc_only && (cmd->result & RES_DID) == 0 3325 + if (!ckc_only && get_host_byte(cmd) == DID_OK 3299 3326 && cmd->cmnd[2] == 0 && scsi_bufflen(cmd) >= 8 3300 3327 && dir != DMA_NONE && ptr && (ptr->Vers & 0x07) >= 2) 3301 3328 dcb->inquiry7 = ptr->Flags; 3302 3329 3303 3330 /*if( srb->cmd->cmnd[0] == INQUIRY && */ 3304 3331 /* (host_byte(cmd->result) == DID_OK || status_byte(cmd->result) & CHECK_CONDITION) ) */ 3305 - if ((cmd->result == (DID_OK << 16) || 3306 - status_byte(cmd->result) == CHECK_CONDITION)) { 3332 + if ((get_host_byte(cmd) == DID_OK) || 3333 + (get_status_byte(cmd) == SAM_STAT_CHECK_CONDITION)) { 3307 3334 if (!dcb->init_tcq_flag) { 3308 3335 add_dev(acb, dcb, ptr); 3309 3336 dcb->init_tcq_flag = 1; ··· 3330 3357 if (srb != acb->tmp_srb) { 3331 3358 /* Add to free list */ 3332 3359 dprintkdbg(DBG_0, "srb_done: (0x%p) done result=0x%08x\n", 3333 - cmd, cmd->result); 3360 + cmd, cmd->result); 3334 3361 list_move_tail(&srb->list, &acb->srb_free_list); 3335 3362 } else { 3336 3363 dprintkl(KERN_ERR, "srb_done: ERROR! Completed cmd with tmp_srb\n"); ··· 3354 3381 struct scsi_cmnd *p; 3355 3382 3356 3383 list_for_each_entry_safe(srb, tmp, &dcb->srb_going_list, list) { 3357 - int result; 3358 - 3359 3384 p = srb->cmd; 3360 - result = MK_RES(0, did_flag, 0, 0); 3361 3385 printk("G:%p(%02i-%i) ", p, 3362 3386 p->device->id, (u8)p->device->lun); 3363 3387 list_del(&srb->list); 3364 3388 free_tag(dcb, srb); 3365 3389 list_add_tail(&srb->list, &acb->srb_free_list); 3366 - p->result = result; 3390 + set_host_byte(p, did_flag); 3391 + set_status_byte(p, SAM_STAT_GOOD); 3367 3392 pci_unmap_srb_sense(acb, srb); 3368 3393 pci_unmap_srb(acb, srb); 3369 3394 if (force) { ··· 3382 3411 3383 3412 /* Waiting queue */ 3384 3413 list_for_each_entry_safe(srb, tmp, &dcb->srb_waiting_list, list) { 3385 - int result; 3386 3414 p = srb->cmd; 3387 3415 3388 - result = MK_RES(0, did_flag, 0, 0); 3389 3416 printk("W:%p<%02i-%i>", p, p->device->id, 3390 3417 (u8)p->device->lun); 3391 3418 list_move_tail(&srb->list, &acb->srb_free_list); 3392 - p->result = result; 3419 + set_host_byte(p, did_flag); 3420 + set_status_byte(p, SAM_STAT_GOOD); 3393 3421 pci_unmap_srb_sense(acb, srb); 3394 3422 pci_unmap_srb(acb, srb); 3395 3423 if (force) {
+4 -4
drivers/scsi/device_handler/scsi_dh_alua.c
··· 563 563 kfree(buff); 564 564 return SCSI_DH_OK; 565 565 } 566 - if (!scsi_sense_valid(&sense_hdr)) { 566 + if (retval < 0 || !scsi_sense_valid(&sense_hdr)) { 567 567 sdev_printk(KERN_INFO, sdev, 568 568 "%s: rtpg failed, result %d\n", 569 569 ALUA_DH_NAME, retval); 570 570 kfree(buff); 571 - if (driver_byte(retval) == DRIVER_ERROR) 571 + if (retval < 0) 572 572 return SCSI_DH_DEV_TEMP_BUSY; 573 573 if (host_byte(retval) == DID_NO_CONNECT) 574 574 return SCSI_DH_RES_TEMP_UNAVAIL; ··· 794 794 retval = submit_stpg(sdev, pg->group_id, &sense_hdr); 795 795 796 796 if (retval) { 797 - if (!scsi_sense_valid(&sense_hdr)) { 797 + if (retval < 0 || !scsi_sense_valid(&sense_hdr)) { 798 798 sdev_printk(KERN_INFO, sdev, 799 799 "%s: stpg failed, result %d", 800 800 ALUA_DH_NAME, retval); 801 - if (driver_byte(retval) == DRIVER_ERROR) 801 + if (retval < 0) 802 802 return SCSI_DH_DEV_TEMP_BUSY; 803 803 } else { 804 804 sdev_printk(KERN_INFO, sdev, "%s: stpg failed\n",
+1 -1
drivers/scsi/esas2r/esas2r_main.c
··· 1525 1525 1526 1526 rq->cmd->result = 1527 1527 ((esas2r_req_status_to_error(rq->req_stat) << 16) 1528 - | (rq->func_rsp.scsi_rsp.scsi_stat & STATUS_MASK)); 1528 + | rq->func_rsp.scsi_rsp.scsi_stat); 1529 1529 1530 1530 if (rq->req_stat == RS_UNDERRUN) 1531 1531 scsi_set_resid(rq->cmd,
+1 -3
drivers/scsi/esp_scsi.c
··· 922 922 * saw originally. Also, report that we are providing 923 923 * the sense data. 924 924 */ 925 - cmd->result = ((DRIVER_SENSE << 24) | 926 - (DID_OK << 16) | 927 - (SAM_STAT_CHECK_CONDITION << 0)); 925 + cmd->result = SAM_STAT_CHECK_CONDITION; 928 926 929 927 ent->flags &= ~ESP_CMD_FLAG_AUTOSENSE; 930 928 if (esp_debug & ESP_DEBUG_AUTOSENSE) {
+12 -10
drivers/scsi/fdomain.c
··· 202 202 return 1; 203 203 } 204 204 205 - static void fdomain_finish_cmd(struct fdomain *fd, int result) 205 + static void fdomain_finish_cmd(struct fdomain *fd) 206 206 { 207 207 outb(0, fd->base + REG_ICTL); 208 208 fdomain_make_bus_idle(fd); 209 - fd->cur_cmd->result = result; 210 209 fd->cur_cmd->scsi_done(fd->cur_cmd); 211 210 fd->cur_cmd = NULL; 212 211 } ··· 272 273 if (cmd->SCp.phase & in_arbitration) { 273 274 status = inb(fd->base + REG_ASTAT); 274 275 if (!(status & ASTAT_ARB)) { 275 - fdomain_finish_cmd(fd, DID_BUS_BUSY << 16); 276 + set_host_byte(cmd, DID_BUS_BUSY); 277 + fdomain_finish_cmd(fd); 276 278 goto out; 277 279 } 278 280 cmd->SCp.phase = in_selection; ··· 290 290 if (!(status & BSTAT_BSY)) { 291 291 /* Try again, for slow devices */ 292 292 if (fdomain_select(cmd->device->host, scmd_id(cmd))) { 293 - fdomain_finish_cmd(fd, DID_NO_CONNECT << 16); 293 + set_host_byte(cmd, DID_NO_CONNECT); 294 + fdomain_finish_cmd(fd); 294 295 goto out; 295 296 } 296 297 /* Stop arbitration and enable parity */ ··· 334 333 break; 335 334 case BSTAT_MSG | BSTAT_CMD | BSTAT_IO: /* MESSAGE IN */ 336 335 cmd->SCp.Message = inb(fd->base + REG_SCSI_DATA); 337 - if (!cmd->SCp.Message) 336 + if (cmd->SCp.Message == COMMAND_COMPLETE) 338 337 ++done; 339 338 break; 340 339 } ··· 360 359 fdomain_read_data(cmd); 361 360 362 361 if (done) { 363 - fdomain_finish_cmd(fd, (cmd->SCp.Status & 0xff) | 364 - ((cmd->SCp.Message & 0xff) << 8) | 365 - (DID_OK << 16)); 362 + set_status_byte(cmd, cmd->SCp.Status); 363 + set_host_byte(cmd, DID_OK); 364 + scsi_msg_to_host_byte(cmd, cmd->SCp.Message); 365 + fdomain_finish_cmd(fd); 366 366 } else { 367 367 if (cmd->SCp.phase & disconnect) { 368 368 outb(ICTL_FIFO | ICTL_SEL | ICTL_REQ | FIFO_COUNT, ··· 441 439 442 440 fdomain_make_bus_idle(fd); 443 441 fd->cur_cmd->SCp.phase |= aborted; 444 - fd->cur_cmd->result = DID_ABORT << 16; 445 442 446 443 /* Aborts are not done well. . . */ 447 - fdomain_finish_cmd(fd, DID_ABORT << 16); 444 + set_host_byte(fd->cur_cmd, DID_ABORT); 445 + fdomain_finish_cmd(fd); 448 446 spin_unlock_irqrestore(sh->host_lock, flags); 449 447 return SUCCESS; 450 448 }
+1 -1
drivers/scsi/hptiop.c
··· 760 760 goto skip_resid; 761 761 762 762 default: 763 - scp->result = DRIVER_INVALID << 24 | DID_ABORT << 16; 763 + scp->result = DID_ABORT << 16; 764 764 break; 765 765 } 766 766
+1 -1
drivers/scsi/ibmvscsi/ibmvscsi.c
··· 1005 1005 1006 1006 if (cmnd) { 1007 1007 cmnd->result |= rsp->status; 1008 - if (((cmnd->result >> 1) & 0x1f) == CHECK_CONDITION) 1008 + if (scsi_status_is_check_condition(cmnd->result)) 1009 1009 memcpy(cmnd->sense_buffer, 1010 1010 rsp->data, 1011 1011 be32_to_cpu(rsp->sense_data_len));
+1 -4
drivers/scsi/libiscsi.c
··· 829 829 830 830 ascq = session->tt->check_protection(task, &sector); 831 831 if (ascq) { 832 - sc->result = DRIVER_SENSE << 24 | 833 - SAM_STAT_CHECK_CONDITION; 834 - scsi_build_sense_buffer(1, sc->sense_buffer, 835 - ILLEGAL_REQUEST, 0x10, ascq); 832 + scsi_build_sense(sc, 1, ILLEGAL_REQUEST, 0x10, ascq); 836 833 scsi_set_sense_information(sc->sense_buffer, 837 834 SCSI_SENSE_BUFFERSIZE, 838 835 sector);
+18 -36
drivers/scsi/lpfc/lpfc_scsi.c
··· 2896 2896 } 2897 2897 out: 2898 2898 if (err_type == BGS_GUARD_ERR_MASK) { 2899 - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, 2900 - 0x10, 0x1); 2901 - cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 | 2902 - SAM_STAT_CHECK_CONDITION; 2899 + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x1); 2900 + set_host_byte(cmd, DID_ABORT); 2903 2901 phba->bg_guard_err_cnt++; 2904 2902 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, 2905 2903 "9069 BLKGRD: reftag %x grd_tag err %x != %x\n", ··· 2905 2907 sum, guard_tag); 2906 2908 2907 2909 } else if (err_type == BGS_REFTAG_ERR_MASK) { 2908 - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, 2909 - 0x10, 0x3); 2910 - cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 | 2911 - SAM_STAT_CHECK_CONDITION; 2910 + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x3); 2911 + set_host_byte(cmd, DID_ABORT); 2912 2912 2913 2913 phba->bg_reftag_err_cnt++; 2914 2914 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, ··· 2915 2919 ref_tag, start_ref_tag); 2916 2920 2917 2921 } else if (err_type == BGS_APPTAG_ERR_MASK) { 2918 - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, 2919 - 0x10, 0x2); 2920 - cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 | 2921 - SAM_STAT_CHECK_CONDITION; 2922 + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x2); 2923 + set_host_byte(cmd, DID_ABORT); 2922 2924 2923 2925 phba->bg_apptag_err_cnt++; 2924 2926 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, ··· 2975 2981 if (lpfc_bgs_get_guard_err(bgstat)) { 2976 2982 ret = 1; 2977 2983 2978 - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, 2979 - 0x10, 0x1); 2980 - cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 | 2981 - SAM_STAT_CHECK_CONDITION; 2984 + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x1); 2985 + set_host_byte(cmd, DID_ABORT); 2982 2986 phba->bg_guard_err_cnt++; 2983 2987 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, 2984 2988 "9059 BLKGRD: Guard Tag error in cmd" ··· 2989 2997 if (lpfc_bgs_get_reftag_err(bgstat)) { 2990 2998 ret = 1; 2991 2999 2992 - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, 2993 - 0x10, 0x3); 2994 - cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 | 2995 - SAM_STAT_CHECK_CONDITION; 3000 + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x3); 3001 + set_host_byte(cmd, DID_ABORT); 2996 3002 2997 3003 phba->bg_reftag_err_cnt++; 2998 3004 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, ··· 3004 3014 if (lpfc_bgs_get_apptag_err(bgstat)) { 3005 3015 ret = 1; 3006 3016 3007 - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, 3008 - 0x10, 0x2); 3009 - cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 | 3010 - SAM_STAT_CHECK_CONDITION; 3017 + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x2); 3018 + set_host_byte(cmd, DID_ABORT); 3011 3019 3012 3020 phba->bg_apptag_err_cnt++; 3013 3021 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, ··· 3115 3127 if (lpfc_bgs_get_guard_err(bgstat)) { 3116 3128 ret = 1; 3117 3129 3118 - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, 3119 - 0x10, 0x1); 3120 - cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 | 3121 - SAM_STAT_CHECK_CONDITION; 3130 + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x1); 3131 + set_host_byte(cmd, DID_ABORT); 3122 3132 phba->bg_guard_err_cnt++; 3123 3133 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, 3124 3134 "9055 BLKGRD: Guard Tag error in cmd " ··· 3129 3143 if (lpfc_bgs_get_reftag_err(bgstat)) { 3130 3144 ret = 1; 3131 3145 3132 - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, 3133 - 0x10, 0x3); 3134 - cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 | 3135 - SAM_STAT_CHECK_CONDITION; 3146 + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x3); 3147 + set_host_byte(cmd, DID_ABORT); 3136 3148 3137 3149 phba->bg_reftag_err_cnt++; 3138 3150 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, ··· 3144 3160 if (lpfc_bgs_get_apptag_err(bgstat)) { 3145 3161 ret = 1; 3146 3162 3147 - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, 3148 - 0x10, 0x2); 3149 - cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 | 3150 - SAM_STAT_CHECK_CONDITION; 3163 + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x2); 3164 + set_host_byte(cmd, DID_ABORT); 3151 3165 3152 3166 phba->bg_apptag_err_cnt++; 3153 3167 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
+7 -13
drivers/scsi/megaraid.c
··· 1583 1583 memcpy(cmd->sense_buffer, pthru->reqsensearea, 1584 1584 14); 1585 1585 1586 - cmd->result = (DRIVER_SENSE << 24) | 1587 - (DID_OK << 16) | 1588 - (CHECK_CONDITION << 1); 1586 + cmd->result = SAM_STAT_CHECK_CONDITION; 1589 1587 } 1590 1588 else { 1591 1589 if (mbox->m_out.cmd == MEGA_MBOXCMD_EXTPTHRU) { ··· 1591 1593 memcpy(cmd->sense_buffer, 1592 1594 epthru->reqsensearea, 14); 1593 1595 1594 - cmd->result = (DRIVER_SENSE << 24) | 1595 - (DID_OK << 16) | 1596 - (CHECK_CONDITION << 1); 1597 - } else { 1598 - cmd->sense_buffer[0] = 0x70; 1599 - cmd->sense_buffer[2] = ABORTED_COMMAND; 1600 - cmd->result |= (CHECK_CONDITION << 1); 1601 - } 1596 + cmd->result = SAM_STAT_CHECK_CONDITION; 1597 + } else 1598 + scsi_build_sense(cmd, 0, 1599 + ABORTED_COMMAND, 0, 0); 1602 1600 } 1603 1601 break; 1604 1602 ··· 1611 1617 */ 1612 1618 if( cmd->cmnd[0] == TEST_UNIT_READY ) { 1613 1619 cmd->result |= (DID_ERROR << 16) | 1614 - (RESERVATION_CONFLICT << 1); 1620 + SAM_STAT_RESERVATION_CONFLICT; 1615 1621 } 1616 1622 else 1617 1623 /* ··· 1623 1629 cmd->cmnd[0] == RELEASE) ) { 1624 1630 1625 1631 cmd->result |= (DID_ERROR << 16) | 1626 - (RESERVATION_CONFLICT << 1); 1632 + SAM_STAT_RESERVATION_CONFLICT; 1627 1633 } 1628 1634 else 1629 1635 #endif
+9 -16
drivers/scsi/megaraid/megaraid_mbox.c
··· 1574 1574 } 1575 1575 1576 1576 if (scp->cmnd[1] & MEGA_SCSI_INQ_EVPD) { 1577 - scp->sense_buffer[0] = 0x70; 1578 - scp->sense_buffer[2] = ILLEGAL_REQUEST; 1579 - scp->sense_buffer[12] = MEGA_INVALID_FIELD_IN_CDB; 1580 - scp->result = CHECK_CONDITION << 1; 1577 + scsi_build_sense(scp, 0, ILLEGAL_REQUEST, 1578 + MEGA_INVALID_FIELD_IN_CDB, 0); 1581 1579 return NULL; 1582 1580 } 1583 1581 ··· 2299 2301 memcpy(scp->sense_buffer, pthru->reqsensearea, 2300 2302 14); 2301 2303 2302 - scp->result = DRIVER_SENSE << 24 | 2303 - DID_OK << 16 | CHECK_CONDITION << 1; 2304 + scp->result = SAM_STAT_CHECK_CONDITION; 2304 2305 } 2305 2306 else { 2306 2307 if (mbox->cmd == MBOXCMD_EXTPTHRU) { ··· 2307 2310 memcpy(scp->sense_buffer, 2308 2311 epthru->reqsensearea, 14); 2309 2312 2310 - scp->result = DRIVER_SENSE << 24 | 2311 - DID_OK << 16 | 2312 - CHECK_CONDITION << 1; 2313 - } else { 2314 - scp->sense_buffer[0] = 0x70; 2315 - scp->sense_buffer[2] = ABORTED_COMMAND; 2316 - scp->result = CHECK_CONDITION << 1; 2317 - } 2313 + scp->result = SAM_STAT_CHECK_CONDITION; 2314 + } else 2315 + scsi_build_sense(scp, 0, 2316 + ABORTED_COMMAND, 0, 0); 2318 2317 } 2319 2318 break; 2320 2319 ··· 2327 2334 */ 2328 2335 if (scp->cmnd[0] == TEST_UNIT_READY) { 2329 2336 scp->result = DID_ERROR << 16 | 2330 - RESERVATION_CONFLICT << 1; 2337 + SAM_STAT_RESERVATION_CONFLICT; 2331 2338 } 2332 2339 else 2333 2340 /* ··· 2338 2345 scp->cmnd[0] == RELEASE)) { 2339 2346 2340 2347 scp->result = DID_ERROR << 16 | 2341 - RESERVATION_CONFLICT << 1; 2348 + SAM_STAT_RESERVATION_CONFLICT; 2342 2349 } 2343 2350 else { 2344 2351 scp->result = DID_BAD_TARGET << 16 | status;
-2
drivers/scsi/megaraid/megaraid_sas_base.c
··· 3667 3667 SCSI_SENSE_BUFFERSIZE); 3668 3668 memcpy(cmd->scmd->sense_buffer, cmd->sense, 3669 3669 hdr->sense_len); 3670 - 3671 - cmd->scmd->result |= DRIVER_SENSE << 24; 3672 3670 } 3673 3671 3674 3672 break;
-1
drivers/scsi/megaraid/megaraid_sas_fusion.c
··· 2051 2051 SCSI_SENSE_BUFFERSIZE); 2052 2052 memcpy(scmd->sense_buffer, sense, 2053 2053 SCSI_SENSE_BUFFERSIZE); 2054 - scmd->result |= DRIVER_SENSE << 24; 2055 2054 } 2056 2055 2057 2056 /*
+5 -4
drivers/scsi/mesh.c
··· 595 595 ms->current_req = NULL; 596 596 tp->current_req = NULL; 597 597 if (cmd) { 598 - cmd->result = (ms->stat << 16) | cmd->SCp.Status; 598 + set_host_byte(cmd, ms->stat); 599 + set_status_byte(cmd, cmd->SCp.Status); 599 600 if (ms->stat == DID_OK) 600 - cmd->result |= cmd->SCp.Message << 8; 601 + scsi_msg_to_host_byte(cmd, cmd->SCp.Message); 601 602 if (DEBUG_TARGET(cmd)) { 602 603 printk(KERN_DEBUG "mesh_done: result = %x, data_ptr=%d, buflen=%d\n", 603 604 cmd->result, ms->data_ptr, scsi_bufflen(cmd)); ··· 994 993 for (tgt = 0; tgt < 8; ++tgt) { 995 994 tp = &ms->tgts[tgt]; 996 995 if ((cmd = tp->current_req) != NULL) { 997 - cmd->result = DID_RESET << 16; 996 + set_host_byte(cmd, DID_RESET); 998 997 tp->current_req = NULL; 999 998 mesh_completed(ms, cmd); 1000 999 } ··· 1004 1003 ms->current_req = NULL; 1005 1004 while ((cmd = ms->request_q) != NULL) { 1006 1005 ms->request_q = (struct scsi_cmnd *) cmd->host_scribble; 1007 - cmd->result = DID_RESET << 16; 1006 + set_host_byte(cmd, DID_RESET); 1008 1007 mesh_completed(ms, cmd); 1009 1008 } 1010 1009 ms->phase = idle;
+5 -10
drivers/scsi/mpi3mr/mpi3mr_os.c
··· 2127 2127 2128 2128 mpi3mr_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST, 2129 2129 0x10, ascq); 2130 - scmd->result = DRIVER_SENSE << 24 | (DID_ABORT << 16) | 2131 - SAM_STAT_CHECK_CONDITION; 2130 + scmd->result = (DID_ABORT << 16) | SAM_STAT_CHECK_CONDITION; 2132 2131 } 2133 2132 2134 2133 /** ··· 3353 3354 "%s: cdb received with invalid param_len: %d\n", 3354 3355 __func__, param_len); 3355 3356 scsi_print_command(scmd); 3356 - scmd->result = (DRIVER_SENSE << 24) | 3357 - SAM_STAT_CHECK_CONDITION; 3357 + scmd->result = SAM_STAT_CHECK_CONDITION; 3358 3358 scsi_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST, 3359 3359 0x1A, 0); 3360 3360 scmd->scsi_done(scmd); ··· 3364 3366 "%s: cdb received with param_len: %d bufflen: %d\n", 3365 3367 __func__, param_len, scsi_bufflen(scmd)); 3366 3368 scsi_print_command(scmd); 3367 - scmd->result = (DRIVER_SENSE << 24) | 3368 - SAM_STAT_CHECK_CONDITION; 3369 + scmd->result = SAM_STAT_CHECK_CONDITION; 3369 3370 scsi_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST, 3370 3371 0x1A, 0); 3371 3372 scmd->scsi_done(scmd); ··· 3373 3376 buf = kzalloc(scsi_bufflen(scmd), GFP_ATOMIC); 3374 3377 if (!buf) { 3375 3378 scsi_print_command(scmd); 3376 - scmd->result = (DRIVER_SENSE << 24) | 3377 - SAM_STAT_CHECK_CONDITION; 3379 + scmd->result = SAM_STAT_CHECK_CONDITION; 3378 3380 scsi_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST, 3379 3381 0x55, 0x03); 3380 3382 scmd->scsi_done(scmd); ··· 3387 3391 "%s: Invalid descriptor length in param list: %d\n", 3388 3392 __func__, desc_len); 3389 3393 scsi_print_command(scmd); 3390 - scmd->result = (DRIVER_SENSE << 24) | 3391 - SAM_STAT_CHECK_CONDITION; 3394 + scmd->result = SAM_STAT_CHECK_CONDITION; 3392 3395 scsi_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST, 3393 3396 0x26, 0); 3394 3397 scmd->scsi_done(scmd);
+4 -10
drivers/scsi/mpt3sas/mpt3sas_scsih.c
··· 5119 5119 ascq = 0x00; 5120 5120 break; 5121 5121 } 5122 - scsi_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST, 0x10, 5123 - ascq); 5124 - scmd->result = DRIVER_SENSE << 24 | (DID_ABORT << 16) | 5125 - SAM_STAT_CHECK_CONDITION; 5122 + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x10, ascq); 5123 + set_host_byte(scmd, DID_ABORT); 5126 5124 } 5127 5125 5128 5126 /** ··· 5877 5879 else if (!xfer_cnt && scmd->cmnd[0] == REPORT_LUNS) { 5878 5880 mpi_reply->SCSIState = MPI2_SCSI_STATE_AUTOSENSE_VALID; 5879 5881 mpi_reply->SCSIStatus = SAM_STAT_CHECK_CONDITION; 5880 - scmd->result = (DRIVER_SENSE << 24) | 5881 - SAM_STAT_CHECK_CONDITION; 5882 - scmd->sense_buffer[0] = 0x70; 5883 - scmd->sense_buffer[2] = ILLEGAL_REQUEST; 5884 - scmd->sense_buffer[12] = 0x20; 5885 - scmd->sense_buffer[13] = 0; 5882 + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 5883 + 0x20, 0); 5886 5884 } 5887 5885 break; 5888 5886
+3 -7
drivers/scsi/mvumi.c
··· 1317 1317 if (ob_frame->rsp_flag & CL_RSP_FLAG_SENSEDATA) { 1318 1318 memcpy(cmd->scmd->sense_buffer, ob_frame->payload, 1319 1319 sizeof(struct mvumi_sense_data)); 1320 - scmd->result |= (DRIVER_SENSE << 24); 1321 1320 } 1322 1321 break; 1323 1322 default: 1324 - scmd->result |= (DRIVER_INVALID << 24) | (DID_ABORT << 16); 1323 + scmd->result |= (DID_ABORT << 16); 1325 1324 break; 1326 1325 } 1327 1326 ··· 2067 2068 return 0; 2068 2069 2069 2070 error: 2070 - scmd->result = (DID_OK << 16) | (DRIVER_SENSE << 24) | 2071 - SAM_STAT_CHECK_CONDITION; 2072 - scsi_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST, 0x24, 2073 - 0); 2071 + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x24, 0); 2074 2072 return -1; 2075 2073 } 2076 2074 ··· 2127 2131 else 2128 2132 atomic_dec(&mhba->fw_outstanding); 2129 2133 2130 - scmd->result = (DRIVER_INVALID << 24) | (DID_ABORT << 16); 2134 + scmd->result = (DID_ABORT << 16); 2131 2135 scmd->SCp.ptr = NULL; 2132 2136 if (scsi_bufflen(scmd)) { 2133 2137 dma_unmap_sg(&mhba->pdev->dev, scsi_sglist(scmd),
+15 -49
drivers/scsi/myrb.c
··· 1397 1397 static void myrb_request_sense(struct myrb_hba *cb, 1398 1398 struct scsi_cmnd *scmd) 1399 1399 { 1400 - scsi_build_sense_buffer(0, scmd->sense_buffer, 1401 - NO_SENSE, 0, 0); 1400 + scsi_build_sense(scmd, 0, NO_SENSE, 0, 0); 1402 1401 scsi_sg_copy_from_buffer(scmd, scmd->sense_buffer, 1403 1402 SCSI_SENSE_BUFFERSIZE); 1404 1403 } ··· 1446 1447 case INQUIRY: 1447 1448 if (scmd->cmnd[1] & 1) { 1448 1449 /* Illegal request, invalid field in CDB */ 1449 - scsi_build_sense_buffer(0, scmd->sense_buffer, 1450 - ILLEGAL_REQUEST, 0x24, 0); 1451 - scmd->result = (DRIVER_SENSE << 24) | 1452 - SAM_STAT_CHECK_CONDITION; 1450 + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x24, 0); 1453 1451 } else { 1454 1452 myrb_inquiry(cb, scmd); 1455 1453 scmd->result = (DID_OK << 16); ··· 1461 1465 if ((scmd->cmnd[2] & 0x3F) != 0x3F && 1462 1466 (scmd->cmnd[2] & 0x3F) != 0x08) { 1463 1467 /* Illegal request, invalid field in CDB */ 1464 - scsi_build_sense_buffer(0, scmd->sense_buffer, 1465 - ILLEGAL_REQUEST, 0x24, 0); 1466 - scmd->result = (DRIVER_SENSE << 24) | 1467 - SAM_STAT_CHECK_CONDITION; 1468 + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x24, 0); 1468 1469 } else { 1469 1470 myrb_mode_sense(cb, scmd, ldev_info); 1470 1471 scmd->result = (DID_OK << 16); ··· 1472 1479 if ((scmd->cmnd[1] & 1) || 1473 1480 (scmd->cmnd[8] & 1)) { 1474 1481 /* Illegal request, invalid field in CDB */ 1475 - scsi_build_sense_buffer(0, scmd->sense_buffer, 1476 - ILLEGAL_REQUEST, 0x24, 0); 1477 - scmd->result = (DRIVER_SENSE << 24) | 1478 - SAM_STAT_CHECK_CONDITION; 1482 + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x24, 0); 1479 1483 scmd->scsi_done(scmd); 1480 1484 return 0; 1481 1485 } 1482 1486 lba = get_unaligned_be32(&scmd->cmnd[2]); 1483 1487 if (lba) { 1484 1488 /* Illegal request, invalid field in CDB */ 1485 - scsi_build_sense_buffer(0, scmd->sense_buffer, 1486 - ILLEGAL_REQUEST, 0x24, 0); 1487 - scmd->result = (DRIVER_SENSE << 24) | 1488 - SAM_STAT_CHECK_CONDITION; 1489 + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x24, 0); 1489 1490 scmd->scsi_done(scmd); 1490 1491 return 0; 1491 1492 } ··· 1493 1506 case SEND_DIAGNOSTIC: 1494 1507 if (scmd->cmnd[1] != 0x04) { 1495 1508 /* Illegal request, invalid field in CDB */ 1496 - scsi_build_sense_buffer(0, scmd->sense_buffer, 1497 - ILLEGAL_REQUEST, 0x24, 0); 1498 - scmd->result = (DRIVER_SENSE << 24) | 1499 - SAM_STAT_CHECK_CONDITION; 1509 + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x24, 0); 1500 1510 } else { 1501 1511 /* Assume good status */ 1502 1512 scmd->result = (DID_OK << 16); ··· 1503 1519 case READ_6: 1504 1520 if (ldev_info->state == MYRB_DEVICE_WO) { 1505 1521 /* Data protect, attempt to read invalid data */ 1506 - scsi_build_sense_buffer(0, scmd->sense_buffer, 1507 - DATA_PROTECT, 0x21, 0x06); 1508 - scmd->result = (DRIVER_SENSE << 24) | 1509 - SAM_STAT_CHECK_CONDITION; 1522 + scsi_build_sense(scmd, 0, DATA_PROTECT, 0x21, 0x06); 1510 1523 scmd->scsi_done(scmd); 1511 1524 return 0; 1512 1525 } ··· 1517 1536 case READ_10: 1518 1537 if (ldev_info->state == MYRB_DEVICE_WO) { 1519 1538 /* Data protect, attempt to read invalid data */ 1520 - scsi_build_sense_buffer(0, scmd->sense_buffer, 1521 - DATA_PROTECT, 0x21, 0x06); 1522 - scmd->result = (DRIVER_SENSE << 24) | 1523 - SAM_STAT_CHECK_CONDITION; 1539 + scsi_build_sense(scmd, 0, DATA_PROTECT, 0x21, 0x06); 1524 1540 scmd->scsi_done(scmd); 1525 1541 return 0; 1526 1542 } ··· 1531 1553 case READ_12: 1532 1554 if (ldev_info->state == MYRB_DEVICE_WO) { 1533 1555 /* Data protect, attempt to read invalid data */ 1534 - scsi_build_sense_buffer(0, scmd->sense_buffer, 1535 - DATA_PROTECT, 0x21, 0x06); 1536 - scmd->result = (DRIVER_SENSE << 24) | 1537 - SAM_STAT_CHECK_CONDITION; 1556 + scsi_build_sense(scmd, 0, DATA_PROTECT, 0x21, 0x06); 1538 1557 scmd->scsi_done(scmd); 1539 1558 return 0; 1540 1559 } ··· 1544 1569 break; 1545 1570 default: 1546 1571 /* Illegal request, invalid opcode */ 1547 - scsi_build_sense_buffer(0, scmd->sense_buffer, 1548 - ILLEGAL_REQUEST, 0x20, 0); 1549 - scmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; 1572 + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x20, 0); 1550 1573 scmd->scsi_done(scmd); 1551 1574 return 0; 1552 1575 } ··· 2325 2352 "Bad Data Encountered\n"); 2326 2353 if (scmd->sc_data_direction == DMA_FROM_DEVICE) 2327 2354 /* Unrecovered read error */ 2328 - scsi_build_sense_buffer(0, scmd->sense_buffer, 2329 - MEDIUM_ERROR, 0x11, 0); 2355 + scsi_build_sense(scmd, 0, MEDIUM_ERROR, 0x11, 0); 2330 2356 else 2331 2357 /* Write error */ 2332 - scsi_build_sense_buffer(0, scmd->sense_buffer, 2333 - MEDIUM_ERROR, 0x0C, 0); 2334 - scmd->result = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION; 2358 + scsi_build_sense(scmd, 0, MEDIUM_ERROR, 0x0C, 0); 2335 2359 break; 2336 2360 case MYRB_STATUS_IRRECOVERABLE_DATA_ERROR: 2337 2361 scmd_printk(KERN_ERR, scmd, "Irrecoverable Data Error\n"); 2338 2362 if (scmd->sc_data_direction == DMA_FROM_DEVICE) 2339 2363 /* Unrecovered read error, auto-reallocation failed */ 2340 - scsi_build_sense_buffer(0, scmd->sense_buffer, 2341 - MEDIUM_ERROR, 0x11, 0x04); 2364 + scsi_build_sense(scmd, 0, MEDIUM_ERROR, 0x11, 0x04); 2342 2365 else 2343 2366 /* Write error, auto-reallocation failed */ 2344 - scsi_build_sense_buffer(0, scmd->sense_buffer, 2345 - MEDIUM_ERROR, 0x0C, 0x02); 2346 - scmd->result = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION; 2367 + scsi_build_sense(scmd, 0, MEDIUM_ERROR, 0x0C, 0x02); 2347 2368 break; 2348 2369 case MYRB_STATUS_LDRV_NONEXISTENT_OR_OFFLINE: 2349 2370 dev_dbg(&scmd->device->sdev_gendev, ··· 2348 2381 dev_dbg(&scmd->device->sdev_gendev, 2349 2382 "Attempt to Access Beyond End of Logical Drive"); 2350 2383 /* Logical block address out of range */ 2351 - scsi_build_sense_buffer(0, scmd->sense_buffer, 2352 - NOT_READY, 0x21, 0); 2384 + scsi_build_sense(scmd, 0, NOT_READY, 0x21, 0); 2353 2385 break; 2354 2386 case MYRB_STATUS_DEVICE_NONRESPONSIVE: 2355 2387 dev_dbg(&scmd->device->sdev_gendev, "Device nonresponsive\n");
+2 -7
drivers/scsi/myrs.c
··· 1600 1600 1601 1601 switch (scmd->cmnd[0]) { 1602 1602 case REPORT_LUNS: 1603 - scsi_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST, 1604 - 0x20, 0x0); 1605 - scmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; 1603 + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x20, 0x0); 1606 1604 scmd->scsi_done(scmd); 1607 1605 return 0; 1608 1606 case MODE_SENSE: ··· 1610 1612 if ((scmd->cmnd[2] & 0x3F) != 0x3F && 1611 1613 (scmd->cmnd[2] & 0x3F) != 0x08) { 1612 1614 /* Illegal request, invalid field in CDB */ 1613 - scsi_build_sense_buffer(0, scmd->sense_buffer, 1614 - ILLEGAL_REQUEST, 0x24, 0); 1615 - scmd->result = (DRIVER_SENSE << 24) | 1616 - SAM_STAT_CHECK_CONDITION; 1615 + scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x24, 0); 1617 1616 } else { 1618 1617 myrs_mode_sense(cs, scmd, ldev_info); 1619 1618 scmd->result = (DID_OK << 16);
+221 -198
drivers/scsi/nsp32.c
··· 176 176 * function declaration 177 177 */ 178 178 /* module entry point */ 179 - static int nsp32_probe (struct pci_dev *, const struct pci_device_id *); 180 - static void nsp32_remove(struct pci_dev *); 179 + static int nsp32_probe (struct pci_dev *, const struct pci_device_id *); 180 + static void nsp32_remove(struct pci_dev *); 181 181 static int __init init_nsp32 (void); 182 182 static void __exit exit_nsp32 (void); 183 183 184 184 /* struct struct scsi_host_template */ 185 - static int nsp32_show_info (struct seq_file *, struct Scsi_Host *); 185 + static int nsp32_show_info (struct seq_file *, struct Scsi_Host *); 186 186 187 - static int nsp32_detect (struct pci_dev *pdev); 188 - static int nsp32_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); 189 - static const char *nsp32_info (struct Scsi_Host *); 190 - static int nsp32_release (struct Scsi_Host *); 187 + static int nsp32_detect (struct pci_dev *pdev); 188 + static int nsp32_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); 189 + static const char *nsp32_info (struct Scsi_Host *); 190 + static int nsp32_release (struct Scsi_Host *); 191 191 192 192 /* SCSI error handler */ 193 - static int nsp32_eh_abort (struct scsi_cmnd *); 194 - static int nsp32_eh_host_reset(struct scsi_cmnd *); 193 + static int nsp32_eh_abort (struct scsi_cmnd *); 194 + static int nsp32_eh_host_reset(struct scsi_cmnd *); 195 195 196 196 /* generate SCSI message */ 197 197 static void nsp32_build_identify(struct scsi_cmnd *); 198 198 static void nsp32_build_nop (struct scsi_cmnd *); 199 199 static void nsp32_build_reject (struct scsi_cmnd *); 200 - static void nsp32_build_sdtr (struct scsi_cmnd *, unsigned char, unsigned char); 200 + static void nsp32_build_sdtr (struct scsi_cmnd *, unsigned char, 201 + unsigned char); 201 202 202 203 /* SCSI message handler */ 203 204 static int nsp32_busfree_occur(struct scsi_cmnd *, unsigned short); 204 205 static void nsp32_msgout_occur (struct scsi_cmnd *); 205 - static void nsp32_msgin_occur (struct scsi_cmnd *, unsigned long, unsigned short); 206 + static void nsp32_msgin_occur (struct scsi_cmnd *, unsigned long, 207 + unsigned short); 206 208 207 209 static int nsp32_setup_sg_table (struct scsi_cmnd *); 208 210 static int nsp32_selection_autopara(struct scsi_cmnd *); 209 211 static int nsp32_selection_autoscsi(struct scsi_cmnd *); 210 - static void nsp32_scsi_done (struct scsi_cmnd *); 212 + static void nsp32_scsi_done (struct scsi_cmnd *); 211 213 static int nsp32_arbitration (struct scsi_cmnd *, unsigned int); 212 214 static int nsp32_reselection (struct scsi_cmnd *, unsigned char); 213 215 static void nsp32_adjust_busfree (struct scsi_cmnd *, unsigned int); ··· 217 215 218 216 /* SCSI SDTR */ 219 217 static void nsp32_analyze_sdtr (struct scsi_cmnd *); 220 - static int nsp32_search_period_entry(nsp32_hw_data *, nsp32_target *, unsigned char); 221 - static void nsp32_set_async (nsp32_hw_data *, nsp32_target *); 222 - static void nsp32_set_max_sync (nsp32_hw_data *, nsp32_target *, unsigned char *, unsigned char *); 223 - static void nsp32_set_sync_entry (nsp32_hw_data *, nsp32_target *, int, unsigned char); 218 + static int nsp32_search_period_entry(nsp32_hw_data *, nsp32_target *, 219 + unsigned char); 220 + static void nsp32_set_async (nsp32_hw_data *, nsp32_target *); 221 + static void nsp32_set_max_sync (nsp32_hw_data *, nsp32_target *, 222 + unsigned char *, unsigned char *); 223 + static void nsp32_set_sync_entry (nsp32_hw_data *, nsp32_target *, 224 + int, unsigned char); 224 225 225 226 /* SCSI bus status handler */ 226 227 static void nsp32_wait_req (nsp32_hw_data *, int); ··· 239 234 static int nsp32hw_init(nsp32_hw_data *); 240 235 241 236 /* EEPROM handler */ 242 - static int nsp32_getprom_param (nsp32_hw_data *); 243 - static int nsp32_getprom_at24 (nsp32_hw_data *); 244 - static int nsp32_getprom_c16 (nsp32_hw_data *); 245 - static void nsp32_prom_start (nsp32_hw_data *); 246 - static void nsp32_prom_stop (nsp32_hw_data *); 247 - static int nsp32_prom_read (nsp32_hw_data *, int); 248 - static int nsp32_prom_read_bit (nsp32_hw_data *); 249 - static void nsp32_prom_write_bit(nsp32_hw_data *, int); 250 - static void nsp32_prom_set (nsp32_hw_data *, int, int); 251 - static int nsp32_prom_get (nsp32_hw_data *, int); 237 + static int nsp32_getprom_param (nsp32_hw_data *); 238 + static int nsp32_getprom_at24 (nsp32_hw_data *); 239 + static int nsp32_getprom_c16 (nsp32_hw_data *); 240 + static void nsp32_prom_start (nsp32_hw_data *); 241 + static void nsp32_prom_stop (nsp32_hw_data *); 242 + static int nsp32_prom_read (nsp32_hw_data *, int); 243 + static int nsp32_prom_read_bit (nsp32_hw_data *); 244 + static void nsp32_prom_write_bit(nsp32_hw_data *, int); 245 + static void nsp32_prom_set (nsp32_hw_data *, int, int); 246 + static int nsp32_prom_get (nsp32_hw_data *, int); 252 247 253 248 /* debug/warning/info message */ 254 249 static void nsp32_message (const char *, int, char *, char *, ...); ··· 361 356 static void nsp32_build_identify(struct scsi_cmnd *SCpnt) 362 357 { 363 358 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; 364 - int pos = data->msgout_len; 365 - int mode = FALSE; 359 + int pos = data->msgout_len; 360 + int mode = FALSE; 366 361 367 362 /* XXX: Auto DiscPriv detection is progressing... */ 368 363 if (disc_priv == 0) { ··· 382 377 unsigned char offset) 383 378 { 384 379 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; 385 - int pos = data->msgout_len; 380 + int pos = data->msgout_len; 386 381 387 382 data->msgoutbuf[pos] = EXTENDED_MESSAGE; pos++; 388 383 data->msgoutbuf[pos] = EXTENDED_SDTR_LEN; pos++; 389 384 data->msgoutbuf[pos] = EXTENDED_SDTR; pos++; 390 - data->msgoutbuf[pos] = period; pos++; 391 - data->msgoutbuf[pos] = offset; pos++; 385 + data->msgoutbuf[pos] = period; pos++; 386 + data->msgoutbuf[pos] = offset; pos++; 392 387 393 388 data->msgout_len = pos; 394 389 } ··· 399 394 static void nsp32_build_nop(struct scsi_cmnd *SCpnt) 400 395 { 401 396 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; 402 - int pos = data->msgout_len; 397 + int pos = data->msgout_len; 403 398 404 399 if (pos != 0) { 405 400 nsp32_msg(KERN_WARNING, ··· 417 412 static void nsp32_build_reject(struct scsi_cmnd *SCpnt) 418 413 { 419 414 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; 420 - int pos = data->msgout_len; 415 + int pos = data->msgout_len; 421 416 422 417 data->msgoutbuf[pos] = MESSAGE_REJECT; pos++; 423 418 data->msgout_len = pos; 424 419 } 425 - 420 + 426 421 /* 427 422 * timer 428 423 */ ··· 455 450 unsigned char phase; 456 451 int i, ret; 457 452 unsigned int msgout; 458 - u16_le s; 453 + u16_le s; 459 454 460 455 nsp32_dbg(NSP32_DEBUG_AUTOSCSI, "in"); 461 456 ··· 487 482 * the sending order of the message is: 488 483 * MCNT 3: MSG#0 -> MSG#1 -> MSG#2 489 484 * MCNT 2: MSG#1 -> MSG#2 490 - * MCNT 1: MSG#2 485 + * MCNT 1: MSG#2 491 486 */ 492 487 msgout >>= 8; 493 488 msgout |= ((unsigned int)(data->msgoutbuf[i]) << 24); ··· 499 494 msgout = 0; 500 495 } 501 496 502 - // nsp_dbg(NSP32_DEBUG_AUTOSCSI, "sel time out=0x%x\n", nsp32_read2(base, SEL_TIME_OUT)); 497 + // nsp_dbg(NSP32_DEBUG_AUTOSCSI, "sel time out=0x%x\n", 498 + // nsp32_read2(base, SEL_TIME_OUT)); 503 499 // nsp32_write2(base, SEL_TIME_OUT, SEL_TIMEOUT_TIME); 504 500 505 501 /* ··· 526 520 527 521 /* command control */ 528 522 param->command_control = cpu_to_le16(CLEAR_CDB_FIFO_POINTER | 529 - AUTOSCSI_START | 530 - AUTO_MSGIN_00_OR_04 | 531 - AUTO_MSGIN_02 | 532 - AUTO_ATN ); 523 + AUTOSCSI_START | 524 + AUTO_MSGIN_00_OR_04 | 525 + AUTO_MSGIN_02 | 526 + AUTO_ATN ); 533 527 534 528 535 529 /* transfer control */ ··· 561 555 /* 562 556 * transfer parameter to ASIC 563 557 */ 564 - nsp32_write4(base, SGT_ADR, data->auto_paddr); 565 - nsp32_write2(base, COMMAND_CONTROL, CLEAR_CDB_FIFO_POINTER | 566 - AUTO_PARAMETER ); 558 + nsp32_write4(base, SGT_ADR, data->auto_paddr); 559 + nsp32_write2(base, COMMAND_CONTROL, 560 + CLEAR_CDB_FIFO_POINTER | AUTO_PARAMETER ); 567 561 568 562 /* 569 563 * Check arbitration ··· 605 599 SCpnt->result = DID_BUS_BUSY << 16; 606 600 status = 1; 607 601 goto out; 608 - } 602 + } 609 603 610 604 /* 611 605 * clear execph ··· 622 616 */ 623 617 for (i = 0; i < SCpnt->cmd_len; i++) { 624 618 nsp32_write1(base, COMMAND_DATA, SCpnt->cmnd[i]); 625 - } 619 + } 626 620 nsp32_dbg(NSP32_DEBUG_CDB_CONTENTS, "CDB[0]=[0x%x]", SCpnt->cmnd[0]); 627 621 628 622 /* 629 623 * set SCSIOUT LATCH(initiator)/TARGET(target) (OR-ed) ID 630 624 */ 631 - nsp32_write1(base, SCSI_OUT_LATCH_TARGET_ID, BIT(host_id) | BIT(target)); 625 + nsp32_write1(base, SCSI_OUT_LATCH_TARGET_ID, 626 + BIT(host_id) | BIT(target)); 632 627 633 628 /* 634 629 * set SCSI MSGOUT REG ··· 649 642 * the sending order of the message is: 650 643 * MCNT 3: MSG#0 -> MSG#1 -> MSG#2 651 644 * MCNT 2: MSG#1 -> MSG#2 652 - * MCNT 1: MSG#2 645 + * MCNT 1: MSG#2 653 646 */ 654 647 msgout >>= 8; 655 648 msgout |= ((unsigned int)(data->msgoutbuf[i]) << 24); ··· 669 662 670 663 /* 671 664 * set SREQ hazard killer sampling rate 672 - * 665 + * 673 666 * TODO: sample_rate (BASE+0F) is 0 when internal clock = 40MHz. 674 667 * check other internal clock! 675 668 */ ··· 694 687 nsp32_dbg(NSP32_DEBUG_AUTOSCSI, 695 688 "syncreg=0x%x, ackwidth=0x%x, sgtpaddr=0x%x, id=0x%x", 696 689 nsp32_read1(base, SYNC_REG), nsp32_read1(base, ACK_WIDTH), 697 - nsp32_read4(base, SGT_ADR), nsp32_read1(base, SCSI_OUT_LATCH_TARGET_ID)); 690 + nsp32_read4(base, SGT_ADR), 691 + nsp32_read1(base, SCSI_OUT_LATCH_TARGET_ID)); 698 692 nsp32_dbg(NSP32_DEBUG_AUTOSCSI, "msgout_len=%d, msgout=0x%x", 699 693 data->msgout_len, msgout); 700 694 ··· 724 716 * start AUTO SCSI, kick off arbitration 725 717 */ 726 718 command = (CLEAR_CDB_FIFO_POINTER | 727 - AUTOSCSI_START | 719 + AUTOSCSI_START | 728 720 AUTO_MSGIN_00_OR_04 | 729 - AUTO_MSGIN_02 | 730 - AUTO_ATN ); 721 + AUTO_MSGIN_02 | 722 + AUTO_ATN); 731 723 nsp32_write2(base, COMMAND_CONTROL, command); 732 724 733 725 /* ··· 747 739 748 740 /* 749 741 * Arbitration Status Check 750 - * 742 + * 751 743 * Note: Arbitration counter is waited during ARBIT_GO is not lifting. 752 - * Using udelay(1) consumes CPU time and system time, but 744 + * Using udelay(1) consumes CPU time and system time, but 753 745 * arbitration delay time is defined minimal 2.4us in SCSI 754 746 * specification, thus udelay works as coarse grained wait timer. 755 747 */ ··· 784 776 nsp32_dbg(NSP32_DEBUG_AUTOSCSI, "arbit timeout"); 785 777 SCpnt->result = DID_NO_CONNECT << 16; 786 778 status = FALSE; 787 - } 779 + } 788 780 789 781 /* 790 782 * clear Arbit ··· 830 822 * or current nexus is not existed, unexpected 831 823 * reselection is occurred. Send reject message. 832 824 */ 833 - if (newid >= ARRAY_SIZE(data->lunt) || newlun >= ARRAY_SIZE(data->lunt[0])) { 825 + if (newid >= ARRAY_SIZE(data->lunt) || 826 + newlun >= ARRAY_SIZE(data->lunt[0])) { 834 827 nsp32_msg(KERN_WARNING, "unknown id/lun"); 835 828 return FALSE; 836 829 } else if(data->lunt[newid][newlun].SCpnt == NULL) { ··· 885 876 886 877 if (le32_to_cpu(sgt[i].len) > 0x10000) { 887 878 nsp32_msg(KERN_ERR, 888 - "can't transfer over 64KB at a time, size=0x%x", le32_to_cpu(sgt[i].len)); 879 + "can't transfer over 64KB at a time, " 880 + "size=0x%x", le32_to_cpu(sgt[i].len)); 889 881 return FALSE; 890 882 } 891 883 nsp32_dbg(NSP32_DEBUG_SGLIST, ··· 904 894 return TRUE; 905 895 } 906 896 907 - static int nsp32_queuecommand_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) 897 + static int nsp32_queuecommand_lck(struct scsi_cmnd *SCpnt, 898 + void (*done)(struct scsi_cmnd *)) 908 899 { 909 900 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; 910 901 nsp32_target *target; ··· 915 904 nsp32_dbg(NSP32_DEBUG_QUEUECOMMAND, 916 905 "enter. target: 0x%x LUN: 0x%llx cmnd: 0x%x cmndlen: 0x%x " 917 906 "use_sg: 0x%x reqbuf: 0x%lx reqlen: 0x%x", 918 - SCpnt->device->id, SCpnt->device->lun, SCpnt->cmnd[0], SCpnt->cmd_len, 919 - scsi_sg_count(SCpnt), scsi_sglist(SCpnt), scsi_bufflen(SCpnt)); 907 + SCpnt->device->id, SCpnt->device->lun, SCpnt->cmnd[0], 908 + SCpnt->cmd_len, scsi_sg_count(SCpnt), scsi_sglist(SCpnt), 909 + scsi_bufflen(SCpnt)); 920 910 921 911 if (data->CurrentSC != NULL) { 922 912 nsp32_msg(KERN_ERR, "Currentsc != NULL. Cancel this command request"); ··· 948 936 SCpnt->scsi_done = done; 949 937 data->CurrentSC = SCpnt; 950 938 SCpnt->SCp.Status = SAM_STAT_CHECK_CONDITION; 951 - SCpnt->SCp.Message = 0; 952 939 scsi_set_resid(SCpnt, scsi_bufflen(SCpnt)); 953 940 954 941 SCpnt->SCp.ptr = (char *)scsi_sglist(SCpnt); ··· 977 966 /* Build IDENTIFY */ 978 967 nsp32_build_identify(SCpnt); 979 968 980 - /* 969 + /* 981 970 * If target is the first time to transfer after the reset 982 971 * (target don't have SDTR_DONE and SDTR_INITIATOR), sync 983 972 * message SDTR is needed to do synchronous transfer. ··· 1062 1051 nsp32_index_write2(base, CFG_LATE_CACHE, lc_reg & 0xffff); 1063 1052 } 1064 1053 1065 - nsp32_write2(base, IRQ_CONTROL, IRQ_CONTROL_ALL_IRQ_MASK); 1066 - nsp32_write2(base, TRANSFER_CONTROL, 0); 1067 - nsp32_write4(base, BM_CNT, 0); 1054 + nsp32_write2(base, IRQ_CONTROL, IRQ_CONTROL_ALL_IRQ_MASK); 1055 + nsp32_write2(base, TRANSFER_CONTROL, 0); 1056 + nsp32_write4(base, BM_CNT, 0); 1068 1057 nsp32_write2(base, SCSI_EXECUTE_PHASE, 0); 1069 1058 1070 1059 do { ··· 1092 1081 nsp32_index_read1(base, FIFO_EMPTY_SHLD_COUNT)); 1093 1082 1094 1083 nsp32_index_write1(base, CLOCK_DIV, data->clock); 1095 - nsp32_index_write1(base, BM_CYCLE, MEMRD_CMD1 | SGT_AUTO_PARA_MEMED_CMD); 1084 + nsp32_index_write1(base, BM_CYCLE, 1085 + MEMRD_CMD1 | SGT_AUTO_PARA_MEMED_CMD); 1096 1086 nsp32_write1(base, PARITY_CONTROL, 0); /* parity check is disable */ 1097 1087 1098 1088 /* 1099 1089 * initialize MISC_WRRD register 1100 - * 1090 + * 1101 1091 * Note: Designated parameters is obeyed as following: 1102 1092 * MISC_SCSI_DIRECTION_DETECTOR_SELECT: It must be set. 1103 1093 * MISC_MASTER_TERMINATION_SELECT: It must be set. ··· 1113 1101 */ 1114 1102 nsp32_index_write2(base, MISC_WR, 1115 1103 (SCSI_DIRECTION_DETECTOR_SELECT | 1116 - DELAYED_BMSTART | 1117 - MASTER_TERMINATION_SELECT | 1118 - BMREQ_NEGATE_TIMING_SEL | 1119 - AUTOSEL_TIMING_SEL | 1104 + DELAYED_BMSTART | 1105 + MASTER_TERMINATION_SELECT | 1106 + BMREQ_NEGATE_TIMING_SEL | 1107 + AUTOSEL_TIMING_SEL | 1120 1108 BMSTOP_CHANGE2_NONDATA_PHASE)); 1121 1109 1122 1110 nsp32_index_write1(base, TERM_PWR_CONTROL, 0); ··· 1137 1125 * enable to select designated IRQ (except for 1138 1126 * IRQSELECT_SERR, IRQSELECT_PERR, IRQSELECT_BMCNTERR) 1139 1127 */ 1140 - nsp32_index_write2(base, IRQ_SELECT, IRQSELECT_TIMER_IRQ | 1141 - IRQSELECT_SCSIRESET_IRQ | 1142 - IRQSELECT_FIFO_SHLD_IRQ | 1143 - IRQSELECT_RESELECT_IRQ | 1144 - IRQSELECT_PHASE_CHANGE_IRQ | 1145 - IRQSELECT_AUTO_SCSI_SEQ_IRQ | 1146 - // IRQSELECT_BMCNTERR_IRQ | 1147 - IRQSELECT_TARGET_ABORT_IRQ | 1148 - IRQSELECT_MASTER_ABORT_IRQ ); 1128 + nsp32_index_write2(base, IRQ_SELECT, 1129 + IRQSELECT_TIMER_IRQ | 1130 + IRQSELECT_SCSIRESET_IRQ | 1131 + IRQSELECT_FIFO_SHLD_IRQ | 1132 + IRQSELECT_RESELECT_IRQ | 1133 + IRQSELECT_PHASE_CHANGE_IRQ | 1134 + IRQSELECT_AUTO_SCSI_SEQ_IRQ | 1135 + // IRQSELECT_BMCNTERR_IRQ | 1136 + IRQSELECT_TARGET_ABORT_IRQ | 1137 + IRQSELECT_MASTER_ABORT_IRQ ); 1149 1138 nsp32_write2(base, IRQ_CONTROL, 0); 1150 1139 1151 1140 /* PCI LED off */ ··· 1176 1163 * IRQ check, then enable IRQ mask 1177 1164 */ 1178 1165 irq_stat = nsp32_read2(base, IRQ_STATUS); 1179 - nsp32_dbg(NSP32_DEBUG_INTR, 1166 + nsp32_dbg(NSP32_DEBUG_INTR, 1180 1167 "enter IRQ: %d, IRQstatus: 0x%x", irq, irq_stat); 1181 1168 /* is this interrupt comes from Ninja asic? */ 1182 1169 if ((irq_stat & IRQSTATUS_ANY_IRQ) == 0) { 1183 - nsp32_dbg(NSP32_DEBUG_INTR, "shared interrupt: irq other 0x%x", irq_stat); 1170 + nsp32_dbg(NSP32_DEBUG_INTR, 1171 + "shared interrupt: irq other 0x%x", irq_stat); 1184 1172 goto out2; 1185 1173 } 1186 1174 handled = 1; ··· 1221 1207 1222 1208 if (SCpnt == NULL) { 1223 1209 nsp32_msg(KERN_WARNING, "SCpnt==NULL this can't be happened"); 1224 - nsp32_msg(KERN_WARNING, "irq_stat=0x%x trans_stat=0x%x", irq_stat, trans_stat); 1210 + nsp32_msg(KERN_WARNING, "irq_stat=0x%x trans_stat=0x%x", 1211 + irq_stat, trans_stat); 1225 1212 goto out; 1226 1213 } 1227 1214 ··· 1280 1265 "Data in/out phase processed"); 1281 1266 1282 1267 /* read BMCNT, SGT pointer addr */ 1283 - nsp32_dbg(NSP32_DEBUG_INTR, "BMCNT=0x%lx", 1268 + nsp32_dbg(NSP32_DEBUG_INTR, "BMCNT=0x%lx", 1284 1269 nsp32_read4(base, BM_CNT)); 1285 - nsp32_dbg(NSP32_DEBUG_INTR, "addr=0x%lx", 1270 + nsp32_dbg(NSP32_DEBUG_INTR, "addr=0x%lx", 1286 1271 nsp32_read4(base, SGT_ADR)); 1287 - nsp32_dbg(NSP32_DEBUG_INTR, "SACK=0x%lx", 1272 + nsp32_dbg(NSP32_DEBUG_INTR, "SACK=0x%lx", 1288 1273 nsp32_read4(base, SACK_CNT)); 1289 - nsp32_dbg(NSP32_DEBUG_INTR, "SSACK=0x%lx", 1274 + nsp32_dbg(NSP32_DEBUG_INTR, "SSACK=0x%lx", 1290 1275 nsp32_read4(base, SAVED_SACK_CNT)); 1291 1276 1292 1277 scsi_set_resid(SCpnt, 0); /* all data transferred! */ ··· 1321 1306 * Read CSB and substitute CSB for SCpnt->result 1322 1307 * to save status phase stutas byte. 1323 1308 * scsi error handler checks host_byte (DID_*: 1324 - * low level driver to indicate status), then checks 1309 + * low level driver to indicate status), then checks 1325 1310 * status_byte (SCSI status byte). 1326 1311 */ 1327 1312 SCpnt->result = (int)nsp32_read1(base, SCSI_CSB_IN); ··· 1329 1314 1330 1315 if (auto_stat & ILLEGAL_PHASE) { 1331 1316 /* Illegal phase is detected. SACK is not back. */ 1332 - nsp32_msg(KERN_WARNING, 1317 + nsp32_msg(KERN_WARNING, 1333 1318 "AUTO SCSI ILLEGAL PHASE OCCUR!!!!"); 1334 1319 1335 1320 /* TODO: currently we don't have any action... bus reset? */ ··· 1382 1367 break; 1383 1368 default: 1384 1369 nsp32_dbg(NSP32_DEBUG_INTR, "fifo/other phase"); 1385 - nsp32_dbg(NSP32_DEBUG_INTR, "irq_stat=0x%x trans_stat=0x%x", irq_stat, trans_stat); 1370 + nsp32_dbg(NSP32_DEBUG_INTR, "irq_stat=0x%x trans_stat=0x%x", 1371 + irq_stat, trans_stat); 1386 1372 show_busphase(busphase); 1387 1373 break; 1388 1374 } ··· 1449 1433 { 1450 1434 unsigned long flags; 1451 1435 nsp32_hw_data *data; 1452 - int hostno; 1436 + int hostno; 1453 1437 unsigned int base; 1454 1438 unsigned char mode_reg; 1455 - int id, speed; 1456 - long model; 1439 + int id, speed; 1440 + long model; 1457 1441 1458 1442 hostno = host->host_no; 1459 1443 data = (nsp32_hw_data *)host->hostdata; 1460 1444 base = host->io_port; 1461 1445 1462 1446 seq_puts(m, "NinjaSCSI-32 status\n\n"); 1463 - seq_printf(m, "Driver version: %s, $Revision: 1.33 $\n", nsp32_release_version); 1464 - seq_printf(m, "SCSI host No.: %d\n", hostno); 1465 - seq_printf(m, "IRQ: %d\n", host->irq); 1466 - seq_printf(m, "IO: 0x%lx-0x%lx\n", host->io_port, host->io_port + host->n_io_port - 1); 1467 - seq_printf(m, "MMIO(virtual address): 0x%lx-0x%lx\n", host->base, host->base + data->MmioLength - 1); 1468 - seq_printf(m, "sg_tablesize: %d\n", host->sg_tablesize); 1469 - seq_printf(m, "Chip revision: 0x%x\n", (nsp32_read2(base, INDEX_REG) >> 8) & 0xff); 1447 + seq_printf(m, "Driver version: %s, $Revision: 1.33 $\n", 1448 + nsp32_release_version); 1449 + seq_printf(m, "SCSI host No.: %d\n", hostno); 1450 + seq_printf(m, "IRQ: %d\n", host->irq); 1451 + seq_printf(m, "IO: 0x%lx-0x%lx\n", 1452 + host->io_port, host->io_port + host->n_io_port - 1); 1453 + seq_printf(m, "MMIO(virtual address): 0x%lx-0x%lx\n", 1454 + host->base, host->base + data->MmioLength - 1); 1455 + seq_printf(m, "sg_tablesize: %d\n", 1456 + host->sg_tablesize); 1457 + seq_printf(m, "Chip revision: 0x%x\n", 1458 + (nsp32_read2(base, INDEX_REG) >> 8) & 0xff); 1470 1459 1471 1460 mode_reg = nsp32_index_read1(base, CHIP_MODE); 1472 1461 model = data->pci_devid->driver_data; 1473 1462 1474 1463 #ifdef CONFIG_PM 1475 - seq_printf(m, "Power Management: %s\n", (mode_reg & OPTF) ? "yes" : "no"); 1464 + seq_printf(m, "Power Management: %s\n", 1465 + (mode_reg & OPTF) ? "yes" : "no"); 1476 1466 #endif 1477 - seq_printf(m, "OEM: %ld, %s\n", (mode_reg & (OEM0|OEM1)), nsp32_model[model]); 1467 + seq_printf(m, "OEM: %ld, %s\n", 1468 + (mode_reg & (OEM0|OEM1)), nsp32_model[model]); 1478 1469 1479 1470 spin_lock_irqsave(&(data->Lock), flags); 1480 1471 seq_printf(m, "CurrentSC: 0x%p\n\n", data->CurrentSC); ··· 1499 1476 } 1500 1477 1501 1478 if (data->target[id].sync_flag == SDTR_DONE) { 1502 - if (data->target[id].period == 0 && 1479 + if (data->target[id].period == 0 && 1503 1480 data->target[id].offset == ASYNC_OFFSET ) { 1504 1481 seq_puts(m, "async"); 1505 1482 } else { ··· 1541 1518 * clear TRANSFERCONTROL_BM_START 1542 1519 */ 1543 1520 nsp32_write2(base, TRANSFER_CONTROL, 0); 1544 - nsp32_write4(base, BM_CNT, 0); 1521 + nsp32_write4(base, BM_CNT, 0); 1545 1522 1546 1523 /* 1547 1524 * call scsi_done ··· 1551 1528 /* 1552 1529 * reset parameters 1553 1530 */ 1554 - data->cur_lunt->SCpnt = NULL; 1555 - data->cur_lunt = NULL; 1556 - data->cur_target = NULL; 1557 - data->CurrentSC = NULL; 1531 + data->cur_lunt->SCpnt = NULL; 1532 + data->cur_lunt = NULL; 1533 + data->cur_target = NULL; 1534 + data->CurrentSC = NULL; 1558 1535 } 1559 1536 1560 1537 ··· 1576 1553 nsp32_dbg(NSP32_DEBUG_BUSFREE, "enter execph=0x%x", execph); 1577 1554 show_autophase(execph); 1578 1555 1579 - nsp32_write4(base, BM_CNT, 0); 1556 + nsp32_write4(base, BM_CNT, 0); 1580 1557 nsp32_write2(base, TRANSFER_CONTROL, 0); 1581 1558 1582 1559 /* ··· 1584 1561 * 1585 1562 * VALID: 1586 1563 * Save Data Pointer is received. Adjust pointer. 1587 - * 1564 + * 1588 1565 * NO-VALID: 1589 1566 * SCSI-3 says if Save Data Pointer is not received, then we restart 1590 1567 * processing and we can't adjust any SCSI data pointer in next data ··· 1597 1574 * Check sack_cnt/saved_sack_cnt, then adjust sg table if 1598 1575 * needed. 1599 1576 */ 1600 - if (!(execph & MSGIN_00_VALID) && 1577 + if (!(execph & MSGIN_00_VALID) && 1601 1578 ((execph & DATA_IN_PHASE) || (execph & DATA_OUT_PHASE))) { 1602 1579 unsigned int sacklen, s_sacklen; 1603 1580 ··· 1640 1617 * no processing. 1641 1618 */ 1642 1619 } 1643 - 1620 + 1644 1621 if (execph & MSGIN_03_VALID) { 1645 1622 /* MsgIn03 was valid to be processed. No need processing. */ 1646 1623 } ··· 1662 1639 * negotiating. 1663 1640 */ 1664 1641 if (execph & (MSGIN_00_VALID | MSGIN_04_VALID)) { 1665 - /* 1642 + /* 1666 1643 * If valid message is received, then 1667 1644 * negotiation is succeeded. 1668 1645 */ ··· 1689 1666 nsp32_dbg(NSP32_DEBUG_BUSFREE, "command complete"); 1690 1667 1691 1668 SCpnt->SCp.Status = nsp32_read1(base, SCSI_CSB_IN); 1692 - SCpnt->SCp.Message = 0; 1693 - nsp32_dbg(NSP32_DEBUG_BUSFREE, 1669 + nsp32_dbg(NSP32_DEBUG_BUSFREE, 1694 1670 "normal end stat=0x%x resid=0x%x\n", 1695 1671 SCpnt->SCp.Status, scsi_get_resid(SCpnt)); 1696 - SCpnt->result = (DID_OK << 16) | 1697 - (SCpnt->SCp.Message << 8) | 1698 - (SCpnt->SCp.Status << 0); 1672 + SCpnt->result = (DID_OK << 16) | 1673 + (SCpnt->SCp.Status << 0); 1699 1674 nsp32_scsi_done(SCpnt); 1700 1675 /* All operation is done */ 1701 1676 return TRUE; 1702 1677 } else if (execph & MSGIN_04_VALID) { 1703 1678 /* MsgIn 04: Disconnect */ 1704 1679 SCpnt->SCp.Status = nsp32_read1(base, SCSI_CSB_IN); 1705 - SCpnt->SCp.Message = 4; 1706 - 1680 + 1707 1681 nsp32_dbg(NSP32_DEBUG_BUSFREE, "disconnect"); 1708 1682 return TRUE; 1709 1683 } else { ··· 1708 1688 nsp32_msg(KERN_WARNING, "unexpected bus free occurred"); 1709 1689 1710 1690 /* DID_ERROR? */ 1711 - //SCpnt->result = (DID_OK << 16) | (SCpnt->SCp.Message << 8) | (SCpnt->SCp.Status << 0); 1691 + //SCpnt->result = (DID_OK << 16) | (SCpnt->SCp.Status << 0); 1712 1692 SCpnt->result = DID_ERROR << 16; 1713 1693 nsp32_scsi_done(SCpnt); 1714 1694 return TRUE; ··· 1726 1706 static void nsp32_adjust_busfree(struct scsi_cmnd *SCpnt, unsigned int s_sacklen) 1727 1707 { 1728 1708 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; 1729 - int old_entry = data->cur_entry; 1730 - int new_entry; 1731 - int sg_num = data->cur_lunt->sg_num; 1732 - nsp32_sgtable *sgt = data->cur_lunt->sglun->sgt; 1733 - unsigned int restlen, sentlen; 1734 - u32_le len, addr; 1709 + int old_entry = data->cur_entry; 1710 + int new_entry; 1711 + int sg_num = data->cur_lunt->sg_num; 1712 + nsp32_sgtable *sgt = data->cur_lunt->sglun->sgt; 1713 + unsigned int restlen, sentlen; 1714 + u32_le len, addr; 1735 1715 1736 1716 nsp32_dbg(NSP32_DEBUG_SGLIST, "old resid=0x%x", scsi_get_resid(SCpnt)); 1737 1717 ··· 1739 1719 s_sacklen -= le32_to_cpu(sgt[old_entry].addr) & 3; 1740 1720 1741 1721 /* 1742 - * calculate new_entry from sack count and each sgt[].len 1722 + * calculate new_entry from sack count and each sgt[].len 1743 1723 * calculate the byte which is intent to send 1744 1724 */ 1745 1725 sentlen = 0; ··· 1757 1737 1758 1738 if (sentlen == s_sacklen) { 1759 1739 /* XXX: confirm it's ok or not */ 1760 - /* In this case, it's ok because we are at 1761 - the head element of the sg. restlen is correctly calculated. */ 1740 + /* In this case, it's ok because we are at 1741 + * the head element of the sg. restlen is correctly 1742 + * calculated. 1743 + */ 1762 1744 } 1763 1745 1764 1746 /* calculate the rest length for transferring */ ··· 1775 1753 1776 1754 /* set cur_entry with new_entry */ 1777 1755 data->cur_entry = new_entry; 1778 - 1756 + 1779 1757 return; 1780 1758 1781 1759 last: ··· 1803 1781 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; 1804 1782 unsigned int base = SCpnt->device->host->io_port; 1805 1783 int i; 1806 - 1784 + 1807 1785 nsp32_dbg(NSP32_DEBUG_MSGOUTOCCUR, 1808 1786 "enter: msgout_len: 0x%x", data->msgout_len); 1809 1787 ··· 1837 1815 //nsp32_restart_autoscsi(SCpnt, command); 1838 1816 nsp32_write2(base, COMMAND_CONTROL, 1839 1817 (CLEAR_CDB_FIFO_POINTER | 1840 - AUTO_COMMAND_PHASE | 1841 - AUTOSCSI_RESTART | 1842 - AUTO_MSGIN_00_OR_04 | 1843 - AUTO_MSGIN_02 )); 1818 + AUTO_COMMAND_PHASE | 1819 + AUTOSCSI_RESTART | 1820 + AUTO_MSGIN_00_OR_04 | 1821 + AUTO_MSGIN_02 )); 1844 1822 } 1845 1823 /* 1846 1824 * Write data with SACK, then wait sack is ··· 1940 1918 unsigned char msgtype; 1941 1919 unsigned char newlun; 1942 1920 unsigned short command = 0; 1943 - int msgclear = TRUE; 1944 - long new_sgtp; 1945 - int ret; 1921 + int msgclear = TRUE; 1922 + long new_sgtp; 1923 + int ret; 1946 1924 1947 1925 /* 1948 1926 * read first message ··· 1982 1960 goto reject; 1983 1961 } 1984 1962 } 1985 - 1963 + 1986 1964 /* 1987 1965 * processing messages except for IDENTIFY 1988 1966 * ··· 1998 1976 * These messages should not be occurred. 1999 1977 * They should be processed on AutoSCSI sequencer. 2000 1978 */ 2001 - nsp32_msg(KERN_WARNING, 1979 + nsp32_msg(KERN_WARNING, 2002 1980 "unexpected message of AutoSCSI MsgIn: 0x%x", msg); 2003 1981 break; 2004 - 1982 + 2005 1983 case RESTORE_POINTERS: 2006 1984 /* 2007 1985 * AutoMsgIn03 is disabled, and HBA gets this message. ··· 2027 2005 /* 2028 2006 * set new sg pointer 2029 2007 */ 2030 - new_sgtp = data->cur_lunt->sglun_paddr + 2008 + new_sgtp = data->cur_lunt->sglun_paddr + 2031 2009 (data->cur_lunt->cur_entry * sizeof(nsp32_sgtable)); 2032 2010 nsp32_write4(base, SGT_ADR, new_sgtp); 2033 2011 ··· 2038 2016 * These messages should not be occurred. 2039 2017 * They should be processed on AutoSCSI sequencer. 2040 2018 */ 2041 - nsp32_msg (KERN_WARNING, 2019 + nsp32_msg (KERN_WARNING, 2042 2020 "unexpected message of AutoSCSI MsgIn: SAVE_POINTERS"); 2043 - 2021 + 2044 2022 break; 2045 - 2023 + 2046 2024 case MESSAGE_REJECT: 2047 - /* If previous message_out is sending SDTR, and get 2025 + /* If previous message_out is sending SDTR, and get 2048 2026 message_reject from target, SDTR negotiation is failed */ 2049 2027 if (data->cur_target->sync_flag & 2050 2028 (SDTR_INITIATOR | SDTR_TARGET)) { ··· 2063 2041 case LINKED_CMD_COMPLETE: 2064 2042 case LINKED_FLG_CMD_COMPLETE: 2065 2043 /* queue tag is not supported currently */ 2066 - nsp32_msg (KERN_WARNING, 2044 + nsp32_msg (KERN_WARNING, 2067 2045 "unsupported message: 0x%x", msgtype); 2068 2046 break; 2069 2047 ··· 2116 2094 } 2117 2095 2118 2096 /* 2119 - * Reach here means regular length of each type of 2097 + * Reach here means regular length of each type of 2120 2098 * extended messages. 2121 2099 */ 2122 2100 switch (data->msginbuf[2]) { ··· 2151 2129 goto reject; /* not implemented yet */ 2152 2130 2153 2131 break; 2154 - 2132 + 2155 2133 default: 2156 2134 goto reject; 2157 2135 } 2158 2136 break; 2159 - 2137 + 2160 2138 default: 2161 2139 goto reject; 2162 2140 } ··· 2172 2150 * AutoSCSI restart, at the same time MsgOutOccur should be 2173 2151 * happened (however, such situation is really possible...?). 2174 2152 */ 2175 - if (data->msgout_len > 0) { 2153 + if (data->msgout_len > 0) { 2176 2154 nsp32_write4(base, SCSI_MSG_OUT, 0); 2177 2155 command |= AUTO_ATN; 2178 2156 } ··· 2214 2192 return; 2215 2193 2216 2194 reject: 2217 - nsp32_msg(KERN_WARNING, 2195 + nsp32_msg(KERN_WARNING, 2218 2196 "invalid or unsupported MessageIn, rejected. " 2219 2197 "current msg: 0x%x (len: 0x%x), processing msg: 0x%x", 2220 2198 msg, data->msgin_len, msgtype); ··· 2225 2203 } 2226 2204 2227 2205 /* 2228 - * 2206 + * 2229 2207 */ 2230 2208 static void nsp32_analyze_sdtr(struct scsi_cmnd *SCpnt) 2231 2209 { 2232 2210 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; 2233 - nsp32_target *target = data->cur_target; 2234 - unsigned char get_period = data->msginbuf[3]; 2235 - unsigned char get_offset = data->msginbuf[4]; 2236 - int entry; 2211 + nsp32_target *target = data->cur_target; 2212 + unsigned char get_period = data->msginbuf[3]; 2213 + unsigned char get_offset = data->msginbuf[4]; 2214 + int entry; 2237 2215 2238 2216 nsp32_dbg(NSP32_DEBUG_MSGINOCCUR, "enter"); 2239 2217 ··· 2241 2219 * If this inititor sent the SDTR message, then target responds SDTR, 2242 2220 * initiator SYNCREG, ACKWIDTH from SDTR parameter. 2243 2221 * Messages are not appropriate, then send back reject message. 2244 - * If initiator did not send the SDTR, but target sends SDTR, 2222 + * If initiator did not send the SDTR, but target sends SDTR, 2245 2223 * initiator calculator the appropriate parameter and send back SDTR. 2246 - */ 2224 + */ 2247 2225 if (target->sync_flag & SDTR_INITIATOR) { 2248 2226 /* 2249 2227 * Initiator sent SDTR, the target responds and 2250 2228 * send back negotiation SDTR. 2251 2229 */ 2252 2230 nsp32_dbg(NSP32_DEBUG_MSGINOCCUR, "target responds SDTR"); 2253 - 2231 + 2254 2232 target->sync_flag &= ~SDTR_INITIATOR; 2255 2233 target->sync_flag |= SDTR_DONE; 2256 2234 ··· 2264 2242 */ 2265 2243 goto reject; 2266 2244 } 2267 - 2245 + 2268 2246 if (get_offset == ASYNC_OFFSET) { 2269 2247 /* 2270 2248 * Negotiation is succeeded, the target want ··· 2295 2273 2296 2274 if (entry < 0) { 2297 2275 /* 2298 - * Target want to use long period which is not 2276 + * Target want to use long period which is not 2299 2277 * acceptable NinjaSCSI-32Bi/UDE. 2300 2278 */ 2301 2279 goto reject; ··· 2308 2286 } else { 2309 2287 /* Target send SDTR to initiator. */ 2310 2288 nsp32_dbg(NSP32_DEBUG_MSGINOCCUR, "target send SDTR"); 2311 - 2289 + 2312 2290 target->sync_flag |= SDTR_INITIATOR; 2313 2291 2314 2292 /* offset: */ ··· 2431 2409 */ 2432 2410 static void nsp32_set_sync_entry(nsp32_hw_data *data, 2433 2411 nsp32_target *target, 2434 - int entry, 2412 + int entry, 2435 2413 unsigned char offset) 2436 2414 { 2437 2415 unsigned char period, ackwidth, sample_rate; ··· 2460 2438 static void nsp32_wait_req(nsp32_hw_data *data, int state) 2461 2439 { 2462 2440 unsigned int base = data->BaseAddress; 2463 - int wait_time = 0; 2441 + int wait_time = 0; 2464 2442 unsigned char bus, req_bit; 2465 2443 2466 2444 if (!((state == ASSERT) || (state == NEGATE))) { ··· 2472 2450 do { 2473 2451 bus = nsp32_read1(base, SCSI_BUS_MONITOR); 2474 2452 if ((bus & BUSMON_REQ) == req_bit) { 2475 - nsp32_dbg(NSP32_DEBUG_WAIT, 2453 + nsp32_dbg(NSP32_DEBUG_WAIT, 2476 2454 "wait_time: %d", wait_time); 2477 2455 return; 2478 2456 } ··· 2489 2467 static void nsp32_wait_sack(nsp32_hw_data *data, int state) 2490 2468 { 2491 2469 unsigned int base = data->BaseAddress; 2492 - int wait_time = 0; 2470 + int wait_time = 0; 2493 2471 unsigned char bus, ack_bit; 2494 2472 2495 2473 if (!((state == ASSERT) || (state == NEGATE))) { ··· 2554 2532 struct Scsi_Host *host; /* registered host structure */ 2555 2533 struct resource *res; 2556 2534 nsp32_hw_data *data; 2557 - int ret; 2558 - int i, j; 2535 + int ret; 2536 + int i, j; 2559 2537 2560 2538 nsp32_dbg(NSP32_DEBUG_REGISTER, "enter"); 2561 2539 ··· 2632 2610 */ 2633 2611 2634 2612 /* 2635 - * setup DMA 2613 + * setup DMA 2636 2614 */ 2637 2615 if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)) != 0) { 2638 2616 nsp32_msg (KERN_ERR, "failed to set PCI DMA mask"); ··· 2732 2710 goto free_sg_list; 2733 2711 } 2734 2712 2735 - /* 2713 + /* 2736 2714 * PCI IO register 2737 2715 */ 2738 2716 res = request_region(host->io_port, host->n_io_port, "nsp32"); 2739 2717 if (res == NULL) { 2740 - nsp32_msg(KERN_ERR, 2718 + nsp32_msg(KERN_ERR, 2741 2719 "I/O region 0x%x+0x%x is already used", 2742 2720 data->BaseAddress, data->NumAddress); 2743 2721 goto free_irq; 2744 - } 2722 + } 2745 2723 2746 2724 ret = scsi_add_host(host, &pdev->dev); 2747 2725 if (ret) { ··· 2765 2743 free_autoparam: 2766 2744 dma_free_coherent(&pdev->dev, sizeof(nsp32_autoparam), 2767 2745 data->autoparam, data->auto_paddr); 2768 - 2746 + 2769 2747 scsi_unregister: 2770 2748 scsi_host_put(host); 2771 2749 ··· 2832 2810 } 2833 2811 2834 2812 nsp32_write2(base, TRANSFER_CONTROL, 0); 2835 - nsp32_write2(base, BM_CNT, 0); 2813 + nsp32_write2(base, BM_CNT, 0); 2836 2814 2837 2815 SCpnt->result = DID_ABORT << 16; 2838 2816 nsp32_scsi_done(SCpnt); ··· 2855 2833 * clear counter 2856 2834 */ 2857 2835 nsp32_write2(base, TRANSFER_CONTROL, 0); 2858 - nsp32_write4(base, BM_CNT, 0); 2859 - nsp32_write4(base, CLR_COUNTER, CLRCOUNTER_ALLMASK); 2836 + nsp32_write4(base, BM_CNT, 0); 2837 + nsp32_write4(base, CLR_COUNTER, CLRCOUNTER_ALLMASK); 2860 2838 2861 2839 /* 2862 2840 * fall back to asynchronous transfer mode ··· 2878 2856 for(i = 0; i < 5; i++) { 2879 2857 intrdat = nsp32_read2(base, IRQ_STATUS); /* dummy read */ 2880 2858 nsp32_dbg(NSP32_DEBUG_BUSRESET, "irq:1: 0x%x", intrdat); 2881 - } 2859 + } 2882 2860 2883 2861 data->CurrentSC = NULL; 2884 2862 } ··· 2889 2867 unsigned int base = SCpnt->device->host->io_port; 2890 2868 nsp32_hw_data *data = (nsp32_hw_data *)host->hostdata; 2891 2869 2892 - nsp32_msg(KERN_INFO, "Host Reset"); 2870 + nsp32_msg(KERN_INFO, "Host Reset"); 2893 2871 nsp32_dbg(NSP32_DEBUG_BUSRESET, "SCpnt=0x%x", SCpnt); 2894 2872 2895 2873 spin_lock_irq(SCpnt->device->host->host_lock); ··· 2964 2942 * AT24C01A (Logitec: LHA-600S), AT24C02 (Melco Buffalo: IFC-USLP) data map: 2965 2943 * 2966 2944 * ROMADDR 2967 - * 0x00 - 0x06 : Device Synchronous Transfer Period (SCSI ID 0 - 6) 2945 + * 0x00 - 0x06 : Device Synchronous Transfer Period (SCSI ID 0 - 6) 2968 2946 * Value 0x0: ASYNC, 0x0c: Ultra-20M, 0x19: Fast-10M 2969 2947 * 0x07 : HBA Synchronous Transfer Period 2970 2948 * Value 0: AutoSync, 1: Manual Setting 2971 2949 * 0x08 - 0x0f : Not Used? (0x0) 2972 2950 * 0x10 : Bus Termination 2973 - * Value 0: Auto[ON], 1: ON, 2: OFF 2951 + * Value 0: Auto[ON], 1: ON, 2: OFF 2974 2952 * 0x11 : Not Used? (0) 2975 2953 * 0x12 : Bus Reset Delay Time (0x03) 2976 2954 * 0x13 : Bootable CD Support ··· 2978 2956 * 0x14 : Device Scan 2979 2957 * Bit 7 6 5 4 3 2 1 0 2980 2958 * | <-----------------> 2981 - * | SCSI ID: Value 0: Skip, 1: YES 2959 + * | SCSI ID: Value 0: Skip, 1: YES 2982 2960 * |-> Value 0: ALL scan, Value 1: Manual 2983 2961 * 0x15 - 0x1b : Not Used? (0) 2984 2962 * 0x1c : Constant? (0x01) (clock div?) ··· 2989 2967 */ 2990 2968 static int nsp32_getprom_at24(nsp32_hw_data *data) 2991 2969 { 2992 - int ret, i; 2993 - int auto_sync; 2970 + int ret, i; 2971 + int auto_sync; 2994 2972 nsp32_target *target; 2995 - int entry; 2973 + int entry; 2996 2974 2997 2975 /* 2998 2976 * Reset time which is designated by EEPROM. ··· 3058 3036 * C16 110 (I-O Data: SC-NBD) data map: 3059 3037 * 3060 3038 * ROMADDR 3061 - * 0x00 - 0x06 : Device Synchronous Transfer Period (SCSI ID 0 - 6) 3039 + * 0x00 - 0x06 : Device Synchronous Transfer Period (SCSI ID 0 - 6) 3062 3040 * Value 0x0: 20MB/S, 0x1: 10MB/S, 0x2: 5MB/S, 0x3: ASYNC 3063 3041 * 0x07 : 0 (HBA Synchronous Transfer Period: Auto Sync) 3064 3042 * 0x08 - 0x0f : Not Used? (0x0) ··· 3066 3044 * Value 0: PIO, 1: Busmater 3067 3045 * 0x11 : Bus Reset Delay Time (0x00-0x20) 3068 3046 * 0x12 : Bus Termination 3069 - * Value 0: Disable, 1: Enable 3047 + * Value 0: Disable, 1: Enable 3070 3048 * 0x13 - 0x19 : Disconnection 3071 3049 * Value 0: Disable, 1: Enable 3072 3050 * 0x1a - 0x7c : Not Used? (0) ··· 3076 3054 */ 3077 3055 static int nsp32_getprom_c16(nsp32_hw_data *data) 3078 3056 { 3079 - int ret, i; 3057 + int ret, i; 3080 3058 nsp32_target *target; 3081 - int entry, val; 3059 + int entry, val; 3082 3060 3083 3061 /* 3084 3062 * Reset time which is designated by EEPROM. ··· 3178 3156 for (i = 7; i >= 0; i--) { 3179 3157 val += (nsp32_prom_read_bit(data) << i); 3180 3158 } 3181 - 3159 + 3182 3160 /* no ack */ 3183 3161 nsp32_prom_write_bit(data, 1); 3184 3162 ··· 3303 3281 nsp32_hw_data *data = (nsp32_hw_data *)host->hostdata; 3304 3282 unsigned short reg; 3305 3283 3306 - nsp32_msg(KERN_INFO, "pci-resume: pdev=0x%p, slot=%s, host=0x%p", pdev, pci_name(pdev), host); 3284 + nsp32_msg(KERN_INFO, "pci-resume: pdev=0x%p, slot=%s, host=0x%p", 3285 + pdev, pci_name(pdev), host); 3307 3286 3308 3287 pci_set_power_state(pdev, PCI_D0); 3309 3288 pci_enable_wake (pdev, PCI_D0, 0); ··· 3339 3316 3340 3317 nsp32_dbg(NSP32_DEBUG_REGISTER, "enter"); 3341 3318 3342 - ret = pci_enable_device(pdev); 3319 + ret = pci_enable_device(pdev); 3343 3320 if (ret) { 3344 3321 nsp32_msg(KERN_ERR, "failed to enable pci device"); 3345 3322 return ret; 3346 3323 } 3347 3324 3348 - data->Pci = pdev; 3325 + data->Pci = pdev; 3349 3326 data->pci_devid = id; 3350 3327 data->IrqNumber = pdev->irq; 3351 3328 data->BaseAddress = pci_resource_start(pdev, 0); ··· 3374 3351 3375 3352 nsp32_dbg(NSP32_DEBUG_REGISTER, "enter"); 3376 3353 3377 - scsi_remove_host(host); 3354 + scsi_remove_host(host); 3378 3355 3379 3356 nsp32_release(host); 3380 3357 ··· 3387 3364 .probe = nsp32_probe, 3388 3365 .remove = nsp32_remove, 3389 3366 #ifdef CONFIG_PM 3390 - .suspend = nsp32_suspend, 3391 - .resume = nsp32_resume, 3367 + .suspend = nsp32_suspend, 3368 + .resume = nsp32_resume, 3392 3369 #endif 3393 3370 }; 3394 3371
+1 -1
drivers/scsi/pcmcia/nsp_cs.c
··· 221 221 222 222 data->CurrentSC = SCpnt; 223 223 224 - SCpnt->SCp.Status = CHECK_CONDITION; 224 + SCpnt->SCp.Status = SAM_STAT_CHECK_CONDITION; 225 225 SCpnt->SCp.Message = 0; 226 226 SCpnt->SCp.have_data_in = IO_UNKNOWN; 227 227 SCpnt->SCp.sent_command = 0;
+2 -5
drivers/scsi/ps3rom.c
··· 234 234 } 235 235 236 236 if (res) { 237 - memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); 237 + scsi_build_sense(cmd, 0, ILLEGAL_REQUEST, 0, 0); 238 238 cmd->result = res; 239 - cmd->sense_buffer[0] = 0x70; 240 - cmd->sense_buffer[2] = ILLEGAL_REQUEST; 241 239 priv->curr_cmd = NULL; 242 240 cmd->scsi_done(cmd); 243 241 } ··· 317 319 goto done; 318 320 } 319 321 320 - scsi_build_sense_buffer(0, cmd->sense_buffer, sense_key, asc, ascq); 321 - cmd->result = SAM_STAT_CHECK_CONDITION; 322 + scsi_build_sense(cmd, 0, sense_key, asc, ascq); 322 323 323 324 done: 324 325 priv->curr_cmd = NULL;
+3 -12
drivers/scsi/qla2xxx/qla_isr.c
··· 2694 2694 2695 2695 /* check guard */ 2696 2696 if (e_guard != a_guard) { 2697 - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, 2698 - 0x10, 0x1); 2699 - set_driver_byte(cmd, DRIVER_SENSE); 2697 + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x1); 2700 2698 set_host_byte(cmd, DID_ABORT); 2701 - cmd->result |= SAM_STAT_CHECK_CONDITION; 2702 2699 return 1; 2703 2700 } 2704 2701 2705 2702 /* check ref tag */ 2706 2703 if (e_ref_tag != a_ref_tag) { 2707 - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, 2708 - 0x10, 0x3); 2709 - set_driver_byte(cmd, DRIVER_SENSE); 2704 + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x3); 2710 2705 set_host_byte(cmd, DID_ABORT); 2711 - cmd->result |= SAM_STAT_CHECK_CONDITION; 2712 2706 return 1; 2713 2707 } 2714 2708 2715 2709 /* check appl tag */ 2716 2710 if (e_app_tag != a_app_tag) { 2717 - scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, 2718 - 0x10, 0x2); 2719 - set_driver_byte(cmd, DRIVER_SENSE); 2711 + scsi_build_sense(cmd, 1, ILLEGAL_REQUEST, 0x10, 0x2); 2720 2712 set_host_byte(cmd, DID_ABORT); 2721 - cmd->result |= SAM_STAT_CHECK_CONDITION; 2722 2713 return 1; 2723 2714 } 2724 2715
+81 -57
drivers/scsi/qlogicfas408.c
··· 4 4 Use at your own risk. Support Tort Reform so you won't have to read all 5 5 these silly disclaimers. 6 6 7 - Copyright 1994, Tom Zerucha. 7 + Copyright 1994, Tom Zerucha. 8 8 tz@execpc.com 9 - 9 + 10 10 Additional Code, and much appreciated help by 11 11 Michael A. Griffith 12 12 grif@cs.ucr.edu ··· 22 22 23 23 Functions as standalone, loadable, and PCMCIA driver, the latter from 24 24 Dave Hinds' PCMCIA package. 25 - 25 + 26 26 Cleaned up 26/10/2002 by Alan Cox <alan@lxorguk.ukuu.org.uk> as part of the 2.5 27 27 SCSI driver cleanup and audit. This driver still needs work on the 28 28 following 29 - - Non terminating hardware waits 30 - - Some layering violations with its pcmcia stub 29 + - Non terminating hardware waits 30 + - Some layering violations with its pcmcia stub 31 31 32 32 Redistributable under terms of the GNU General Public License 33 33 ··· 92 92 /* 93 93 * Do a pseudo-dma tranfer 94 94 */ 95 - 96 - static int ql_pdma(struct qlogicfas408_priv *priv, int phase, char *request, int reqlen) 95 + 96 + static int ql_pdma(struct qlogicfas408_priv *priv, int phase, char *request, 97 + int reqlen) 97 98 { 98 99 int j; 99 100 int qbase = priv->qbase; ··· 109 108 request += 128; 110 109 } 111 110 while (reqlen >= 84 && !(j & 0xc0)) /* 2/3 */ 112 - if ((j = inb(qbase + 8)) & 4) 111 + if ((j = inb(qbase + 8)) & 4) 113 112 { 114 113 insl(qbase + 4, request, 21); 115 114 reqlen -= 84; ··· 124 123 /* until both empty and int (or until reclen is 0) */ 125 124 rtrc(7) 126 125 j = 0; 127 - while (reqlen && !((j & 0x10) && (j & 0xc0))) 126 + while (reqlen && !((j & 0x10) && (j & 0xc0))) 128 127 { 129 128 /* while bytes to receive and not empty */ 130 129 j &= 0xc0; 131 - while (reqlen && !((j = inb(qbase + 8)) & 0x10)) 130 + while (reqlen && !((j = inb(qbase + 8)) & 0x10)) 132 131 { 133 132 *request++ = inb(qbase + 4); 134 133 reqlen--; ··· 162 161 j = 0; 163 162 while (reqlen && !((j & 2) && (j & 0xc0))) { 164 163 /* while bytes to send and not full */ 165 - while (reqlen && !((j = inb(qbase + 8)) & 2)) 164 + while (reqlen && !((j = inb(qbase + 8)) & 2)) 166 165 { 167 166 outb(*request++, qbase + 4); 168 167 reqlen--; ··· 176 175 } 177 176 178 177 /* 179 - * Wait for interrupt flag (polled - not real hardware interrupt) 178 + * Wait for interrupt flag (polled - not real hardware interrupt) 180 179 */ 181 180 182 181 static int ql_wai(struct qlogicfas408_priv *priv) ··· 206 205 } 207 206 208 207 /* 209 - * Initiate scsi command - queueing handler 208 + * Initiate scsi command - queueing handler 210 209 * caller must hold host lock 211 210 */ 212 211 213 212 static void ql_icmd(struct scsi_cmnd *cmd) 214 213 { 215 214 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); 216 - int qbase = priv->qbase; 215 + int qbase = priv->qbase; 217 216 int int_type = priv->int_type; 218 217 unsigned int i; 219 218 ··· 254 253 } 255 254 256 255 /* 257 - * Process scsi command - usually after interrupt 256 + * Process scsi command - usually after interrupt 258 257 */ 259 258 260 - static unsigned int ql_pcmd(struct scsi_cmnd *cmd) 259 + static void ql_pcmd(struct scsi_cmnd *cmd) 261 260 { 262 261 unsigned int i, j; 263 262 unsigned long k; 264 - unsigned int result; /* ultimate return result */ 265 263 unsigned int status; /* scsi returned status */ 266 264 unsigned int message; /* scsi returned message */ 267 265 unsigned int phase; /* recorded scsi phase */ ··· 274 274 j = inb(qbase + 6); 275 275 i = inb(qbase + 5); 276 276 if (i == 0x20) { 277 - return (DID_NO_CONNECT << 16); 277 + set_host_byte(cmd, DID_NO_CONNECT); 278 + return; 278 279 } 279 280 i |= inb(qbase + 5); /* the 0x10 bit can be set after the 0x08 */ 280 281 if (i != 0x18) { 281 282 printk(KERN_ERR "Ql:Bad Interrupt status:%02x\n", i); 282 283 ql_zap(priv); 283 - return (DID_BAD_INTR << 16); 284 + set_host_byte(cmd, DID_BAD_INTR); 285 + return; 284 286 } 285 287 j &= 7; /* j = inb( qbase + 7 ) >> 5; */ 286 288 ··· 295 293 printk(KERN_ERR "Ql:Bad sequence for command %d, int %02X, cmdleft = %d\n", 296 294 j, i, inb(qbase + 7) & 0x1f); 297 295 ql_zap(priv); 298 - return (DID_ERROR << 16); 296 + set_host_byte(cmd, DID_ERROR); 297 + return; 299 298 } 300 - result = DID_OK; 299 + 301 300 if (inb(qbase + 7) & 0x1f) /* if some bytes in fifo */ 302 301 outb(1, qbase + 3); /* clear fifo */ 303 302 /* note that request_bufflen is the total xfer size when sg is used */ ··· 317 314 scsi_for_each_sg(cmd, sg, scsi_sg_count(cmd), i) { 318 315 if (priv->qabort) { 319 316 REG0; 320 - return ((priv->qabort == 1 ? 321 - DID_ABORT : DID_RESET) << 16); 317 + set_host_byte(cmd, 318 + priv->qabort == 1 ? 319 + DID_ABORT : DID_RESET); 322 320 } 323 321 buf = sg_virt(sg); 324 322 if (ql_pdma(priv, phase, buf, sg->length)) 325 323 break; 326 324 } 327 325 REG0; 328 - rtrc(2) 326 + rtrc(2); 329 327 /* 330 328 * Wait for irq (split into second state of irq handler 331 - * if this can take time) 329 + * if this can take time) 332 330 */ 333 - if ((k = ql_wai(priv))) 334 - return (k << 16); 331 + if ((k = ql_wai(priv))) { 332 + set_host_byte(cmd, k); 333 + return; 334 + } 335 335 k = inb(qbase + 5); /* should be 0x10, bus service */ 336 336 } 337 337 338 338 /* 339 - * Enter Status (and Message In) Phase 339 + * Enter Status (and Message In) Phase 340 340 */ 341 - 341 + 342 342 k = jiffies + WATCHDOG; 343 343 344 344 while (time_before(jiffies, k) && !priv->qabort && ··· 350 344 351 345 if (time_after_eq(jiffies, k)) { 352 346 ql_zap(priv); 353 - return (DID_TIME_OUT << 16); 347 + set_host_byte(cmd, DID_TIME_OUT); 348 + return; 354 349 } 355 350 356 351 /* FIXME: timeout ?? */ 357 352 while (inb(qbase + 5)) 358 353 cpu_relax(); /* clear pending ints */ 359 354 360 - if (priv->qabort) 361 - return ((priv->qabort == 1 ? DID_ABORT : DID_RESET) << 16); 355 + if (priv->qabort) { 356 + set_host_byte(cmd, 357 + priv->qabort == 1 ? DID_ABORT : DID_RESET); 358 + return; 359 + } 362 360 363 361 outb(0x11, qbase + 3); /* get status and message */ 364 - if ((k = ql_wai(priv))) 365 - return (k << 16); 362 + if ((k = ql_wai(priv))) { 363 + set_host_byte(cmd, k); 364 + return; 365 + } 366 366 i = inb(qbase + 5); /* get chip irq stat */ 367 367 j = inb(qbase + 7) & 0x1f; /* and bytes rec'd */ 368 368 status = inb(qbase + 2); 369 369 message = inb(qbase + 2); 370 370 371 371 /* 372 - * Should get function complete int if Status and message, else 373 - * bus serv if only status 372 + * Should get function complete int if Status and message, else 373 + * bus serv if only status 374 374 */ 375 375 if (!((i == 8 && j == 2) || (i == 0x10 && j == 1))) { 376 376 printk(KERN_ERR "Ql:Error during status phase, int=%02X, %d bytes recd\n", i, j); 377 - result = DID_ERROR; 377 + set_host_byte(cmd, DID_ERROR); 378 378 } 379 379 outb(0x12, qbase + 3); /* done, disconnect */ 380 - rtrc(1) 381 - if ((k = ql_wai(priv))) 382 - return (k << 16); 380 + rtrc(1); 381 + if ((k = ql_wai(priv))) { 382 + set_host_byte(cmd, k); 383 + return; 384 + } 383 385 384 386 /* 385 - * Should get bus service interrupt and disconnect interrupt 387 + * Should get bus service interrupt and disconnect interrupt 386 388 */ 387 - 389 + 388 390 i = inb(qbase + 5); /* should be bus service */ 389 391 while (!priv->qabort && ((i & 0x20) != 0x20)) { 390 392 barrier(); 391 393 cpu_relax(); 392 394 i |= inb(qbase + 5); 393 395 } 394 - rtrc(0) 396 + rtrc(0); 395 397 396 - if (priv->qabort) 397 - return ((priv->qabort == 1 ? DID_ABORT : DID_RESET) << 16); 398 - 399 - return (result << 16) | (message << 8) | (status & STATUS_MASK); 398 + if (priv->qabort) { 399 + set_host_byte(cmd, 400 + priv->qabort == 1 ? DID_ABORT : DID_RESET); 401 + return; 402 + } 403 + 404 + set_host_byte(cmd, DID_OK); 405 + if (message != COMMAND_COMPLETE) 406 + scsi_msg_to_host_byte(cmd, message); 407 + set_status_byte(cmd, status); 408 + return; 400 409 } 401 410 402 411 /* 403 - * Interrupt handler 412 + * Interrupt handler 404 413 */ 405 414 406 415 static void ql_ihandl(void *dev_id) ··· 436 415 return; 437 416 } 438 417 icmd = priv->qlcmd; 439 - icmd->result = ql_pcmd(icmd); 418 + ql_pcmd(icmd); 440 419 priv->qlcmd = NULL; 441 420 /* 442 - * If result is CHECK CONDITION done calls qcommand to request 443 - * sense 421 + * If result is CHECK CONDITION done calls qcommand to request 422 + * sense 444 423 */ 445 424 (icmd->scsi_done) (icmd); 446 425 } ··· 464 443 void (*done) (struct scsi_cmnd *)) 465 444 { 466 445 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); 446 + 447 + set_host_byte(cmd, DID_OK); 448 + set_status_byte(cmd, SAM_STAT_GOOD); 467 449 if (scmd_id(cmd) == priv->qinitid) { 468 - cmd->result = DID_BAD_TARGET << 16; 450 + set_host_byte(cmd, DID_BAD_TARGET); 469 451 done(cmd); 470 452 return 0; 471 453 } ··· 485 461 486 462 DEF_SCSI_QCMD(qlogicfas408_queuecommand) 487 463 488 - /* 489 - * Return bios parameters 464 + /* 465 + * Return bios parameters 490 466 */ 491 467 492 468 int qlogicfas408_biosparam(struct scsi_device *disk, struct block_device *dev, ··· 511 487 /* 512 488 * Abort a command in progress 513 489 */ 514 - 490 + 515 491 int qlogicfas408_abort(struct scsi_cmnd *cmd) 516 492 { 517 493 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); ··· 590 566 591 567 int qlogicfas408_detect(int qbase, int int_type) 592 568 { 593 - REG1; 569 + REG1; 594 570 return (((inb(qbase + 0xe) ^ inb(qbase + 0xe)) == 7) && 595 - ((inb(qbase + 0xe) ^ inb(qbase + 0xe)) == 7)); 571 + ((inb(qbase + 0xe) ^ inb(qbase + 0xe)) == 7)); 596 572 } 597 573 598 574 /*
+3 -8
drivers/scsi/scsi.c
··· 144 144 (level > 1)) { 145 145 scsi_print_result(cmd, "Done", disposition); 146 146 scsi_print_command(cmd); 147 - if (status_byte(cmd->result) == CHECK_CONDITION) 147 + if (scsi_status_is_check_condition(cmd->result)) 148 148 scsi_print_sense(cmd); 149 149 if (level > 3) 150 150 scmd_printk(KERN_INFO, cmd, ··· 184 184 atomic_set(&starget->target_blocked, 0); 185 185 if (atomic_read(&sdev->device_blocked)) 186 186 atomic_set(&sdev->device_blocked, 0); 187 - 188 - /* 189 - * If we have valid sense information, then some kind of recovery 190 - * must have taken place. Make a note of this. 191 - */ 192 - if (SCSI_SENSE_VALID(cmd)) 193 - cmd->result |= (DRIVER_SENSE << 24); 194 187 195 188 SCSI_LOG_MLCOMPLETE(4, sdev_printk(KERN_INFO, sdev, 196 189 "Notifying upper driver of completion " ··· 501 508 result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len, 502 509 &sshdr, 30 * HZ, 3, NULL); 503 510 511 + if (result < 0) 512 + return result; 504 513 if (result && scsi_sense_valid(&sshdr) && 505 514 sshdr.sense_key == ILLEGAL_REQUEST && 506 515 (sshdr.asc == 0x20 || sshdr.asc == 0x24) && sshdr.ascq == 0x00)
+6 -9
drivers/scsi/scsi_debug.c
··· 851 851 }; 852 852 853 853 static const int check_condition_result = 854 - (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; 854 + SAM_STAT_CHECK_CONDITION; 855 855 856 856 static const int illegal_condition_result = 857 - (DRIVER_SENSE << 24) | (DID_ABORT << 16) | SAM_STAT_CHECK_CONDITION; 857 + (DID_ABORT << 16) | SAM_STAT_CHECK_CONDITION; 858 858 859 859 static const int device_qfull_result = 860 860 (DID_OK << 16) | SAM_STAT_TASK_SET_FULL; ··· 931 931 } 932 932 asc = c_d ? INVALID_FIELD_IN_CDB : INVALID_FIELD_IN_PARAM_LIST; 933 933 memset(sbuff, 0, SCSI_SENSE_BUFFERSIZE); 934 - scsi_build_sense_buffer(sdebug_dsense, sbuff, ILLEGAL_REQUEST, asc, 0); 934 + scsi_build_sense(scp, sdebug_dsense, ILLEGAL_REQUEST, asc, 0); 935 935 memset(sks, 0, sizeof(sks)); 936 936 sks[0] = 0x80; 937 937 if (c_d) ··· 957 957 958 958 static void mk_sense_buffer(struct scsi_cmnd *scp, int key, int asc, int asq) 959 959 { 960 - unsigned char *sbuff; 961 - 962 - sbuff = scp->sense_buffer; 963 - if (!sbuff) { 960 + if (!scp->sense_buffer) { 964 961 sdev_printk(KERN_ERR, scp->device, 965 962 "%s: sense_buffer is NULL\n", __func__); 966 963 return; 967 964 } 968 - memset(sbuff, 0, SCSI_SENSE_BUFFERSIZE); 965 + memset(scp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); 969 966 970 - scsi_build_sense_buffer(sdebug_dsense, sbuff, key, asc, asq); 967 + scsi_build_sense(scp, sdebug_dsense, key, asc, asq); 971 968 972 969 if (sdebug_verbose) 973 970 sdev_printk(KERN_INFO, scp->device,
+28 -42
drivers/scsi/scsi_error.c
··· 742 742 return FAILED; 743 743 744 744 /* 745 - * next, check the message byte. 746 - */ 747 - if (msg_byte(scmd->result) != COMMAND_COMPLETE) 748 - return FAILED; 749 - 750 - /* 751 745 * now, check the status byte to see if this indicates 752 746 * anything special. 753 747 */ 754 - switch (status_byte(scmd->result)) { 755 - case GOOD: 748 + switch (get_status_byte(scmd)) { 749 + case SAM_STAT_GOOD: 756 750 scsi_handle_queue_ramp_up(scmd->device); 757 751 fallthrough; 758 - case COMMAND_TERMINATED: 752 + case SAM_STAT_COMMAND_TERMINATED: 759 753 return SUCCESS; 760 - case CHECK_CONDITION: 754 + case SAM_STAT_CHECK_CONDITION: 761 755 return scsi_check_sense(scmd); 762 - case CONDITION_GOOD: 763 - case INTERMEDIATE_GOOD: 764 - case INTERMEDIATE_C_GOOD: 756 + case SAM_STAT_CONDITION_MET: 757 + case SAM_STAT_INTERMEDIATE: 758 + case SAM_STAT_INTERMEDIATE_CONDITION_MET: 765 759 /* 766 760 * who knows? FIXME(eric) 767 761 */ 768 762 return SUCCESS; 769 - case RESERVATION_CONFLICT: 763 + case SAM_STAT_RESERVATION_CONFLICT: 770 764 if (scmd->cmnd[0] == TEST_UNIT_READY) 771 765 /* it is a success, we probed the device and 772 766 * found it */ 773 767 return SUCCESS; 774 768 /* otherwise, we failed to send the command */ 775 769 return FAILED; 776 - case QUEUE_FULL: 770 + case SAM_STAT_TASK_SET_FULL: 777 771 scsi_handle_queue_full(scmd->device); 778 772 fallthrough; 779 - case BUSY: 773 + case SAM_STAT_BUSY: 780 774 return NEEDS_RETRY; 781 775 default: 782 776 return FAILED; ··· 1252 1258 current->comm)); 1253 1259 break; 1254 1260 } 1255 - if (status_byte(scmd->result) != CHECK_CONDITION) 1261 + if (!scsi_status_is_check_condition(scmd->result)) 1256 1262 /* 1257 1263 * don't request sense if there's no check condition 1258 1264 * status because the error we're processing isn't one ··· 1760 1766 case DID_PARITY: 1761 1767 return (scmd->request->cmd_flags & REQ_FAILFAST_DEV); 1762 1768 case DID_ERROR: 1763 - if (msg_byte(scmd->result) == COMMAND_COMPLETE && 1764 - status_byte(scmd->result) == RESERVATION_CONFLICT) 1769 + if (get_status_byte(scmd) == SAM_STAT_RESERVATION_CONFLICT) 1765 1770 return 0; 1766 1771 fallthrough; 1767 1772 case DID_SOFT_ERROR: 1768 1773 return (scmd->request->cmd_flags & REQ_FAILFAST_DRIVER); 1769 1774 } 1770 1775 1771 - if (status_byte(scmd->result) != CHECK_CONDITION) 1776 + if (!scsi_status_is_check_condition(scmd->result)) 1772 1777 return 0; 1773 1778 1774 1779 check_type: ··· 1876 1883 */ 1877 1884 return SUCCESS; 1878 1885 case DID_ERROR: 1879 - if (msg_byte(scmd->result) == COMMAND_COMPLETE && 1880 - status_byte(scmd->result) == RESERVATION_CONFLICT) 1886 + if (get_status_byte(scmd) == SAM_STAT_RESERVATION_CONFLICT) 1881 1887 /* 1882 1888 * execute reservation conflict processing code 1883 1889 * lower down ··· 1905 1913 } 1906 1914 1907 1915 /* 1908 - * next, check the message byte. 1909 - */ 1910 - if (msg_byte(scmd->result) != COMMAND_COMPLETE) 1911 - return FAILED; 1912 - 1913 - /* 1914 1916 * check the status byte to see if this indicates anything special. 1915 1917 */ 1916 - switch (status_byte(scmd->result)) { 1917 - case QUEUE_FULL: 1918 + switch (get_status_byte(scmd)) { 1919 + case SAM_STAT_TASK_SET_FULL: 1918 1920 scsi_handle_queue_full(scmd->device); 1919 1921 /* 1920 1922 * the case of trying to send too many commands to a 1921 1923 * tagged queueing device. 1922 1924 */ 1923 1925 fallthrough; 1924 - case BUSY: 1926 + case SAM_STAT_BUSY: 1925 1927 /* 1926 1928 * device can't talk to us at the moment. Should only 1927 1929 * occur (SAM-3) when the task queue is empty, so will cause ··· 1923 1937 * device. 1924 1938 */ 1925 1939 return ADD_TO_MLQUEUE; 1926 - case GOOD: 1940 + case SAM_STAT_GOOD: 1927 1941 if (scmd->cmnd[0] == REPORT_LUNS) 1928 1942 scmd->device->sdev_target->expecting_lun_change = 0; 1929 1943 scsi_handle_queue_ramp_up(scmd->device); 1930 1944 fallthrough; 1931 - case COMMAND_TERMINATED: 1945 + case SAM_STAT_COMMAND_TERMINATED: 1932 1946 return SUCCESS; 1933 - case TASK_ABORTED: 1947 + case SAM_STAT_TASK_ABORTED: 1934 1948 goto maybe_retry; 1935 - case CHECK_CONDITION: 1949 + case SAM_STAT_CHECK_CONDITION: 1936 1950 rtn = scsi_check_sense(scmd); 1937 1951 if (rtn == NEEDS_RETRY) 1938 1952 goto maybe_retry; ··· 1941 1955 * to collect the sense and redo the decide 1942 1956 * disposition */ 1943 1957 return rtn; 1944 - case CONDITION_GOOD: 1945 - case INTERMEDIATE_GOOD: 1946 - case INTERMEDIATE_C_GOOD: 1947 - case ACA_ACTIVE: 1958 + case SAM_STAT_CONDITION_MET: 1959 + case SAM_STAT_INTERMEDIATE: 1960 + case SAM_STAT_INTERMEDIATE_CONDITION_MET: 1961 + case SAM_STAT_ACA_ACTIVE: 1948 1962 /* 1949 1963 * who knows? FIXME(eric) 1950 1964 */ 1951 1965 return SUCCESS; 1952 1966 1953 - case RESERVATION_CONFLICT: 1967 + case SAM_STAT_RESERVATION_CONFLICT: 1954 1968 sdev_printk(KERN_INFO, scmd->device, 1955 1969 "reservation conflict\n"); 1956 1970 set_host_byte(scmd, DID_NEXUS_FAILURE); ··· 2123 2137 /* 2124 2138 * If just we got sense for the device (called 2125 2139 * scsi_eh_get_sense), scmd->result is already 2126 - * set, do not set DRIVER_TIMEOUT. 2140 + * set, do not set DID_TIME_OUT. 2127 2141 */ 2128 2142 if (!scmd->result) 2129 - scmd->result |= (DRIVER_TIMEOUT << 24); 2143 + scmd->result |= (DID_TIME_OUT << 16); 2130 2144 SCSI_LOG_ERROR_RECOVERY(3, 2131 2145 scmd_printk(KERN_INFO, scmd, 2132 2146 "%s: flush finish cmd\n",
+4 -3
drivers/scsi/scsi_ioctl.c
··· 101 101 SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev, 102 102 "Ioctl returned 0x%x\n", result)); 103 103 104 - if (driver_byte(result) == DRIVER_SENSE && 105 - scsi_sense_valid(&sshdr)) { 104 + if (result < 0) 105 + goto out; 106 + if (scsi_sense_valid(&sshdr)) { 106 107 switch (sshdr.sense_key) { 107 108 case ILLEGAL_REQUEST: 108 109 if (cmd[0] == ALLOW_MEDIUM_REMOVAL) ··· 134 133 break; 135 134 } 136 135 } 137 - 136 + out: 138 137 SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev, 139 138 "IOCTL Releasing command\n")); 140 139 return result;
+66 -51
drivers/scsi/scsi_lib.c
··· 211 211 { 212 212 struct request *req; 213 213 struct scsi_request *rq; 214 - int ret = DRIVER_ERROR << 24; 214 + int ret; 215 215 216 216 req = blk_get_request(sdev->request_queue, 217 217 data_direction == DMA_TO_DEVICE ? 218 218 REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, 219 219 rq_flags & RQF_PM ? BLK_MQ_REQ_PM : 0); 220 220 if (IS_ERR(req)) 221 - return ret; 221 + return PTR_ERR(req); 222 + 222 223 rq = scsi_req(req); 223 224 224 - if (bufflen && blk_rq_map_kern(sdev->request_queue, req, 225 - buffer, bufflen, GFP_NOIO)) 226 - goto out; 227 - 225 + if (bufflen) { 226 + ret = blk_rq_map_kern(sdev->request_queue, req, 227 + buffer, bufflen, GFP_NOIO); 228 + if (ret) 229 + goto out; 230 + } 228 231 rq->cmd_len = COMMAND_SIZE(cmd[0]); 229 232 memcpy(rq->cmd, cmd, rq->cmd_len); 230 233 rq->retries = retries; ··· 591 588 { 592 589 switch (host_byte(result)) { 593 590 case DID_OK: 594 - /* 595 - * Also check the other bytes than the status byte in result 596 - * to handle the case when a SCSI LLD sets result to 597 - * DRIVER_SENSE << 24 without setting SAM_STAT_CHECK_CONDITION. 598 - */ 599 - if (scsi_status_is_good(result) && (result & ~0xff) == 0) 591 + if (scsi_status_is_good(result)) 600 592 return BLK_STS_OK; 601 593 return BLK_STS_IOERR; 602 594 case DID_TRANSPORT_FAILFAST: ··· 785 787 */ 786 788 if (!level && __ratelimit(&_rs)) { 787 789 scsi_print_result(cmd, NULL, FAILED); 788 - if (driver_byte(result) == DRIVER_SENSE) 790 + if (sense_valid) 789 791 scsi_print_sense(cmd); 790 792 scsi_print_command(cmd); 791 793 } ··· 873 875 * if it can't fit). Treat SAM_STAT_CONDITION_MET and the related 874 876 * intermediate statuses (both obsolete in SAM-4) as good. 875 877 */ 876 - if (status_byte(result) && scsi_status_is_good(result)) { 878 + if ((result & 0xff) && scsi_status_is_good(result)) { 877 879 result = 0; 878 880 *blk_statp = BLK_STS_OK; 879 881 } ··· 2091 2093 * @sshdr: place to put sense data (or NULL if no sense to be collected). 2092 2094 * must be SCSI_SENSE_BUFFERSIZE big. 2093 2095 * 2094 - * Returns zero if unsuccessful, or the header offset (either 4 2095 - * or 8 depending on whether a six or ten byte command was 2096 - * issued) if successful. 2096 + * Returns zero if successful, or a negative error number on failure 2097 2097 */ 2098 2098 int 2099 2099 scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, ··· 2138 2142 2139 2143 result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len, 2140 2144 sshdr, timeout, retries, NULL); 2145 + if (result < 0) 2146 + return result; 2141 2147 2142 2148 /* This code looks awful: what it's doing is making sure an 2143 2149 * ILLEGAL REQUEST sense return identifies the actual command 2144 2150 * byte as the problem. MODE_SENSE commands can return 2145 2151 * ILLEGAL REQUEST if the code page isn't supported */ 2146 2152 2147 - if (use_10_for_ms && !scsi_status_is_good(result) && 2148 - driver_byte(result) == DRIVER_SENSE) { 2153 + if (!scsi_status_is_good(result)) { 2149 2154 if (scsi_sense_valid(sshdr)) { 2150 2155 if ((sshdr->sense_key == ILLEGAL_REQUEST) && 2151 2156 (sshdr->asc == 0x20) && (sshdr->ascq == 0)) { 2152 2157 /* 2153 2158 * Invalid command operation code 2154 2159 */ 2155 - sdev->use_10_for_ms = 0; 2160 + if (use_10_for_ms) { 2161 + sdev->use_10_for_ms = 0; 2162 + goto retry; 2163 + } 2164 + } 2165 + if (scsi_status_is_check_condition(result) && 2166 + sshdr->sense_key == UNIT_ATTENTION && 2167 + retry_count) { 2168 + retry_count--; 2156 2169 goto retry; 2157 2170 } 2158 2171 } 2172 + return -EIO; 2159 2173 } 2160 - 2161 - if (scsi_status_is_good(result)) { 2162 - if (unlikely(buffer[0] == 0x86 && buffer[1] == 0x0b && 2163 - (modepage == 6 || modepage == 8))) { 2164 - /* Initio breakage? */ 2165 - header_length = 0; 2166 - data->length = 13; 2167 - data->medium_type = 0; 2168 - data->device_specific = 0; 2169 - data->longlba = 0; 2170 - data->block_descriptor_length = 0; 2171 - } else if (use_10_for_ms) { 2172 - data->length = buffer[0]*256 + buffer[1] + 2; 2173 - data->medium_type = buffer[2]; 2174 - data->device_specific = buffer[3]; 2175 - data->longlba = buffer[4] & 0x01; 2176 - data->block_descriptor_length = buffer[6]*256 2177 - + buffer[7]; 2178 - } else { 2179 - data->length = buffer[0] + 1; 2180 - data->medium_type = buffer[1]; 2181 - data->device_specific = buffer[2]; 2182 - data->block_descriptor_length = buffer[3]; 2183 - } 2184 - data->header_length = header_length; 2185 - } else if ((status_byte(result) == CHECK_CONDITION) && 2186 - scsi_sense_valid(sshdr) && 2187 - sshdr->sense_key == UNIT_ATTENTION && retry_count) { 2188 - retry_count--; 2189 - goto retry; 2174 + if (unlikely(buffer[0] == 0x86 && buffer[1] == 0x0b && 2175 + (modepage == 6 || modepage == 8))) { 2176 + /* Initio breakage? */ 2177 + header_length = 0; 2178 + data->length = 13; 2179 + data->medium_type = 0; 2180 + data->device_specific = 0; 2181 + data->longlba = 0; 2182 + data->block_descriptor_length = 0; 2183 + } else if (use_10_for_ms) { 2184 + data->length = buffer[0]*256 + buffer[1] + 2; 2185 + data->medium_type = buffer[2]; 2186 + data->device_specific = buffer[3]; 2187 + data->longlba = buffer[4] & 0x01; 2188 + data->block_descriptor_length = buffer[6]*256 2189 + + buffer[7]; 2190 + } else { 2191 + data->length = buffer[0] + 1; 2192 + data->medium_type = buffer[1]; 2193 + data->device_specific = buffer[2]; 2194 + data->block_descriptor_length = buffer[3]; 2190 2195 } 2196 + data->header_length = header_length; 2191 2197 2192 - return result; 2198 + return 0; 2193 2199 } 2194 2200 EXPORT_SYMBOL(scsi_mode_sense); 2195 2201 ··· 3216 3218 return group_id; 3217 3219 } 3218 3220 EXPORT_SYMBOL(scsi_vpd_tpg_id); 3221 + 3222 + /** 3223 + * scsi_build_sense - build sense data for a command 3224 + * @scmd: scsi command for which the sense should be formatted 3225 + * @desc: Sense format (non-zero == descriptor format, 3226 + * 0 == fixed format) 3227 + * @key: Sense key 3228 + * @asc: Additional sense code 3229 + * @ascq: Additional sense code qualifier 3230 + * 3231 + **/ 3232 + void scsi_build_sense(struct scsi_cmnd *scmd, int desc, u8 key, u8 asc, u8 ascq) 3233 + { 3234 + scsi_build_sense_buffer(desc, scmd->sense_buffer, key, asc, ascq); 3235 + scmd->result = SAM_STAT_CHECK_CONDITION; 3236 + } 3237 + EXPORT_SYMBOL_GPL(scsi_build_sense);
+2 -8
drivers/scsi/scsi_logging.c
··· 385 385 size_t off, logbuf_len; 386 386 const char *mlret_string = scsi_mlreturn_string(disposition); 387 387 const char *hb_string = scsi_hostbyte_string(cmd->result); 388 - const char *db_string = scsi_driverbyte_string(cmd->result); 389 388 unsigned long cmd_age = (jiffies - cmd->jiffies_at_alloc) / HZ; 390 389 391 390 logbuf = scsi_log_reserve_buffer(&logbuf_len); ··· 425 426 if (WARN_ON(off >= logbuf_len)) 426 427 goto out_printk; 427 428 428 - if (db_string) 429 - off += scnprintf(logbuf + off, logbuf_len - off, 430 - "driverbyte=%s ", db_string); 431 - else 432 - off += scnprintf(logbuf + off, logbuf_len - off, 433 - "driverbyte=0x%02x ", 434 - driver_byte(cmd->result)); 429 + off += scnprintf(logbuf + off, logbuf_len - off, 430 + "driverbyte=DRIVER_OK "); 435 431 436 432 off += scnprintf(logbuf + off, logbuf_len - off, 437 433 "cmd_age=%lus", cmd_age);
+3 -3
drivers/scsi/scsi_scan.c
··· 616 616 "scsi scan: INQUIRY %s with code 0x%x\n", 617 617 result ? "failed" : "successful", result)); 618 618 619 - if (result) { 619 + if (result > 0) { 620 620 /* 621 621 * not-ready to ready transition [asc/ascq=0x28/0x0] 622 622 * or power-on, reset [asc/ascq=0x29/0x0], continue. 623 623 * INQUIRY should not yield UNIT_ATTENTION 624 624 * but many buggy devices do so anyway. 625 625 */ 626 - if (driver_byte(result) == DRIVER_SENSE && 626 + if (scsi_status_is_check_condition(result) && 627 627 scsi_sense_valid(&sshdr)) { 628 628 if ((sshdr.sense_key == UNIT_ATTENTION) && 629 629 ((sshdr.asc == 0x28) || ··· 631 631 (sshdr.ascq == 0)) 632 632 continue; 633 633 } 634 - } else { 634 + } else if (result == 0) { 635 635 /* 636 636 * if nothing was transferred, we try 637 637 * again. It's a workaround for some USB
+4 -5
drivers/scsi/scsi_transport_sas.c
··· 1229 1229 char *buffer = kzalloc(BUF_SIZE, GFP_KERNEL), *msdata; 1230 1230 struct sas_end_device *rdev = sas_sdev_to_rdev(sdev); 1231 1231 struct scsi_mode_data mode_data; 1232 - int res, error; 1232 + int error; 1233 1233 1234 1234 if (!buffer) 1235 1235 return -ENOMEM; 1236 1236 1237 - res = scsi_mode_sense(sdev, 1, 0x19, buffer, BUF_SIZE, 30*HZ, 3, 1238 - &mode_data, NULL); 1237 + error = scsi_mode_sense(sdev, 1, 0x19, buffer, BUF_SIZE, 30*HZ, 3, 1238 + &mode_data, NULL); 1239 1239 1240 - error = -EINVAL; 1241 - if (!scsi_status_is_good(res)) 1240 + if (error) 1242 1241 goto out; 1243 1242 1244 1243 msdata = buffer + mode_data.header_length +
+1 -1
drivers/scsi/scsi_transport_spi.c
··· 127 127 REQ_FAILFAST_TRANSPORT | 128 128 REQ_FAILFAST_DRIVER, 129 129 RQF_PM, NULL); 130 - if (driver_byte(result) != DRIVER_SENSE || 130 + if (result < 0 || !scsi_sense_valid(sshdr) || 131 131 sshdr->sense_key != UNIT_ATTENTION) 132 132 break; 133 133 }
+33 -30
drivers/scsi/sd.c
··· 1658 1658 &sshdr); 1659 1659 1660 1660 /* failed to execute TUR, assume media not present */ 1661 - if (host_byte(retval)) { 1661 + if (retval < 0 || host_byte(retval)) { 1662 1662 set_media_not_present(sdkp); 1663 1663 goto out; 1664 1664 } ··· 1719 1719 if (res) { 1720 1720 sd_print_result(sdkp, "Synchronize Cache(10) failed", res); 1721 1721 1722 - if (driver_byte(res) == DRIVER_SENSE) 1722 + if (res < 0) 1723 + return res; 1724 + 1725 + if (scsi_status_is_check_condition(res) && 1726 + scsi_sense_valid(sshdr)) { 1723 1727 sd_print_sense_hdr(sdkp, sshdr); 1724 1728 1725 - /* we need to evaluate the error return */ 1726 - if (scsi_sense_valid(sshdr) && 1727 - (sshdr->asc == 0x3a || /* medium not present */ 1728 - sshdr->asc == 0x20 || /* invalid command */ 1729 - (sshdr->asc == 0x74 && sshdr->ascq == 0x71))) /* drive is password locked */ 1729 + /* we need to evaluate the error return */ 1730 + if (sshdr->asc == 0x3a || /* medium not present */ 1731 + sshdr->asc == 0x20 || /* invalid command */ 1732 + (sshdr->asc == 0x74 && sshdr->ascq == 0x71)) /* drive is password locked */ 1730 1733 /* this is no error here */ 1731 1734 return 0; 1735 + } 1732 1736 1733 1737 switch (host_byte(res)) { 1734 1738 /* ignore errors due to racing a disconnection */ ··· 1829 1825 result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, &data, sizeof(data), 1830 1826 &sshdr, SD_TIMEOUT, sdkp->max_retries, NULL); 1831 1827 1832 - if (driver_byte(result) == DRIVER_SENSE && 1828 + if (scsi_status_is_check_condition(result) && 1833 1829 scsi_sense_valid(&sshdr)) { 1834 1830 sdev_printk(KERN_INFO, sdev, "PR command failed: %d\n", result); 1835 1831 scsi_print_sense_hdr(sdev, NULL, &sshdr); ··· 2073 2069 } 2074 2070 sdkp->medium_access_timed_out = 0; 2075 2071 2076 - if (driver_byte(result) != DRIVER_SENSE && 2072 + if (!scsi_status_is_check_condition(result) && 2077 2073 (!sense_valid || sense_deferred)) 2078 2074 goto out; 2079 2075 ··· 2176 2172 if (the_result) 2177 2173 sense_valid = scsi_sense_valid(&sshdr); 2178 2174 retries++; 2179 - } while (retries < 3 && 2175 + } while (retries < 3 && 2180 2176 (!scsi_status_is_good(the_result) || 2181 - ((driver_byte(the_result) == DRIVER_SENSE) && 2177 + (scsi_status_is_check_condition(the_result) && 2182 2178 sense_valid && sshdr.sense_key == UNIT_ATTENTION))); 2183 2179 2184 - if (driver_byte(the_result) != DRIVER_SENSE) { 2180 + if (!scsi_status_is_check_condition(the_result)) { 2185 2181 /* no sense, TUR either succeeded or failed 2186 2182 * with a status error */ 2187 2183 if(!spintime && !scsi_status_is_good(the_result)) { ··· 2309 2305 struct scsi_sense_hdr *sshdr, int sense_valid, 2310 2306 int the_result) 2311 2307 { 2312 - if (driver_byte(the_result) == DRIVER_SENSE) 2308 + if (sense_valid) 2313 2309 sd_print_sense_hdr(sdkp, sshdr); 2314 2310 else 2315 2311 sd_printk(KERN_NOTICE, sdkp, "Sense not available.\n"); ··· 2366 2362 if (media_not_present(sdkp, &sshdr)) 2367 2363 return -ENODEV; 2368 2364 2369 - if (the_result) { 2365 + if (the_result > 0) { 2370 2366 sense_valid = scsi_sense_valid(&sshdr); 2371 2367 if (sense_valid && 2372 2368 sshdr.sense_key == ILLEGAL_REQUEST && ··· 2451 2447 if (media_not_present(sdkp, &sshdr)) 2452 2448 return -ENODEV; 2453 2449 2454 - if (the_result) { 2450 + if (the_result > 0) { 2455 2451 sense_valid = scsi_sense_valid(&sshdr); 2456 2452 if (sense_valid && 2457 2453 sshdr.sense_key == UNIT_ATTENTION && ··· 2674 2670 * 5: Illegal Request, Sense Code 24: Invalid field in 2675 2671 * CDB. 2676 2672 */ 2677 - if (!scsi_status_is_good(res)) 2673 + if (res < 0) 2678 2674 res = sd_do_mode_sense(sdkp, 0, 0, buffer, 4, &data, NULL); 2679 2675 2680 2676 /* 2681 2677 * Third attempt: ask 255 bytes, as we did earlier. 2682 2678 */ 2683 - if (!scsi_status_is_good(res)) 2679 + if (res < 0) 2684 2680 res = sd_do_mode_sense(sdkp, 0, 0x3F, buffer, 255, 2685 2681 &data, NULL); 2686 2682 } 2687 2683 2688 - if (!scsi_status_is_good(res)) { 2684 + if (res < 0) { 2689 2685 sd_first_printk(KERN_WARNING, sdkp, 2690 2686 "Test WP failed, assume Write Enabled\n"); 2691 2687 } else { ··· 2746 2742 res = sd_do_mode_sense(sdkp, dbd, modepage, buffer, first_len, 2747 2743 &data, &sshdr); 2748 2744 2749 - if (!scsi_status_is_good(res)) 2745 + if (res < 0) 2750 2746 goto bad_sense; 2751 2747 2752 2748 if (!data.header_length) { ··· 2778 2774 res = sd_do_mode_sense(sdkp, dbd, modepage, buffer, len, 2779 2775 &data, &sshdr); 2780 2776 2781 - if (scsi_status_is_good(res)) { 2777 + if (!res) { 2782 2778 int offset = data.header_length + data.block_descriptor_length; 2783 2779 2784 2780 while (offset < len) { ··· 2896 2892 res = scsi_mode_sense(sdp, 1, 0x0a, buffer, 36, SD_TIMEOUT, 2897 2893 sdkp->max_retries, &data, &sshdr); 2898 2894 2899 - if (!scsi_status_is_good(res) || !data.header_length || 2895 + if (res < 0 || !data.header_length || 2900 2896 data.length < 6) { 2901 2897 sd_first_printk(KERN_WARNING, sdkp, 2902 2898 "getting Control mode page failed, assume no ATO\n"); ··· 3595 3591 SD_TIMEOUT, sdkp->max_retries, 0, RQF_PM, NULL); 3596 3592 if (res) { 3597 3593 sd_print_result(sdkp, "Start/Stop Unit failed", res); 3598 - if (driver_byte(res) == DRIVER_SENSE) 3594 + if (res > 0 && scsi_sense_valid(&sshdr)) { 3599 3595 sd_print_sense_hdr(sdkp, &sshdr); 3600 - if (scsi_sense_valid(&sshdr) && 3601 3596 /* 0x3a is medium not present */ 3602 - sshdr.asc == 0x3a) 3603 - res = 0; 3597 + if (sshdr.asc == 0x3a) 3598 + res = 0; 3599 + } 3604 3600 } 3605 3601 3606 3602 /* SCSI error codes must not go to the generic layer */ ··· 3810 3806 void sd_print_result(const struct scsi_disk *sdkp, const char *msg, int result) 3811 3807 { 3812 3808 const char *hb_string = scsi_hostbyte_string(result); 3813 - const char *db_string = scsi_driverbyte_string(result); 3814 3809 3815 - if (hb_string || db_string) 3810 + if (hb_string) 3816 3811 sd_printk(KERN_INFO, sdkp, 3817 3812 "%s: Result: hostbyte=%s driverbyte=%s\n", msg, 3818 3813 hb_string ? hb_string : "invalid", 3819 - db_string ? db_string : "invalid"); 3814 + "DRIVER_OK"); 3820 3815 else 3821 3816 sd_printk(KERN_INFO, sdkp, 3822 - "%s: Result: hostbyte=0x%02x driverbyte=0x%02x\n", 3823 - msg, host_byte(result), driver_byte(result)); 3817 + "%s: Result: hostbyte=0x%02x driverbyte=%s\n", 3818 + msg, host_byte(result), "DRIVER_OK"); 3824 3819 }
+1 -2
drivers/scsi/sd_zbc.c
··· 116 116 sd_printk(KERN_ERR, sdkp, 117 117 "REPORT ZONES start lba %llu failed\n", lba); 118 118 sd_print_result(sdkp, "REPORT ZONES", result); 119 - if (driver_byte(result) == DRIVER_SENSE && 120 - scsi_sense_valid(&sshdr)) 119 + if (result > 0 && scsi_sense_valid(&sshdr)) 121 120 sd_print_sense_hdr(sdkp, &sshdr); 122 121 return -EIO; 123 122 }
+6 -3
drivers/scsi/sg.c
··· 498 498 old_hdr->host_status = hp->host_status; 499 499 old_hdr->driver_status = hp->driver_status; 500 500 if ((CHECK_CONDITION & hp->masked_status) || 501 - (DRIVER_SENSE & hp->driver_status)) 501 + (srp->sense_b[0] & 0x70) == 0x70) { 502 + old_hdr->driver_status = DRIVER_SENSE; 502 503 memcpy(old_hdr->sense_buffer, srp->sense_b, 503 504 sizeof (old_hdr->sense_buffer)); 505 + } 504 506 switch (hp->host_status) { 505 507 /* This setup of 'result' is for backward compatibility and is best 506 508 ignored by the user who should use target, host + driver status */ ··· 576 574 hp->sb_len_wr = 0; 577 575 if ((hp->mx_sb_len > 0) && hp->sbp) { 578 576 if ((CHECK_CONDITION & hp->masked_status) || 579 - (DRIVER_SENSE & hp->driver_status)) { 577 + (srp->sense_b[0] & 0x70) == 0x70) { 580 578 int sb_len = SCSI_SENSE_BUFFERSIZE; 581 579 sb_len = (hp->mx_sb_len > sb_len) ? sb_len : hp->mx_sb_len; 582 580 len = 8 + (int) srp->sense_b[7]; /* Additional sense length field */ ··· 585 583 err = -EFAULT; 586 584 goto err_out; 587 585 } 586 + hp->driver_status = DRIVER_SENSE; 588 587 hp->sb_len_wr = len; 589 588 } 590 589 } ··· 1376 1373 1377 1374 srp->header.status = 0xff & result; 1378 1375 srp->header.masked_status = status_byte(result); 1379 - srp->header.msg_status = msg_byte(result); 1376 + srp->header.msg_status = COMMAND_COMPLETE; 1380 1377 srp->header.host_status = host_byte(result); 1381 1378 srp->header.driver_status = driver_byte(result); 1382 1379 if ((sdp->sgdebug > 0) &&
+1 -2
drivers/scsi/smartpqi/smartpqi_init.c
··· 3087 3087 } 3088 3088 3089 3089 if (device_offline && sense_data_length == 0) 3090 - scsi_build_sense_buffer(0, scmd->sense_buffer, HARDWARE_ERROR, 3091 - 0x3e, 0x1); 3090 + scsi_build_sense(scmd, 0, HARDWARE_ERROR, 0x3e, 0x1); 3092 3091 3093 3092 scmd->result = scsi_status; 3094 3093 set_host_byte(scmd, host_byte);
+2 -2
drivers/scsi/sr.c
··· 338 338 * care is taken to avoid unnecessary additional work such as 339 339 * memcpy's that could be avoided. 340 340 */ 341 - if (driver_byte(result) != 0 && /* An error occurred */ 341 + if (scsi_status_is_check_condition(result) && 342 342 (SCpnt->sense_buffer[0] & 0x7f) == 0x70) { /* Sense current */ 343 343 switch (SCpnt->sense_buffer[2]) { 344 344 case MEDIUM_ERROR: ··· 911 911 rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, ms_len, 912 912 SR_TIMEOUT, 3, &data, NULL); 913 913 914 - if (!scsi_status_is_good(rc) || data.length > ms_len || 914 + if (rc < 0 || data.length > ms_len || 915 915 data.header_length + data.block_descriptor_length > data.length) { 916 916 /* failed, drive doesn't have capabilities mode page */ 917 917 cd->cdi.speed = 1;
+5 -1
drivers/scsi/sr_ioctl.c
··· 201 201 cgc->timeout, IOCTL_RETRIES, 0, 0, NULL); 202 202 203 203 /* Minimal error checking. Ignore cases we know about, and report the rest. */ 204 - if (driver_byte(result) != 0) { 204 + if (result < 0) { 205 + err = result; 206 + goto out; 207 + } 208 + if (scsi_status_is_check_condition(result)) { 205 209 switch (sshdr->sense_key) { 206 210 case UNIT_ATTENTION: 207 211 SDev->changed = 1;
+4 -4
drivers/scsi/st.c
··· 390 390 if (!debugging) { /* Abnormal conditions for tape */ 391 391 if (!cmdstatp->have_sense) 392 392 st_printk(KERN_WARNING, STp, 393 - "Error %x (driver bt 0x%x, host bt 0x%x).\n", 394 - result, driver_byte(result), host_byte(result)); 393 + "Error %x (driver bt 0, host bt 0x%x).\n", 394 + result, host_byte(result)); 395 395 else if (cmdstatp->have_sense && 396 396 scode != NO_SENSE && 397 397 scode != RECOVERED_ERROR && ··· 551 551 data_direction == DMA_TO_DEVICE ? 552 552 REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, 0); 553 553 if (IS_ERR(req)) 554 - return DRIVER_ERROR << 24; 554 + return PTR_ERR(req); 555 555 rq = scsi_req(req); 556 556 req->rq_flags |= RQF_QUIET; 557 557 ··· 562 562 GFP_KERNEL); 563 563 if (err) { 564 564 blk_put_request(req); 565 - return DRIVER_ERROR << 24; 565 + return err; 566 566 } 567 567 } 568 568
+3 -6
drivers/scsi/stex.c
··· 398 398 static void stex_invalid_field(struct scsi_cmnd *cmd, 399 399 void (*done)(struct scsi_cmnd *)) 400 400 { 401 - cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; 402 - 403 401 /* "Invalid field in cdb" */ 404 - scsi_build_sense_buffer(0, cmd->sense_buffer, ILLEGAL_REQUEST, 0x24, 405 - 0x0); 402 + scsi_build_sense(cmd, 0, ILLEGAL_REQUEST, 0x24, 0x0); 406 403 done(cmd); 407 404 } 408 405 ··· 737 740 result |= DID_OK << 16; 738 741 break; 739 742 case SAM_STAT_CHECK_CONDITION: 740 - result |= DRIVER_SENSE << 24; 743 + result |= DID_OK << 16; 741 744 break; 742 745 case SAM_STAT_BUSY: 743 746 result |= DID_BUS_BUSY << 16; ··· 748 751 } 749 752 } 750 753 else if (ccb->srb_status & SRB_SEE_SENSE) 751 - result = DRIVER_SENSE << 24 | SAM_STAT_CHECK_CONDITION; 754 + result = SAM_STAT_CHECK_CONDITION; 752 755 else switch (ccb->srb_status) { 753 756 case SRB_STATUS_SELECTION_TIMEOUT: 754 757 result = DID_NO_CONNECT << 16;
+2 -4
drivers/scsi/sym53c8xx_2/sym_glue.c
··· 170 170 void sym_set_cam_result_error(struct sym_hcb *np, struct sym_ccb *cp, int resid) 171 171 { 172 172 struct scsi_cmnd *cmd = cp->cmd; 173 - u_int cam_status, scsi_status, drv_status; 173 + u_int cam_status, scsi_status; 174 174 175 - drv_status = 0; 176 175 cam_status = DID_OK; 177 176 scsi_status = cp->ssss_status; 178 177 ··· 185 186 cp->xerr_status == 0) { 186 187 cam_status = sym_xerr_cam_status(DID_OK, 187 188 cp->sv_xerr_status); 188 - drv_status = DRIVER_SENSE; 189 189 /* 190 190 * Bounce back the sense data to user. 191 191 */ ··· 233 235 cam_status = sym_xerr_cam_status(DID_ERROR, cp->xerr_status); 234 236 } 235 237 scsi_set_resid(cmd, resid); 236 - cmd->result = (drv_status << 24) | (cam_status << 16) | scsi_status; 238 + cmd->result = (cam_status << 16) | scsi_status; 237 239 } 238 240 239 241 static int sym_scatter(struct sym_hcb *np, struct sym_ccb *cp, struct scsi_cmnd *cmd)
+1 -1
drivers/scsi/ufs/ufshcd.c
··· 8605 8605 sdev_printk(KERN_WARNING, sdp, 8606 8606 "START_STOP failed for power mode: %d, result %x\n", 8607 8607 pwr_mode, ret); 8608 - if (driver_byte(ret) == DRIVER_SENSE) 8608 + if (ret > 0 && scsi_sense_valid(&sshdr)) 8609 8609 scsi_print_sense_hdr(sdp, NULL, &sshdr); 8610 8610 } 8611 8611
+2 -3
drivers/scsi/virtio_scsi.c
··· 161 161 min_t(u32, 162 162 virtio32_to_cpu(vscsi->vdev, resp->sense_len), 163 163 VIRTIO_SCSI_SENSE_SIZE)); 164 - if (resp->sense_len) 165 - set_driver_byte(sc, DRIVER_SENSE); 164 + set_status_byte(sc, SAM_STAT_CHECK_CONDITION); 166 165 } 167 166 168 167 sc->scsi_done(sc); ··· 354 355 if (result == 0 && inq_result[0] >> 5) { 355 356 /* PQ indicates the LUN is not attached */ 356 357 scsi_remove_device(sdev); 357 - } else if (host_byte(result) == DID_BAD_TARGET) { 358 + } else if (result > 0 && host_byte(result) == DID_BAD_TARGET) { 358 359 /* 359 360 * If all LUNs of a virtio-scsi device are unplugged 360 361 * it will respond with BAD TARGET on any INQUIRY
-6
drivers/scsi/vmw_pvscsi.c
··· 576 576 cmd->result = (DID_RESET << 16); 577 577 } else { 578 578 cmd->result = (DID_OK << 16) | sdstat; 579 - if (sdstat == SAM_STAT_CHECK_CONDITION && 580 - cmd->sense_buffer) 581 - cmd->result |= (DRIVER_SENSE << 24); 582 579 } 583 580 } else 584 581 switch (btstat) { ··· 601 604 case BTSTAT_LUNMISMATCH: 602 605 case BTSTAT_TAGREJECT: 603 606 case BTSTAT_BADMSG: 604 - cmd->result = (DRIVER_INVALID << 24); 605 - fallthrough; 606 - 607 607 case BTSTAT_HAHARDWARE: 608 608 case BTSTAT_INVPHASE: 609 609 case BTSTAT_HATIMEOUT:
+23 -20
drivers/scsi/wd33c93.c
··· 1176 1176 if (cmd->SCp.Status == ILLEGAL_STATUS_BYTE) 1177 1177 cmd->SCp.Status = lun; 1178 1178 if (cmd->cmnd[0] == REQUEST_SENSE 1179 - && cmd->SCp.Status != SAM_STAT_GOOD) 1180 - cmd->result = 1181 - (cmd-> 1182 - result & 0x00ffff) | (DID_ERROR << 16); 1183 - else 1184 - cmd->result = 1185 - cmd->SCp.Status | (cmd->SCp.Message << 8); 1179 + && cmd->SCp.Status != SAM_STAT_GOOD) { 1180 + set_host_byte(cmd, DID_ERROR); 1181 + } else { 1182 + set_host_byte(cmd, DID_OK); 1183 + scsi_msg_to_host_byte(cmd, cmd->SCp.Message); 1184 + set_status_byte(cmd, cmd->SCp.Status); 1185 + } 1186 1186 cmd->scsi_done(cmd); 1187 1187 1188 1188 /* We are no longer connected to a target - check to see if ··· 1262 1262 hostdata->connected = NULL; 1263 1263 hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff)); 1264 1264 hostdata->state = S_UNCONNECTED; 1265 - if (cmd->cmnd[0] == REQUEST_SENSE && cmd->SCp.Status != SAM_STAT_GOOD) 1266 - cmd->result = 1267 - (cmd->result & 0x00ffff) | (DID_ERROR << 16); 1268 - else 1269 - cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8); 1265 + if (cmd->cmnd[0] == REQUEST_SENSE && 1266 + cmd->SCp.Status != SAM_STAT_GOOD) { 1267 + set_host_byte(cmd, DID_ERROR); 1268 + } else { 1269 + set_host_byte(cmd, DID_OK); 1270 + scsi_msg_to_host_byte(cmd, cmd->SCp.Message); 1271 + set_status_byte(cmd, cmd->SCp.Status); 1272 + } 1270 1273 cmd->scsi_done(cmd); 1271 1274 1272 1275 /* We are no longer connected to a target - check to see if ··· 1298 1295 hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff)); 1299 1296 hostdata->state = S_UNCONNECTED; 1300 1297 DB(DB_INTR, printk(":%d", cmd->SCp.Status)) 1301 - if (cmd->cmnd[0] == REQUEST_SENSE 1302 - && cmd->SCp.Status != SAM_STAT_GOOD) 1303 - cmd->result = 1304 - (cmd-> 1305 - result & 0x00ffff) | (DID_ERROR << 16); 1306 - else 1307 - cmd->result = 1308 - cmd->SCp.Status | (cmd->SCp.Message << 8); 1298 + if (cmd->cmnd[0] == REQUEST_SENSE 1299 + && cmd->SCp.Status != SAM_STAT_GOOD) { 1300 + set_host_byte(cmd, DID_ERROR); 1301 + } else { 1302 + set_host_byte(cmd, DID_OK); 1303 + scsi_msg_to_host_byte(cmd, cmd->SCp.Message); 1304 + set_status_byte(cmd, cmd->SCp.Status); 1305 + } 1309 1306 cmd->scsi_done(cmd); 1310 1307 break; 1311 1308 case S_PRE_TMP_DISC:
+7 -1
drivers/scsi/xen-scsifront.c
··· 251 251 struct scsi_cmnd *sc; 252 252 uint32_t id; 253 253 uint8_t sense_len; 254 + int result; 254 255 255 256 id = ring_rsp->rqid; 256 257 shadow = info->shadow[id]; ··· 262 261 scsifront_gnttab_done(info, shadow); 263 262 scsifront_put_rqid(info, id); 264 263 265 - sc->result = ring_rsp->rslt; 264 + result = ring_rsp->rslt; 265 + if (result >> 24) 266 + set_host_byte(sc, DID_ERROR); 267 + else 268 + set_host_byte(sc, host_byte(result)); 269 + set_status_byte(sc, result & 0xff); 266 270 scsi_set_resid(sc, ring_rsp->residual_len); 267 271 268 272 sense_len = min_t(uint8_t, VSCSIIF_SENSE_BUFFERSIZE,
-1
drivers/target/loopback/tcm_loop.c
··· 566 566 memcpy(sc->sense_buffer, se_cmd->sense_buffer, 567 567 SCSI_SENSE_BUFFERSIZE); 568 568 sc->result = SAM_STAT_CHECK_CONDITION; 569 - set_driver_byte(sc, DRIVER_SENSE); 570 569 } else 571 570 sc->result = scsi_status; 572 571
+3 -3
drivers/target/target_core_alua.c
··· 123 123 124 124 transport_kunmap_data_sg(cmd); 125 125 126 - target_complete_cmd(cmd, GOOD); 126 + target_complete_cmd(cmd, SAM_STAT_GOOD); 127 127 return 0; 128 128 } 129 129 ··· 255 255 } 256 256 transport_kunmap_data_sg(cmd); 257 257 258 - target_complete_cmd_with_length(cmd, GOOD, rd_len + 4); 258 + target_complete_cmd_with_length(cmd, SAM_STAT_GOOD, rd_len + 4); 259 259 return 0; 260 260 } 261 261 ··· 424 424 out: 425 425 transport_kunmap_data_sg(cmd); 426 426 if (!rc) 427 - target_complete_cmd(cmd, GOOD); 427 + target_complete_cmd(cmd, SAM_STAT_GOOD); 428 428 return rc; 429 429 } 430 430
+1 -1
drivers/target/target_core_iblock.c
··· 474 474 if (ret) 475 475 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 476 476 477 - target_complete_cmd(cmd, GOOD); 477 + target_complete_cmd(cmd, SAM_STAT_GOOD); 478 478 return 0; 479 479 } 480 480
+4 -4
drivers/target/target_core_pr.c
··· 234 234 out_unlock: 235 235 spin_unlock(&dev->dev_reservation_lock); 236 236 out: 237 - target_complete_cmd(cmd, GOOD); 237 + target_complete_cmd(cmd, SAM_STAT_GOOD); 238 238 return 0; 239 239 } 240 240 ··· 297 297 spin_unlock(&dev->dev_reservation_lock); 298 298 out: 299 299 if (!ret) 300 - target_complete_cmd(cmd, GOOD); 300 + target_complete_cmd(cmd, SAM_STAT_GOOD); 301 301 return ret; 302 302 } 303 303 ··· 3676 3676 } 3677 3677 3678 3678 if (!ret) 3679 - target_complete_cmd(cmd, GOOD); 3679 + target_complete_cmd(cmd, SAM_STAT_GOOD); 3680 3680 return ret; 3681 3681 } 3682 3682 ··· 4073 4073 } 4074 4074 4075 4075 if (!ret) 4076 - target_complete_cmd(cmd, GOOD); 4076 + target_complete_cmd(cmd, SAM_STAT_GOOD); 4077 4077 return ret; 4078 4078 } 4079 4079
+1 -1
drivers/target/target_core_pscsi.c
··· 1044 1044 struct se_cmd *cmd = req->end_io_data; 1045 1045 struct pscsi_plugin_task *pt = cmd->priv; 1046 1046 int result = scsi_req(req)->result; 1047 - u8 scsi_status = status_byte(result) << 1; 1047 + u8 scsi_status = result & 0xff; 1048 1048 1049 1049 if (scsi_status != SAM_STAT_GOOD) { 1050 1050 pr_debug("PSCSI Status Byte exception at cmd: %p CDB:"
+5 -5
drivers/target/target_core_sbc.c
··· 67 67 transport_kunmap_data_sg(cmd); 68 68 } 69 69 70 - target_complete_cmd_with_length(cmd, GOOD, 8); 70 + target_complete_cmd_with_length(cmd, SAM_STAT_GOOD, 8); 71 71 return 0; 72 72 } 73 73 ··· 130 130 transport_kunmap_data_sg(cmd); 131 131 } 132 132 133 - target_complete_cmd_with_length(cmd, GOOD, 32); 133 + target_complete_cmd_with_length(cmd, SAM_STAT_GOOD, 32); 134 134 return 0; 135 135 } 136 136 ··· 202 202 return ret; 203 203 } 204 204 205 - target_complete_cmd(cmd, GOOD); 205 + target_complete_cmd(cmd, SAM_STAT_GOOD); 206 206 return 0; 207 207 } 208 208 209 209 static sense_reason_t 210 210 sbc_emulate_noop(struct se_cmd *cmd) 211 211 { 212 - target_complete_cmd(cmd, GOOD); 212 + target_complete_cmd(cmd, SAM_STAT_GOOD); 213 213 return 0; 214 214 } 215 215 ··· 1245 1245 err: 1246 1246 transport_kunmap_data_sg(cmd); 1247 1247 if (!ret) 1248 - target_complete_cmd(cmd, GOOD); 1248 + target_complete_cmd(cmd, SAM_STAT_GOOD); 1249 1249 return ret; 1250 1250 } 1251 1251
+7 -7
drivers/target/target_core_spc.c
··· 781 781 kfree(buf); 782 782 783 783 if (!ret) 784 - target_complete_cmd_with_length(cmd, GOOD, len); 784 + target_complete_cmd_with_length(cmd, SAM_STAT_GOOD, len); 785 785 return ret; 786 786 } 787 787 ··· 1135 1135 transport_kunmap_data_sg(cmd); 1136 1136 } 1137 1137 1138 - target_complete_cmd_with_length(cmd, GOOD, length); 1138 + target_complete_cmd_with_length(cmd, SAM_STAT_GOOD, length); 1139 1139 return 0; 1140 1140 } 1141 1141 ··· 1153 1153 int i; 1154 1154 1155 1155 if (!cmd->data_length) { 1156 - target_complete_cmd(cmd, GOOD); 1156 + target_complete_cmd(cmd, SAM_STAT_GOOD); 1157 1157 return 0; 1158 1158 } 1159 1159 ··· 1196 1196 transport_kunmap_data_sg(cmd); 1197 1197 1198 1198 if (!ret) 1199 - target_complete_cmd(cmd, GOOD); 1199 + target_complete_cmd(cmd, SAM_STAT_GOOD); 1200 1200 return ret; 1201 1201 } 1202 1202 ··· 1229 1229 memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length)); 1230 1230 transport_kunmap_data_sg(cmd); 1231 1231 1232 - target_complete_cmd(cmd, GOOD); 1232 + target_complete_cmd(cmd, SAM_STAT_GOOD); 1233 1233 return 0; 1234 1234 } 1235 1235 ··· 1296 1296 transport_kunmap_data_sg(cmd); 1297 1297 } 1298 1298 1299 - target_complete_cmd_with_length(cmd, GOOD, 8 + lun_count * 8); 1299 + target_complete_cmd_with_length(cmd, SAM_STAT_GOOD, 8 + lun_count * 8); 1300 1300 return 0; 1301 1301 } 1302 1302 EXPORT_SYMBOL(spc_emulate_report_luns); ··· 1304 1304 static sense_reason_t 1305 1305 spc_emulate_testunitready(struct se_cmd *cmd) 1306 1306 { 1307 - target_complete_cmd(cmd, GOOD); 1307 + target_complete_cmd(cmd, SAM_STAT_GOOD); 1308 1308 return 0; 1309 1309 } 1310 1310
+1 -1
drivers/target/target_core_xcopy.c
··· 998 998 put_unaligned_be32(42, &p[0]); 999 999 1000 1000 transport_kunmap_data_sg(se_cmd); 1001 - target_complete_cmd(se_cmd, GOOD); 1001 + target_complete_cmd(se_cmd, SAM_STAT_GOOD); 1002 1002 1003 1003 return TCM_NO_SENSE; 1004 1004 }
+2 -2
drivers/usb/storage/cypress_atacb.c
··· 221 221 desc[12] = regs[6]; /* device */ 222 222 desc[13] = regs[7]; /* command */ 223 223 224 - srb->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; 224 + srb->result = SAM_STAT_CHECK_CONDITION; 225 225 } 226 226 goto end; 227 227 invalid_fld: 228 - srb->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; 228 + srb->result = SAM_STAT_CHECK_CONDITION; 229 229 230 230 memcpy(srb->sense_buffer, 231 231 usb_stor_sense_invalidCDB,
+8 -9
drivers/xen/xen-scsiback.c
··· 222 222 { 223 223 struct scsiback_tpg *tpg = pending_req->v2p->tpg; 224 224 225 - pr_err("[%s:%d] cmnd[0]=%02x -> st=%02x msg=%02x host=%02x drv=%02x\n", 225 + pr_err("[%s:%d] cmnd[0]=%02x -> st=%02x msg=%02x host=%02x\n", 226 226 tpg->tport->tport_name, pending_req->v2p->lun, 227 - pending_req->cmnd[0], status_byte(errors), msg_byte(errors), 228 - host_byte(errors), driver_byte(errors)); 227 + pending_req->cmnd[0], errors & 0xff, COMMAND_COMPLETE, 228 + host_byte(errors)); 229 229 } 230 230 231 231 static void scsiback_fast_flush_area(struct vscsibk_pend *req) ··· 719 719 result = DID_NO_CONNECT; 720 720 break; 721 721 default: 722 - result = DRIVER_ERROR; 722 + result = DID_ERROR; 723 723 break; 724 724 } 725 - scsiback_send_response(info, NULL, result << 24, 0, 725 + scsiback_send_response(info, NULL, result << 16, 0, 726 726 ring_req.rqid); 727 727 return 1; 728 728 } ··· 732 732 if (scsiback_gnttab_data_map(&ring_req, pending_req)) { 733 733 scsiback_fast_flush_area(pending_req); 734 734 scsiback_do_resp_with_sense(NULL, 735 - DRIVER_ERROR << 24, 0, pending_req); 735 + DID_ERROR << 16, 0, pending_req); 736 736 transport_generic_free_cmd(&pending_req->se_cmd, 0); 737 737 } else { 738 738 scsiback_cmd_exec(pending_req); ··· 747 747 break; 748 748 default: 749 749 pr_err_ratelimited("invalid request\n"); 750 - scsiback_do_resp_with_sense(NULL, DRIVER_ERROR << 24, 0, 750 + scsiback_do_resp_with_sense(NULL, DID_ERROR << 16, 0, 751 751 pending_req); 752 752 transport_generic_free_cmd(&pending_req->se_cmd, 0); 753 753 break; ··· 1401 1401 if (se_cmd->sense_buffer && 1402 1402 ((se_cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) || 1403 1403 (se_cmd->se_cmd_flags & SCF_EMULATED_TASK_SENSE))) 1404 - pending_req->result = (DRIVER_SENSE << 24) | 1405 - SAM_STAT_CHECK_CONDITION; 1404 + pending_req->result = SAM_STAT_CHECK_CONDITION; 1406 1405 else 1407 1406 pending_req->result = se_cmd->scsi_status; 1408 1407
+21 -21
include/scsi/scsi.h
··· 62 62 return (lun & 0xff00) == SCSI_W_LUN_BASE; 63 63 } 64 64 65 + /** 66 + * scsi_status_is_check_condition - check the status return. 67 + * 68 + * @status: the status passed up from the driver (including host and 69 + * driver components) 70 + * 71 + * This returns true if the status code is SAM_STAT_CHECK_CONDITION. 72 + */ 73 + static inline int scsi_status_is_check_condition(int status) 74 + { 75 + if (status < 0) 76 + return false; 77 + status &= 0xfe; 78 + return status == SAM_STAT_CHECK_CONDITION; 79 + } 65 80 66 81 /* 67 82 * MESSAGE CODES ··· 153 138 #define DRIVER_OK 0x00 /* Driver status */ 154 139 155 140 /* 156 - * These indicate the error that occurred, and what is available. 157 - */ 158 - 159 - #define DRIVER_BUSY 0x01 160 - #define DRIVER_SOFT 0x02 161 - #define DRIVER_MEDIA 0x03 162 - #define DRIVER_ERROR 0x04 163 - 164 - #define DRIVER_INVALID 0x05 165 - #define DRIVER_TIMEOUT 0x06 166 - #define DRIVER_HARD 0x07 167 - #define DRIVER_SENSE 0x08 168 - 169 - /* 170 141 * Internal return values. 171 142 */ 172 143 enum scsi_disposition { ··· 181 180 * These are set by: 182 181 * 183 182 * status byte = set from target device 184 - * msg_byte = return status from host adapter itself. 183 + * msg_byte (unused) 185 184 * host_byte = set by low-level driver to indicate status. 186 - * driver_byte = set by mid-level. 187 185 */ 188 - #define status_byte(result) (((result) >> 1) & 0x7f) 189 - #define msg_byte(result) (((result) >> 8) & 0xff) 190 186 #define host_byte(result) (((result) >> 16) & 0xff) 191 - #define driver_byte(result) (((result) >> 24) & 0xff) 192 187 193 188 #define sense_class(sense) (((sense) >> 4) & 0x7) 194 189 #define sense_error(sense) ((sense) & 0xf) ··· 256 259 * This returns true for known good conditions that may be treated as 257 260 * command completed normally 258 261 */ 259 - static inline int scsi_status_is_good(int status) 262 + static inline bool scsi_status_is_good(int status) 260 263 { 264 + if (status < 0) 265 + return false; 266 + 261 267 if (host_byte(status) == DID_NO_CONNECT) 262 - return 0; 268 + return false; 263 269 264 270 /* 265 271 * FIXME: bit0 is listed as reserved in SCSI-2, but is
+34 -4
include/scsi/scsi_cmnd.h
··· 315 315 cmd->result = (cmd->result & 0xffffff00) | status; 316 316 } 317 317 318 - static inline void set_msg_byte(struct scsi_cmnd *cmd, char status) 318 + static inline u8 get_status_byte(struct scsi_cmnd *cmd) 319 319 { 320 - cmd->result = (cmd->result & 0xffff00ff) | (status << 8); 320 + return cmd->result & 0xff; 321 321 } 322 322 323 323 static inline void set_host_byte(struct scsi_cmnd *cmd, char status) ··· 325 325 cmd->result = (cmd->result & 0xff00ffff) | (status << 16); 326 326 } 327 327 328 - static inline void set_driver_byte(struct scsi_cmnd *cmd, char status) 328 + static inline u8 get_host_byte(struct scsi_cmnd *cmd) 329 329 { 330 - cmd->result = (cmd->result & 0x00ffffff) | (status << 24); 330 + return (cmd->result >> 16) & 0xff; 331 + } 332 + 333 + /** 334 + * scsi_msg_to_host_byte() - translate message byte 335 + * 336 + * Translate the SCSI parallel message byte to a matching 337 + * host byte setting. A message of COMMAND_COMPLETE indicates 338 + * a successful command execution, any other message indicate 339 + * an error. As the messages themselves only have a meaning 340 + * for the SCSI parallel protocol this function translates 341 + * them into a matching host byte value for SCSI EH. 342 + */ 343 + static inline void scsi_msg_to_host_byte(struct scsi_cmnd *cmd, u8 msg) 344 + { 345 + switch (msg) { 346 + case COMMAND_COMPLETE: 347 + break; 348 + case ABORT_TASK_SET: 349 + set_host_byte(cmd, DID_ABORT); 350 + break; 351 + case TARGET_RESET: 352 + set_host_byte(cmd, DID_RESET); 353 + break; 354 + default: 355 + set_host_byte(cmd, DID_ERROR); 356 + break; 357 + } 331 358 } 332 359 333 360 static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd) ··· 367 340 368 341 return xfer_len; 369 342 } 343 + 344 + extern void scsi_build_sense(struct scsi_cmnd *scmd, int desc, 345 + u8 key, u8 asc, u8 ascq); 370 346 371 347 #endif /* _SCSI_SCSI_CMND_H */
+1 -21
include/scsi/scsi_proto.h
··· 202 202 #define SAM_STAT_ACA_ACTIVE 0x30 203 203 #define SAM_STAT_TASK_ABORTED 0x40 204 204 205 - /* 206 - * Status codes. These are deprecated as they are shifted 1 bit right 207 - * from those found in the SCSI standards. This causes confusion for 208 - * applications that are ported to several OSes. Prefer SAM Status codes 209 - * above. 210 - */ 211 - 212 - #define GOOD 0x00 213 - #define CHECK_CONDITION 0x01 214 - #define CONDITION_GOOD 0x02 215 - #define BUSY 0x04 216 - #define INTERMEDIATE_GOOD 0x08 217 - #define INTERMEDIATE_C_GOOD 0x0a 218 - #define RESERVATION_CONFLICT 0x0c 219 - #define COMMAND_TERMINATED 0x11 220 - #define QUEUE_FULL 0x14 221 - #define ACA_ACTIVE 0x18 222 - #define TASK_ABORTED 0x20 223 - 224 - #define STATUS_MASK 0xfe 225 - 205 + #define STATUS_MASK 0xfe 226 206 /* 227 207 * SENSE KEYS 228 208 */
+33
include/scsi/sg.h
··· 131 131 #define SG_INFO_DIRECT_IO 0x2 /* direct IO requested and performed */ 132 132 #define SG_INFO_MIXED_IO 0x4 /* part direct, part indirect IO */ 133 133 134 + /* 135 + * Obsolete DRIVER_SENSE driver byte 136 + * 137 + * Originally the SCSI midlayer would set the DRIVER_SENSE driver byte when 138 + * a sense code was generated and a sense buffer was allocated. 139 + * However, as nowadays every scsi command has a sense code allocated this 140 + * distinction became moot as one could check the sense buffer directly. 141 + * Consequently this byte is not set anymore from the midlayer, but SG will 142 + * keep setting this byte to be compatible with previous releases. 143 + */ 144 + #define DRIVER_SENSE 0x08 145 + /* Obsolete driver_byte() declaration */ 146 + #define driver_byte(result) (((result) >> 24) & 0xff) 147 + 148 + /* 149 + * Original linux SCSI Status codes. They are shifted 1 bit right 150 + * from those found in the SCSI standards. 151 + */ 152 + 153 + #define GOOD 0x00 154 + #define CHECK_CONDITION 0x01 155 + #define CONDITION_GOOD 0x02 156 + #define BUSY 0x04 157 + #define INTERMEDIATE_GOOD 0x08 158 + #define INTERMEDIATE_C_GOOD 0x0a 159 + #define RESERVATION_CONFLICT 0x0c 160 + #define COMMAND_TERMINATED 0x11 161 + #define QUEUE_FULL 0x14 162 + #define ACA_ACTIVE 0x18 163 + #define TASK_ABORTED 0x20 164 + 165 + /* Obsolete status_byte() declaration */ 166 + #define status_byte(result) (((result) >> 1) & 0x7f) 134 167 135 168 typedef struct sg_scsi_id { /* used by SG_GET_SCSI_ID ioctl() */ 136 169 int host_no; /* as in "scsi<n>" where 'n' is one of 0, 1, 2 etc */
+2 -46
include/trace/events/scsi.h
··· 124 124 scsi_hostbyte_name(DID_TRANSPORT_DISRUPTED), \ 125 125 scsi_hostbyte_name(DID_TRANSPORT_FAILFAST)) 126 126 127 - #define scsi_driverbyte_name(result) { result, #result } 128 - #define show_driverbyte_name(val) \ 129 - __print_symbolic(val, \ 130 - scsi_driverbyte_name(DRIVER_OK), \ 131 - scsi_driverbyte_name(DRIVER_BUSY), \ 132 - scsi_driverbyte_name(DRIVER_SOFT), \ 133 - scsi_driverbyte_name(DRIVER_MEDIA), \ 134 - scsi_driverbyte_name(DRIVER_ERROR), \ 135 - scsi_driverbyte_name(DRIVER_INVALID), \ 136 - scsi_driverbyte_name(DRIVER_TIMEOUT), \ 137 - scsi_driverbyte_name(DRIVER_HARD), \ 138 - scsi_driverbyte_name(DRIVER_SENSE)) 139 - 140 - #define scsi_msgbyte_name(result) { result, #result } 141 - #define show_msgbyte_name(val) \ 142 - __print_symbolic(val, \ 143 - scsi_msgbyte_name(COMMAND_COMPLETE), \ 144 - scsi_msgbyte_name(EXTENDED_MESSAGE), \ 145 - scsi_msgbyte_name(SAVE_POINTERS), \ 146 - scsi_msgbyte_name(RESTORE_POINTERS), \ 147 - scsi_msgbyte_name(DISCONNECT), \ 148 - scsi_msgbyte_name(INITIATOR_ERROR), \ 149 - scsi_msgbyte_name(ABORT_TASK_SET), \ 150 - scsi_msgbyte_name(MESSAGE_REJECT), \ 151 - scsi_msgbyte_name(NOP), \ 152 - scsi_msgbyte_name(MSG_PARITY_ERROR), \ 153 - scsi_msgbyte_name(LINKED_CMD_COMPLETE), \ 154 - scsi_msgbyte_name(LINKED_FLG_CMD_COMPLETE), \ 155 - scsi_msgbyte_name(TARGET_RESET), \ 156 - scsi_msgbyte_name(ABORT_TASK), \ 157 - scsi_msgbyte_name(CLEAR_TASK_SET), \ 158 - scsi_msgbyte_name(INITIATE_RECOVERY), \ 159 - scsi_msgbyte_name(RELEASE_RECOVERY), \ 160 - scsi_msgbyte_name(CLEAR_ACA), \ 161 - scsi_msgbyte_name(LOGICAL_UNIT_RESET), \ 162 - scsi_msgbyte_name(SIMPLE_QUEUE_TAG), \ 163 - scsi_msgbyte_name(HEAD_OF_QUEUE_TAG), \ 164 - scsi_msgbyte_name(ORDERED_QUEUE_TAG), \ 165 - scsi_msgbyte_name(IGNORE_WIDE_RESIDUE), \ 166 - scsi_msgbyte_name(ACA), \ 167 - scsi_msgbyte_name(QAS_REQUEST), \ 168 - scsi_msgbyte_name(BUS_DEVICE_RESET), \ 169 - scsi_msgbyte_name(ABORT)) 170 - 171 127 #define scsi_statusbyte_name(result) { result, #result } 172 128 #define show_statusbyte_name(val) \ 173 129 __print_symbolic(val, \ ··· 283 327 show_opcode_name(__entry->opcode), 284 328 __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len), 285 329 __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len), 286 - show_driverbyte_name(((__entry->result) >> 24) & 0xff), 330 + "DRIVER_OK", 287 331 show_hostbyte_name(((__entry->result) >> 16) & 0xff), 288 - show_msgbyte_name(((__entry->result) >> 8) & 0xff), 332 + "COMMAND_COMPLETE", 289 333 show_statusbyte_name(__entry->result & 0xff)) 290 334 ); 291 335