diff options
| author | Tejun Heo <htejun@gmail.com> | 2006-12-16 20:45:08 -0500 |
|---|---|---|
| committer | Jeff Garzik <jeff@garzik.org> | 2006-12-20 14:26:26 -0500 |
| commit | 542b1444c5639e5964f9aa99e1cb231381d8a7a4 (patch) | |
| tree | 6cdc8ed951a8581f1e0ab0cedba9d5abe89e407f | |
| parent | 6fbf5ba461f5bd36e921627568aca20abc0e2abe (diff) | |
[PATCH] libata: clean up variable name usage in xlat related functions
Variable names in xlat functions are quite confusing now. 'scsicmd'
is used for CDB while qc->scsicmd points to struct scsi_cmnd while
'cmd' is used for struct scsi_cmnd.
This patch cleans up variable names in xlat functions such that 'scmd'
is used for struct scsi_cmnd and 'cdb' for CDB. Also, 'scmd' local
variable is added if qc->scsicmd is used multiple times.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
| -rw-r--r-- | drivers/ata/libata-scsi.c | 217 |
1 files changed, 105 insertions, 112 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index a4790be41d1c..1e42cde05f43 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
| @@ -51,7 +51,7 @@ | |||
| 51 | 51 | ||
| 52 | #define SECTOR_SIZE 512 | 52 | #define SECTOR_SIZE 512 |
| 53 | 53 | ||
| 54 | typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *scsicmd); | 54 | typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *cdb); |
| 55 | 55 | ||
| 56 | static struct ata_device * __ata_scsi_find_dev(struct ata_port *ap, | 56 | static struct ata_device * __ata_scsi_find_dev(struct ata_port *ap, |
| 57 | const struct scsi_device *scsidev); | 57 | const struct scsi_device *scsidev); |
| @@ -935,7 +935,7 @@ int ata_scsi_change_queue_depth(struct scsi_device *sdev, int queue_depth) | |||
| 935 | /** | 935 | /** |
| 936 | * ata_scsi_start_stop_xlat - Translate SCSI START STOP UNIT command | 936 | * ata_scsi_start_stop_xlat - Translate SCSI START STOP UNIT command |
| 937 | * @qc: Storage for translated ATA taskfile | 937 | * @qc: Storage for translated ATA taskfile |
| 938 | * @scsicmd: SCSI command to translate | 938 | * @cdb: SCSI command to translate |
| 939 | * | 939 | * |
| 940 | * Sets up an ATA taskfile to issue STANDBY (to stop) or READ VERIFY | 940 | * Sets up an ATA taskfile to issue STANDBY (to stop) or READ VERIFY |
| 941 | * (to start). Perhaps these commands should be preceded by | 941 | * (to start). Perhaps these commands should be preceded by |
| @@ -948,22 +948,22 @@ int ata_scsi_change_queue_depth(struct scsi_device *sdev, int queue_depth) | |||
| 948 | * RETURNS: | 948 | * RETURNS: |
| 949 | * Zero on success, non-zero on error. | 949 | * Zero on success, non-zero on error. |
| 950 | */ | 950 | */ |
| 951 | |||
| 952 | static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc, | 951 | static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc, |
| 953 | const u8 *scsicmd) | 952 | const u8 *cdb) |
| 954 | { | 953 | { |
| 954 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
| 955 | struct ata_taskfile *tf = &qc->tf; | 955 | struct ata_taskfile *tf = &qc->tf; |
| 956 | 956 | ||
| 957 | tf->flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR; | 957 | tf->flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR; |
| 958 | tf->protocol = ATA_PROT_NODATA; | 958 | tf->protocol = ATA_PROT_NODATA; |
| 959 | if (scsicmd[1] & 0x1) { | 959 | if (cdb[1] & 0x1) { |
| 960 | ; /* ignore IMMED bit, violates sat-r05 */ | 960 | ; /* ignore IMMED bit, violates sat-r05 */ |
| 961 | } | 961 | } |
| 962 | if (scsicmd[4] & 0x2) | 962 | if (cdb[4] & 0x2) |
| 963 | goto invalid_fld; /* LOEJ bit set not supported */ | 963 | goto invalid_fld; /* LOEJ bit set not supported */ |
| 964 | if (((scsicmd[4] >> 4) & 0xf) != 0) | 964 | if (((cdb[4] >> 4) & 0xf) != 0) |
| 965 | goto invalid_fld; /* power conditions not supported */ | 965 | goto invalid_fld; /* power conditions not supported */ |
| 966 | if (scsicmd[4] & 0x1) { | 966 | if (cdb[4] & 0x1) { |
| 967 | tf->nsect = 1; /* 1 sector, lba=0 */ | 967 | tf->nsect = 1; /* 1 sector, lba=0 */ |
| 968 | 968 | ||
| 969 | if (qc->dev->flags & ATA_DFLAG_LBA) { | 969 | if (qc->dev->flags & ATA_DFLAG_LBA) { |
| @@ -996,7 +996,7 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc, | |||
| 996 | return 0; | 996 | return 0; |
| 997 | 997 | ||
| 998 | invalid_fld: | 998 | invalid_fld: |
| 999 | ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x24, 0x0); | 999 | ata_scsi_set_sense(scmd, ILLEGAL_REQUEST, 0x24, 0x0); |
| 1000 | /* "Invalid field in cbd" */ | 1000 | /* "Invalid field in cbd" */ |
| 1001 | return 1; | 1001 | return 1; |
| 1002 | } | 1002 | } |
| @@ -1005,7 +1005,7 @@ invalid_fld: | |||
| 1005 | /** | 1005 | /** |
| 1006 | * ata_scsi_flush_xlat - Translate SCSI SYNCHRONIZE CACHE command | 1006 | * ata_scsi_flush_xlat - Translate SCSI SYNCHRONIZE CACHE command |
| 1007 | * @qc: Storage for translated ATA taskfile | 1007 | * @qc: Storage for translated ATA taskfile |
| 1008 | * @scsicmd: SCSI command to translate (ignored) | 1008 | * @cdb: SCSI command to translate (ignored) |
| 1009 | * | 1009 | * |
| 1010 | * Sets up an ATA taskfile to issue FLUSH CACHE or | 1010 | * Sets up an ATA taskfile to issue FLUSH CACHE or |
| 1011 | * FLUSH CACHE EXT. | 1011 | * FLUSH CACHE EXT. |
| @@ -1016,8 +1016,7 @@ invalid_fld: | |||
| 1016 | * RETURNS: | 1016 | * RETURNS: |
| 1017 | * Zero on success, non-zero on error. | 1017 | * Zero on success, non-zero on error. |
| 1018 | */ | 1018 | */ |
| 1019 | 1019 | static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc, const u8 *cdb) | |
| 1020 | static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd) | ||
| 1021 | { | 1020 | { |
| 1022 | struct ata_taskfile *tf = &qc->tf; | 1021 | struct ata_taskfile *tf = &qc->tf; |
| 1023 | 1022 | ||
| @@ -1034,7 +1033,7 @@ static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc, const u8 *scs | |||
| 1034 | 1033 | ||
| 1035 | /** | 1034 | /** |
| 1036 | * scsi_6_lba_len - Get LBA and transfer length | 1035 | * scsi_6_lba_len - Get LBA and transfer length |
| 1037 | * @scsicmd: SCSI command to translate | 1036 | * @cdb: SCSI command to translate |
| 1038 | * | 1037 | * |
| 1039 | * Calculate LBA and transfer length for 6-byte commands. | 1038 | * Calculate LBA and transfer length for 6-byte commands. |
| 1040 | * | 1039 | * |
| @@ -1042,18 +1041,17 @@ static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc, const u8 *scs | |||
| 1042 | * @plba: the LBA | 1041 | * @plba: the LBA |
| 1043 | * @plen: the transfer length | 1042 | * @plen: the transfer length |
| 1044 | */ | 1043 | */ |
| 1045 | 1044 | static void scsi_6_lba_len(const u8 *cdb, u64 *plba, u32 *plen) | |
| 1046 | static void scsi_6_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen) | ||
| 1047 | { | 1045 | { |
| 1048 | u64 lba = 0; | 1046 | u64 lba = 0; |
| 1049 | u32 len = 0; | 1047 | u32 len = 0; |
| 1050 | 1048 | ||
| 1051 | VPRINTK("six-byte command\n"); | 1049 | VPRINTK("six-byte command\n"); |
| 1052 | 1050 | ||
| 1053 | lba |= ((u64)scsicmd[2]) << 8; | 1051 | lba |= ((u64)cdb[2]) << 8; |
| 1054 | lba |= ((u64)scsicmd[3]); | 1052 | lba |= ((u64)cdb[3]); |
| 1055 | 1053 | ||
| 1056 | len |= ((u32)scsicmd[4]); | 1054 | len |= ((u32)cdb[4]); |
| 1057 | 1055 | ||
| 1058 | *plba = lba; | 1056 | *plba = lba; |
| 1059 | *plen = len; | 1057 | *plen = len; |
| @@ -1061,7 +1059,7 @@ static void scsi_6_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen) | |||
| 1061 | 1059 | ||
| 1062 | /** | 1060 | /** |
| 1063 | * scsi_10_lba_len - Get LBA and transfer length | 1061 | * scsi_10_lba_len - Get LBA and transfer length |
| 1064 | * @scsicmd: SCSI command to translate | 1062 | * @cdb: SCSI command to translate |
| 1065 | * | 1063 | * |
| 1066 | * Calculate LBA and transfer length for 10-byte commands. | 1064 | * Calculate LBA and transfer length for 10-byte commands. |
| 1067 | * | 1065 | * |
| @@ -1069,21 +1067,20 @@ static void scsi_6_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen) | |||
| 1069 | * @plba: the LBA | 1067 | * @plba: the LBA |
| 1070 | * @plen: the transfer length | 1068 | * @plen: the transfer length |
| 1071 | */ | 1069 | */ |
| 1072 | 1070 | static void scsi_10_lba_len(const u8 *cdb, u64 *plba, u32 *plen) | |
| 1073 | static void scsi_10_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen) | ||
| 1074 | { | 1071 | { |
| 1075 | u64 lba = 0; | 1072 | u64 lba = 0; |
| 1076 | u32 len = 0; | 1073 | u32 len = 0; |
| 1077 | 1074 | ||
| 1078 | VPRINTK("ten-byte command\n"); | 1075 | VPRINTK("ten-byte command\n"); |
| 1079 | 1076 | ||
| 1080 | lba |= ((u64)scsicmd[2]) << 24; | 1077 | lba |= ((u64)cdb[2]) << 24; |
| 1081 | lba |= ((u64)scsicmd[3]) << 16; | 1078 | lba |= ((u64)cdb[3]) << 16; |
| 1082 | lba |= ((u64)scsicmd[4]) << 8; | 1079 | lba |= ((u64)cdb[4]) << 8; |
| 1083 | lba |= ((u64)scsicmd[5]); | 1080 | lba |= ((u64)cdb[5]); |
| 1084 | 1081 | ||
| 1085 | len |= ((u32)scsicmd[7]) << 8; | 1082 | len |= ((u32)cdb[7]) << 8; |
| 1086 | len |= ((u32)scsicmd[8]); | 1083 | len |= ((u32)cdb[8]); |
| 1087 | 1084 | ||
| 1088 | *plba = lba; | 1085 | *plba = lba; |
| 1089 | *plen = len; | 1086 | *plen = len; |
| @@ -1091,7 +1088,7 @@ static void scsi_10_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen) | |||
| 1091 | 1088 | ||
| 1092 | /** | 1089 | /** |
| 1093 | * scsi_16_lba_len - Get LBA and transfer length | 1090 | * scsi_16_lba_len - Get LBA and transfer length |
| 1094 | * @scsicmd: SCSI command to translate | 1091 | * @cdb: SCSI command to translate |
| 1095 | * | 1092 | * |
| 1096 | * Calculate LBA and transfer length for 16-byte commands. | 1093 | * Calculate LBA and transfer length for 16-byte commands. |
| 1097 | * | 1094 | * |
| @@ -1099,27 +1096,26 @@ static void scsi_10_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen) | |||
| 1099 | * @plba: the LBA | 1096 | * @plba: the LBA |
| 1100 | * @plen: the transfer length | 1097 | * @plen: the transfer length |
| 1101 | */ | 1098 | */ |
| 1102 | 1099 | static void scsi_16_lba_len(const u8 *cdb, u64 *plba, u32 *plen) | |
| 1103 | static void scsi_16_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen) | ||
| 1104 | { | 1100 | { |
| 1105 | u64 lba = 0; | 1101 | u64 lba = 0; |
| 1106 | u32 len = 0; | 1102 | u32 len = 0; |
| 1107 | 1103 | ||
| 1108 | VPRINTK("sixteen-byte command\n"); | 1104 | VPRINTK("sixteen-byte command\n"); |
| 1109 | 1105 | ||
| 1110 | lba |= ((u64)scsicmd[2]) << 56; | 1106 | lba |= ((u64)cdb[2]) << 56; |
| 1111 | lba |= ((u64)scsicmd[3]) << 48; | 1107 | lba |= ((u64)cdb[3]) << 48; |
| 1112 | lba |= ((u64)scsicmd[4]) << 40; | 1108 | lba |= ((u64)cdb[4]) << 40; |
| 1113 | lba |= ((u64)scsicmd[5]) << 32; | 1109 | lba |= ((u64)cdb[5]) << 32; |
| 1114 | lba |= ((u64)scsicmd[6]) << 24; | 1110 | lba |= ((u64)cdb[6]) << 24; |
| 1115 | lba |= ((u64)scsicmd[7]) << 16; | 1111 | lba |= ((u64)cdb[7]) << 16; |
| 1116 | lba |= ((u64)scsicmd[8]) << 8; | 1112 | lba |= ((u64)cdb[8]) << 8; |
| 1117 | lba |= ((u64)scsicmd[9]); | 1113 | lba |= ((u64)cdb[9]); |
| 1118 | 1114 | ||
| 1119 | len |= ((u32)scsicmd[10]) << 24; | 1115 | len |= ((u32)cdb[10]) << 24; |
| 1120 | len |= ((u32)scsicmd[11]) << 16; | 1116 | len |= ((u32)cdb[11]) << 16; |
| 1121 | len |= ((u32)scsicmd[12]) << 8; | 1117 | len |= ((u32)cdb[12]) << 8; |
| 1122 | len |= ((u32)scsicmd[13]); | 1118 | len |= ((u32)cdb[13]); |
| 1123 | 1119 | ||
| 1124 | *plba = lba; | 1120 | *plba = lba; |
| 1125 | *plen = len; | 1121 | *plen = len; |
| @@ -1128,7 +1124,7 @@ static void scsi_16_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen) | |||
| 1128 | /** | 1124 | /** |
| 1129 | * ata_scsi_verify_xlat - Translate SCSI VERIFY command into an ATA one | 1125 | * ata_scsi_verify_xlat - Translate SCSI VERIFY command into an ATA one |
| 1130 | * @qc: Storage for translated ATA taskfile | 1126 | * @qc: Storage for translated ATA taskfile |
| 1131 | * @scsicmd: SCSI command to translate | 1127 | * @cdb: SCSI command to translate |
| 1132 | * | 1128 | * |
| 1133 | * Converts SCSI VERIFY command to an ATA READ VERIFY command. | 1129 | * Converts SCSI VERIFY command to an ATA READ VERIFY command. |
| 1134 | * | 1130 | * |
| @@ -1138,9 +1134,9 @@ static void scsi_16_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen) | |||
| 1138 | * RETURNS: | 1134 | * RETURNS: |
| 1139 | * Zero on success, non-zero on error. | 1135 | * Zero on success, non-zero on error. |
| 1140 | */ | 1136 | */ |
| 1141 | 1137 | static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *cdb) | |
| 1142 | static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd) | ||
| 1143 | { | 1138 | { |
| 1139 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
| 1144 | struct ata_taskfile *tf = &qc->tf; | 1140 | struct ata_taskfile *tf = &qc->tf; |
| 1145 | struct ata_device *dev = qc->dev; | 1141 | struct ata_device *dev = qc->dev; |
| 1146 | u64 dev_sectors = qc->dev->n_sectors; | 1142 | u64 dev_sectors = qc->dev->n_sectors; |
| @@ -1150,10 +1146,10 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *sc | |||
| 1150 | tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | 1146 | tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; |
| 1151 | tf->protocol = ATA_PROT_NODATA; | 1147 | tf->protocol = ATA_PROT_NODATA; |
| 1152 | 1148 | ||
| 1153 | if (scsicmd[0] == VERIFY) | 1149 | if (cdb[0] == VERIFY) |
| 1154 | scsi_10_lba_len(scsicmd, &block, &n_block); | 1150 | scsi_10_lba_len(cdb, &block, &n_block); |
| 1155 | else if (scsicmd[0] == VERIFY_16) | 1151 | else if (cdb[0] == VERIFY_16) |
| 1156 | scsi_16_lba_len(scsicmd, &block, &n_block); | 1152 | scsi_16_lba_len(cdb, &block, &n_block); |
| 1157 | else | 1153 | else |
| 1158 | goto invalid_fld; | 1154 | goto invalid_fld; |
| 1159 | 1155 | ||
| @@ -1229,24 +1225,24 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *sc | |||
| 1229 | return 0; | 1225 | return 0; |
| 1230 | 1226 | ||
| 1231 | invalid_fld: | 1227 | invalid_fld: |
| 1232 | ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x24, 0x0); | 1228 | ata_scsi_set_sense(scmd, ILLEGAL_REQUEST, 0x24, 0x0); |
| 1233 | /* "Invalid field in cbd" */ | 1229 | /* "Invalid field in cbd" */ |
| 1234 | return 1; | 1230 | return 1; |
| 1235 | 1231 | ||
| 1236 | out_of_range: | 1232 | out_of_range: |
| 1237 | ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x21, 0x0); | 1233 | ata_scsi_set_sense(scmd, ILLEGAL_REQUEST, 0x21, 0x0); |
| 1238 | /* "Logical Block Address out of range" */ | 1234 | /* "Logical Block Address out of range" */ |
| 1239 | return 1; | 1235 | return 1; |
| 1240 | 1236 | ||
| 1241 | nothing_to_do: | 1237 | nothing_to_do: |
| 1242 | qc->scsicmd->result = SAM_STAT_GOOD; | 1238 | scmd->result = SAM_STAT_GOOD; |
| 1243 | return 1; | 1239 | return 1; |
| 1244 | } | 1240 | } |
| 1245 | 1241 | ||
| 1246 | /** | 1242 | /** |
| 1247 | * ata_scsi_rw_xlat - Translate SCSI r/w command into an ATA one | 1243 | * ata_scsi_rw_xlat - Translate SCSI r/w command into an ATA one |
| 1248 | * @qc: Storage for translated ATA taskfile | 1244 | * @qc: Storage for translated ATA taskfile |
| 1249 | * @scsicmd: SCSI command to translate | 1245 | * @cdb: SCSI command to translate |
| 1250 | * | 1246 | * |
| 1251 | * Converts any of six SCSI read/write commands into the | 1247 | * Converts any of six SCSI read/write commands into the |
| 1252 | * ATA counterpart, including starting sector (LBA), | 1248 | * ATA counterpart, including starting sector (LBA), |
| @@ -1262,29 +1258,28 @@ nothing_to_do: | |||
| 1262 | * RETURNS: | 1258 | * RETURNS: |
| 1263 | * Zero on success, non-zero on error. | 1259 | * Zero on success, non-zero on error. |
| 1264 | */ | 1260 | */ |
| 1265 | 1261 | static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *cdb) | |
| 1266 | static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd) | ||
| 1267 | { | 1262 | { |
| 1263 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
| 1268 | unsigned int tf_flags = 0; | 1264 | unsigned int tf_flags = 0; |
| 1269 | u64 block; | 1265 | u64 block; |
| 1270 | u32 n_block; | 1266 | u32 n_block; |
| 1271 | int rc; | 1267 | int rc; |
| 1272 | 1268 | ||
| 1273 | if (scsicmd[0] == WRITE_10 || scsicmd[0] == WRITE_6 || | 1269 | if (cdb[0] == WRITE_10 || cdb[0] == WRITE_6 || cdb[0] == WRITE_16) |
| 1274 | scsicmd[0] == WRITE_16) | ||
| 1275 | tf_flags |= ATA_TFLAG_WRITE; | 1270 | tf_flags |= ATA_TFLAG_WRITE; |
| 1276 | 1271 | ||
| 1277 | /* Calculate the SCSI LBA, transfer length and FUA. */ | 1272 | /* Calculate the SCSI LBA, transfer length and FUA. */ |
| 1278 | switch (scsicmd[0]) { | 1273 | switch (cdb[0]) { |
| 1279 | case READ_10: | 1274 | case READ_10: |
| 1280 | case WRITE_10: | 1275 | case WRITE_10: |
| 1281 | scsi_10_lba_len(scsicmd, &block, &n_block); | 1276 | scsi_10_lba_len(cdb, &block, &n_block); |
| 1282 | if (unlikely(scsicmd[1] & (1 << 3))) | 1277 | if (unlikely(cdb[1] & (1 << 3))) |
| 1283 | tf_flags |= ATA_TFLAG_FUA; | 1278 | tf_flags |= ATA_TFLAG_FUA; |
| 1284 | break; | 1279 | break; |
| 1285 | case READ_6: | 1280 | case READ_6: |
| 1286 | case WRITE_6: | 1281 | case WRITE_6: |
| 1287 | scsi_6_lba_len(scsicmd, &block, &n_block); | 1282 | scsi_6_lba_len(cdb, &block, &n_block); |
| 1288 | 1283 | ||
| 1289 | /* for 6-byte r/w commands, transfer length 0 | 1284 | /* for 6-byte r/w commands, transfer length 0 |
| 1290 | * means 256 blocks of data, not 0 block. | 1285 | * means 256 blocks of data, not 0 block. |
| @@ -1294,8 +1289,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm | |||
| 1294 | break; | 1289 | break; |
| 1295 | case READ_16: | 1290 | case READ_16: |
| 1296 | case WRITE_16: | 1291 | case WRITE_16: |
| 1297 | scsi_16_lba_len(scsicmd, &block, &n_block); | 1292 | scsi_16_lba_len(cdb, &block, &n_block); |
| 1298 | if (unlikely(scsicmd[1] & (1 << 3))) | 1293 | if (unlikely(cdb[1] & (1 << 3))) |
| 1299 | tf_flags |= ATA_TFLAG_FUA; | 1294 | tf_flags |= ATA_TFLAG_FUA; |
| 1300 | break; | 1295 | break; |
| 1301 | default: | 1296 | default: |
| @@ -1326,17 +1321,17 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm | |||
| 1326 | goto out_of_range; | 1321 | goto out_of_range; |
| 1327 | /* treat all other errors as -EINVAL, fall through */ | 1322 | /* treat all other errors as -EINVAL, fall through */ |
| 1328 | invalid_fld: | 1323 | invalid_fld: |
| 1329 | ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x24, 0x0); | 1324 | ata_scsi_set_sense(scmd, ILLEGAL_REQUEST, 0x24, 0x0); |
| 1330 | /* "Invalid field in cbd" */ | 1325 | /* "Invalid field in cbd" */ |
| 1331 | return 1; | 1326 | return 1; |
| 1332 | 1327 | ||
| 1333 | out_of_range: | 1328 | out_of_range: |
| 1334 | ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x21, 0x0); | 1329 | ata_scsi_set_sense(scmd, ILLEGAL_REQUEST, 0x21, 0x0); |
| 1335 | /* "Logical Block Address out of range" */ | 1330 | /* "Logical Block Address out of range" */ |
| 1336 | return 1; | 1331 | return 1; |
| 1337 | 1332 | ||
| 1338 | nothing_to_do: | 1333 | nothing_to_do: |
| 1339 | qc->scsicmd->result = SAM_STAT_GOOD; | 1334 | scmd->result = SAM_STAT_GOOD; |
| 1340 | return 1; | 1335 | return 1; |
| 1341 | } | 1336 | } |
| 1342 | 1337 | ||
| @@ -1456,7 +1451,7 @@ static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd, | |||
| 1456 | ata_xlat_func_t xlat_func) | 1451 | ata_xlat_func_t xlat_func) |
| 1457 | { | 1452 | { |
| 1458 | struct ata_queued_cmd *qc; | 1453 | struct ata_queued_cmd *qc; |
| 1459 | u8 *scsicmd = cmd->cmnd; | 1454 | u8 *cdb = cmd->cmnd; |
| 1460 | int is_io = xlat_func == ata_scsi_rw_xlat; | 1455 | int is_io = xlat_func == ata_scsi_rw_xlat; |
| 1461 | 1456 | ||
| 1462 | VPRINTK("ENTER\n"); | 1457 | VPRINTK("ENTER\n"); |
| @@ -1488,7 +1483,7 @@ static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd, | |||
| 1488 | 1483 | ||
| 1489 | qc->complete_fn = ata_scsi_qc_complete; | 1484 | qc->complete_fn = ata_scsi_qc_complete; |
| 1490 | 1485 | ||
| 1491 | if (xlat_func(qc, scsicmd)) | 1486 | if (xlat_func(qc, cdb)) |
| 1492 | goto early_finish; | 1487 | goto early_finish; |
| 1493 | 1488 | ||
| 1494 | /* select device, send command to hardware */ | 1489 | /* select device, send command to hardware */ |
| @@ -2344,7 +2339,7 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc) | |||
| 2344 | /** | 2339 | /** |
| 2345 | * atapi_xlat - Initialize PACKET taskfile | 2340 | * atapi_xlat - Initialize PACKET taskfile |
| 2346 | * @qc: command structure to be initialized | 2341 | * @qc: command structure to be initialized |
| 2347 | * @scsicmd: SCSI CDB associated with this PACKET command | 2342 | * @cdb: SCSI CDB associated with this PACKET command |
| 2348 | * | 2343 | * |
| 2349 | * LOCKING: | 2344 | * LOCKING: |
| 2350 | * spin_lock_irqsave(host lock) | 2345 | * spin_lock_irqsave(host lock) |
| @@ -2352,25 +2347,24 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc) | |||
| 2352 | * RETURNS: | 2347 | * RETURNS: |
| 2353 | * Zero on success, non-zero on failure. | 2348 | * Zero on success, non-zero on failure. |
| 2354 | */ | 2349 | */ |
| 2355 | 2350 | static unsigned int atapi_xlat(struct ata_queued_cmd *qc, const u8 *cdb) | |
| 2356 | static unsigned int atapi_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd) | ||
| 2357 | { | 2351 | { |
| 2358 | struct scsi_cmnd *cmd = qc->scsicmd; | 2352 | struct scsi_cmnd *scmd = qc->scsicmd; |
| 2359 | struct ata_device *dev = qc->dev; | 2353 | struct ata_device *dev = qc->dev; |
| 2360 | int using_pio = (dev->flags & ATA_DFLAG_PIO); | 2354 | int using_pio = (dev->flags & ATA_DFLAG_PIO); |
| 2361 | int nodata = (cmd->sc_data_direction == DMA_NONE); | 2355 | int nodata = (scmd->sc_data_direction == DMA_NONE); |
| 2362 | 2356 | ||
| 2363 | if (!using_pio) | 2357 | if (!using_pio) |
| 2364 | /* Check whether ATAPI DMA is safe */ | 2358 | /* Check whether ATAPI DMA is safe */ |
| 2365 | if (ata_check_atapi_dma(qc)) | 2359 | if (ata_check_atapi_dma(qc)) |
| 2366 | using_pio = 1; | 2360 | using_pio = 1; |
| 2367 | 2361 | ||
| 2368 | memcpy(&qc->cdb, scsicmd, dev->cdb_len); | 2362 | memcpy(&qc->cdb, cdb, dev->cdb_len); |
| 2369 | 2363 | ||
| 2370 | qc->complete_fn = atapi_qc_complete; | 2364 | qc->complete_fn = atapi_qc_complete; |
| 2371 | 2365 | ||
| 2372 | qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | 2366 | qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; |
| 2373 | if (cmd->sc_data_direction == DMA_TO_DEVICE) { | 2367 | if (scmd->sc_data_direction == DMA_TO_DEVICE) { |
| 2374 | qc->tf.flags |= ATA_TFLAG_WRITE; | 2368 | qc->tf.flags |= ATA_TFLAG_WRITE; |
| 2375 | DPRINTK("direction: write\n"); | 2369 | DPRINTK("direction: write\n"); |
| 2376 | } | 2370 | } |
| @@ -2392,12 +2386,12 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd) | |||
| 2392 | qc->tf.protocol = ATA_PROT_ATAPI_DMA; | 2386 | qc->tf.protocol = ATA_PROT_ATAPI_DMA; |
| 2393 | qc->tf.feature |= ATAPI_PKT_DMA; | 2387 | qc->tf.feature |= ATAPI_PKT_DMA; |
| 2394 | 2388 | ||
| 2395 | if (atapi_dmadir && (cmd->sc_data_direction != DMA_TO_DEVICE)) | 2389 | if (atapi_dmadir && (scmd->sc_data_direction != DMA_TO_DEVICE)) |
| 2396 | /* some SATA bridges need us to indicate data xfer direction */ | 2390 | /* some SATA bridges need us to indicate data xfer direction */ |
| 2397 | qc->tf.feature |= ATAPI_DMADIR; | 2391 | qc->tf.feature |= ATAPI_DMADIR; |
| 2398 | } | 2392 | } |
| 2399 | 2393 | ||
| 2400 | qc->nbytes = cmd->request_bufflen; | 2394 | qc->nbytes = scmd->request_bufflen; |
| 2401 | 2395 | ||
| 2402 | return 0; | 2396 | return 0; |
| 2403 | } | 2397 | } |
| @@ -2517,28 +2511,27 @@ ata_scsi_map_proto(u8 byte1) | |||
| 2517 | /** | 2511 | /** |
| 2518 | * ata_scsi_pass_thru - convert ATA pass-thru CDB to taskfile | 2512 | * ata_scsi_pass_thru - convert ATA pass-thru CDB to taskfile |
| 2519 | * @qc: command structure to be initialized | 2513 | * @qc: command structure to be initialized |
| 2520 | * @scsicmd: SCSI command to convert | 2514 | * @cdb: SCSI command to convert |
| 2521 | * | 2515 | * |
| 2522 | * Handles either 12 or 16-byte versions of the CDB. | 2516 | * Handles either 12 or 16-byte versions of the CDB. |
| 2523 | * | 2517 | * |
| 2524 | * RETURNS: | 2518 | * RETURNS: |
| 2525 | * Zero on success, non-zero on failure. | 2519 | * Zero on success, non-zero on failure. |
| 2526 | */ | 2520 | */ |
| 2527 | static unsigned int | 2521 | static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *cdb) |
| 2528 | ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd) | ||
| 2529 | { | 2522 | { |
| 2530 | struct ata_taskfile *tf = &(qc->tf); | 2523 | struct ata_taskfile *tf = &(qc->tf); |
| 2531 | struct scsi_cmnd *cmd = qc->scsicmd; | 2524 | struct scsi_cmnd *scmd = qc->scsicmd; |
| 2532 | struct ata_device *dev = qc->dev; | 2525 | struct ata_device *dev = qc->dev; |
| 2533 | 2526 | ||
| 2534 | if ((tf->protocol = ata_scsi_map_proto(scsicmd[1])) == ATA_PROT_UNKNOWN) | 2527 | if ((tf->protocol = ata_scsi_map_proto(cdb[1])) == ATA_PROT_UNKNOWN) |
| 2535 | goto invalid_fld; | 2528 | goto invalid_fld; |
| 2536 | 2529 | ||
| 2537 | /* We may not issue DMA commands if no DMA mode is set */ | 2530 | /* We may not issue DMA commands if no DMA mode is set */ |
| 2538 | if (tf->protocol == ATA_PROT_DMA && dev->dma_mode == 0) | 2531 | if (tf->protocol == ATA_PROT_DMA && dev->dma_mode == 0) |
| 2539 | goto invalid_fld; | 2532 | goto invalid_fld; |
| 2540 | 2533 | ||
| 2541 | if (scsicmd[1] & 0xe0) | 2534 | if (cdb[1] & 0xe0) |
| 2542 | /* PIO multi not supported yet */ | 2535 | /* PIO multi not supported yet */ |
| 2543 | goto invalid_fld; | 2536 | goto invalid_fld; |
| 2544 | 2537 | ||
| @@ -2546,18 +2539,18 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd) | |||
| 2546 | * 12 and 16 byte CDBs use different offsets to | 2539 | * 12 and 16 byte CDBs use different offsets to |
| 2547 | * provide the various register values. | 2540 | * provide the various register values. |
| 2548 | */ | 2541 | */ |
| 2549 | if (scsicmd[0] == ATA_16) { | 2542 | if (cdb[0] == ATA_16) { |
| 2550 | /* | 2543 | /* |
| 2551 | * 16-byte CDB - may contain extended commands. | 2544 | * 16-byte CDB - may contain extended commands. |
| 2552 | * | 2545 | * |
| 2553 | * If that is the case, copy the upper byte register values. | 2546 | * If that is the case, copy the upper byte register values. |
| 2554 | */ | 2547 | */ |
| 2555 | if (scsicmd[1] & 0x01) { | 2548 | if (cdb[1] & 0x01) { |
| 2556 | tf->hob_feature = scsicmd[3]; | 2549 | tf->hob_feature = cdb[3]; |
| 2557 | tf->hob_nsect = scsicmd[5]; | 2550 | tf->hob_nsect = cdb[5]; |
| 2558 | tf->hob_lbal = scsicmd[7]; | 2551 | tf->hob_lbal = cdb[7]; |
| 2559 | tf->hob_lbam = scsicmd[9]; | 2552 | tf->hob_lbam = cdb[9]; |
| 2560 | tf->hob_lbah = scsicmd[11]; | 2553 | tf->hob_lbah = cdb[11]; |
| 2561 | tf->flags |= ATA_TFLAG_LBA48; | 2554 | tf->flags |= ATA_TFLAG_LBA48; |
| 2562 | } else | 2555 | } else |
| 2563 | tf->flags &= ~ATA_TFLAG_LBA48; | 2556 | tf->flags &= ~ATA_TFLAG_LBA48; |
| @@ -2565,26 +2558,26 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd) | |||
| 2565 | /* | 2558 | /* |
| 2566 | * Always copy low byte, device and command registers. | 2559 | * Always copy low byte, device and command registers. |
| 2567 | */ | 2560 | */ |
| 2568 | tf->feature = scsicmd[4]; | 2561 | tf->feature = cdb[4]; |
| 2569 | tf->nsect = scsicmd[6]; | 2562 | tf->nsect = cdb[6]; |
| 2570 | tf->lbal = scsicmd[8]; | 2563 | tf->lbal = cdb[8]; |
| 2571 | tf->lbam = scsicmd[10]; | 2564 | tf->lbam = cdb[10]; |
| 2572 | tf->lbah = scsicmd[12]; | 2565 | tf->lbah = cdb[12]; |
| 2573 | tf->device = scsicmd[13]; | 2566 | tf->device = cdb[13]; |
| 2574 | tf->command = scsicmd[14]; | 2567 | tf->command = cdb[14]; |
| 2575 | } else { | 2568 | } else { |
| 2576 | /* | 2569 | /* |
| 2577 | * 12-byte CDB - incapable of extended commands. | 2570 | * 12-byte CDB - incapable of extended commands. |
| 2578 | */ | 2571 | */ |
| 2579 | tf->flags &= ~ATA_TFLAG_LBA48; | 2572 | tf->flags &= ~ATA_TFLAG_LBA48; |
| 2580 | 2573 | ||
| 2581 | tf->feature = scsicmd[3]; | 2574 | tf->feature = cdb[3]; |
| 2582 | tf->nsect = scsicmd[4]; | 2575 | tf->nsect = cdb[4]; |
| 2583 | tf->lbal = scsicmd[5]; | 2576 | tf->lbal = cdb[5]; |
| 2584 | tf->lbam = scsicmd[6]; | 2577 | tf->lbam = cdb[6]; |
| 2585 | tf->lbah = scsicmd[7]; | 2578 | tf->lbah = cdb[7]; |
| 2586 | tf->device = scsicmd[8]; | 2579 | tf->device = cdb[8]; |
| 2587 | tf->command = scsicmd[9]; | 2580 | tf->command = cdb[9]; |
| 2588 | } | 2581 | } |
| 2589 | /* | 2582 | /* |
| 2590 | * If slave is possible, enforce correct master/slave bit | 2583 | * If slave is possible, enforce correct master/slave bit |
| @@ -2611,7 +2604,7 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd) | |||
| 2611 | */ | 2604 | */ |
| 2612 | tf->flags |= (ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE); | 2605 | tf->flags |= (ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE); |
| 2613 | 2606 | ||
| 2614 | if (cmd->sc_data_direction == DMA_TO_DEVICE) | 2607 | if (scmd->sc_data_direction == DMA_TO_DEVICE) |
| 2615 | tf->flags |= ATA_TFLAG_WRITE; | 2608 | tf->flags |= ATA_TFLAG_WRITE; |
| 2616 | 2609 | ||
| 2617 | /* | 2610 | /* |
| @@ -2620,7 +2613,7 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd) | |||
| 2620 | * TODO: find out if we need to do more here to | 2613 | * TODO: find out if we need to do more here to |
| 2621 | * cover scatter/gather case. | 2614 | * cover scatter/gather case. |
| 2622 | */ | 2615 | */ |
| 2623 | qc->nsect = cmd->request_bufflen / ATA_SECT_SIZE; | 2616 | qc->nsect = scmd->request_bufflen / ATA_SECT_SIZE; |
| 2624 | 2617 | ||
| 2625 | /* request result TF */ | 2618 | /* request result TF */ |
| 2626 | qc->flags |= ATA_QCFLAG_RESULT_TF; | 2619 | qc->flags |= ATA_QCFLAG_RESULT_TF; |
| @@ -2628,7 +2621,7 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd) | |||
| 2628 | return 0; | 2621 | return 0; |
| 2629 | 2622 | ||
| 2630 | invalid_fld: | 2623 | invalid_fld: |
| 2631 | ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x24, 0x00); | 2624 | ata_scsi_set_sense(scmd, ILLEGAL_REQUEST, 0x24, 0x00); |
| 2632 | /* "Invalid field in cdb" */ | 2625 | /* "Invalid field in cdb" */ |
| 2633 | return 1; | 2626 | return 1; |
| 2634 | } | 2627 | } |
| @@ -2701,7 +2694,7 @@ static inline void ata_scsi_dump_cdb(struct ata_port *ap, | |||
| 2701 | #endif | 2694 | #endif |
| 2702 | } | 2695 | } |
| 2703 | 2696 | ||
| 2704 | static inline int __ata_scsi_queuecmd(struct scsi_cmnd *cmd, | 2697 | static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, |
| 2705 | void (*done)(struct scsi_cmnd *), | 2698 | void (*done)(struct scsi_cmnd *), |
| 2706 | struct ata_device *dev) | 2699 | struct ata_device *dev) |
| 2707 | { | 2700 | { |
| @@ -2709,14 +2702,14 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *cmd, | |||
| 2709 | 2702 | ||
| 2710 | if (dev->class == ATA_DEV_ATA) { | 2703 | if (dev->class == ATA_DEV_ATA) { |
| 2711 | ata_xlat_func_t xlat_func = ata_get_xlat_func(dev, | 2704 | ata_xlat_func_t xlat_func = ata_get_xlat_func(dev, |
| 2712 | cmd->cmnd[0]); | 2705 | scmd->cmnd[0]); |
| 2713 | 2706 | ||
| 2714 | if (xlat_func) | 2707 | if (xlat_func) |
| 2715 | rc = ata_scsi_translate(dev, cmd, done, xlat_func); | 2708 | rc = ata_scsi_translate(dev, scmd, done, xlat_func); |
| 2716 | else | 2709 | else |
| 2717 | ata_scsi_simulate(dev, cmd, done); | 2710 | ata_scsi_simulate(dev, scmd, done); |
| 2718 | } else | 2711 | } else |
| 2719 | rc = ata_scsi_translate(dev, cmd, done, atapi_xlat); | 2712 | rc = ata_scsi_translate(dev, scmd, done, atapi_xlat); |
| 2720 | 2713 | ||
| 2721 | return rc; | 2714 | return rc; |
| 2722 | } | 2715 | } |
