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

scsi: NCR5380: Have NCR5380_select() return a bool

The return value is taken to mean "retry" or "don't retry". Change it to bool
to improve readability. Fix related comments. No functional change.

Tested-by: Michael Schmitz <schmitzmic@gmail.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Finn Thain and committed by
Martin K. Petersen
dad8261e 6a162836

+22 -26
+21 -25
drivers/scsi/NCR5380.c
··· 902 902 return IRQ_RETVAL(handled); 903 903 } 904 904 905 - /* 906 - * Function : int NCR5380_select(struct Scsi_Host *instance, 907 - * struct scsi_cmnd *cmd) 905 + /** 906 + * NCR5380_select - attempt arbitration and selection for a given command 907 + * @instance: the Scsi_Host instance 908 + * @cmd: the scsi_cmnd to execute 908 909 * 909 - * Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command, 910 - * including ARBITRATION, SELECTION, and initial message out for 911 - * IDENTIFY and queue messages. 910 + * This routine establishes an I_T_L nexus for a SCSI command. This involves 911 + * ARBITRATION, SELECTION and MESSAGE OUT phases and an IDENTIFY message. 912 912 * 913 - * Inputs : instance - instantiation of the 5380 driver on which this 914 - * target lives, cmd - SCSI command to execute. 915 - * 916 - * Returns cmd if selection failed but should be retried, 917 - * NULL if selection failed and should not be retried, or 918 - * NULL if selection succeeded (hostdata->connected == cmd). 913 + * Returns true if the operation should be retried. 914 + * Returns false if it should not be retried. 919 915 * 920 916 * Side effects : 921 917 * If bus busy, arbitration failed, etc, NCR5380_select() will exit ··· 919 923 * SELECT_ENABLE will be set appropriately, the NCR5380 920 924 * will cease to drive any SCSI bus signals. 921 925 * 922 - * If successful : I_T_L or I_T_L_Q nexus will be established, 923 - * instance->connected will be set to cmd. 926 + * If successful : the I_T_L nexus will be established, and 927 + * hostdata->connected will be set to cmd. 924 928 * SELECT interrupt will be disabled. 925 929 * 926 930 * If failed (no target) : cmd->scsi_done() will be called, and the 927 931 * cmd->result host byte set to DID_BAD_TARGET. 928 932 */ 929 933 930 - static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance, 931 - struct scsi_cmnd *cmd) 934 + static bool NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd) 932 935 __releases(&hostdata->lock) __acquires(&hostdata->lock) 933 936 { 934 937 struct NCR5380_hostdata *hostdata = shost_priv(instance); ··· 935 940 unsigned char *data; 936 941 int len; 937 942 int err; 943 + bool ret = true; 938 944 939 945 NCR5380_dprint(NDEBUG_ARBITRATION, instance); 940 946 dsprintk(NDEBUG_ARBITRATION, instance, "starting arbitration, id = %d\n", ··· 944 948 /* 945 949 * Arbitration and selection phases are slow and involve dropping the 946 950 * lock, so we have to watch out for EH. An exception handler may 947 - * change 'selecting' to NULL. This function will then return NULL 951 + * change 'selecting' to NULL. This function will then return false 948 952 * so that the caller will forget about 'cmd'. (During information 949 953 * transfer phases, EH may change 'connected' to NULL.) 950 954 */ ··· 980 984 if (!hostdata->selecting) { 981 985 /* Command was aborted */ 982 986 NCR5380_write(MODE_REG, MR_BASE); 983 - return NULL; 987 + return false; 984 988 } 985 989 if (err < 0) { 986 990 NCR5380_write(MODE_REG, MR_BASE); ··· 1029 1033 if (!hostdata->selecting) { 1030 1034 NCR5380_write(MODE_REG, MR_BASE); 1031 1035 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); 1032 - return NULL; 1036 + return false; 1033 1037 } 1034 1038 1035 1039 dsprintk(NDEBUG_ARBITRATION, instance, "won arbitration\n"); ··· 1115 1119 1116 1120 /* Can't touch cmd if it has been reclaimed by the scsi ML */ 1117 1121 if (!hostdata->selecting) 1118 - return NULL; 1122 + return false; 1119 1123 1120 1124 cmd->result = DID_BAD_TARGET << 16; 1121 1125 complete_cmd(instance, cmd); 1122 1126 dsprintk(NDEBUG_SELECTION, instance, 1123 1127 "target did not respond within 250ms\n"); 1124 - cmd = NULL; 1128 + ret = false; 1125 1129 goto out; 1126 1130 } 1127 1131 ··· 1154 1158 } 1155 1159 if (!hostdata->selecting) { 1156 1160 do_abort(instance); 1157 - return NULL; 1161 + return false; 1158 1162 } 1159 1163 1160 1164 dsprintk(NDEBUG_SELECTION, instance, "target %d selected, going into MESSAGE OUT phase.\n", ··· 1170 1174 cmd->result = DID_ERROR << 16; 1171 1175 complete_cmd(instance, cmd); 1172 1176 dsprintk(NDEBUG_SELECTION, instance, "IDENTIFY message transfer failed\n"); 1173 - cmd = NULL; 1177 + ret = false; 1174 1178 goto out; 1175 1179 } 1176 1180 ··· 1185 1189 1186 1190 initialize_SCp(cmd); 1187 1191 1188 - cmd = NULL; 1192 + ret = false; 1189 1193 1190 1194 out: 1191 1195 if (!hostdata->selecting) 1192 1196 return NULL; 1193 1197 hostdata->selecting = NULL; 1194 - return cmd; 1198 + return ret; 1195 1199 } 1196 1200 1197 1201 /*
+1 -1
drivers/scsi/NCR5380.h
··· 275 275 static void NCR5380_main(struct work_struct *work); 276 276 static const char *NCR5380_info(struct Scsi_Host *instance); 277 277 static void NCR5380_reselect(struct Scsi_Host *instance); 278 - static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *, struct scsi_cmnd *); 278 + static bool NCR5380_select(struct Scsi_Host *, struct scsi_cmnd *); 279 279 static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data); 280 280 static int NCR5380_transfer_pio(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data); 281 281 static int NCR5380_poll_politely2(struct NCR5380_hostdata *,