aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ata/ahci.c8
-rw-r--r--drivers/ata/libata-scsi.c238
-rw-r--r--drivers/ata/pata_cs5530.c3
-rw-r--r--drivers/ata/pata_via.c2
-rw-r--r--drivers/ata/sata_nv.c8
-rw-r--r--drivers/ata/sata_svw.c41
-rw-r--r--drivers/ata/sata_vsc.c43
7 files changed, 182 insertions, 161 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index dbae6d971041..b517d2493551 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -402,6 +402,14 @@ static const struct pci_device_id ahci_pci_tbl[] = {
402 { PCI_VDEVICE(NVIDIA, 0x044d), board_ahci }, /* MCP65 */ 402 { PCI_VDEVICE(NVIDIA, 0x044d), board_ahci }, /* MCP65 */
403 { PCI_VDEVICE(NVIDIA, 0x044e), board_ahci }, /* MCP65 */ 403 { PCI_VDEVICE(NVIDIA, 0x044e), board_ahci }, /* MCP65 */
404 { PCI_VDEVICE(NVIDIA, 0x044f), board_ahci }, /* MCP65 */ 404 { PCI_VDEVICE(NVIDIA, 0x044f), board_ahci }, /* MCP65 */
405 { PCI_VDEVICE(NVIDIA, 0x045c), board_ahci }, /* MCP65 */
406 { PCI_VDEVICE(NVIDIA, 0x045d), board_ahci }, /* MCP65 */
407 { PCI_VDEVICE(NVIDIA, 0x045e), board_ahci }, /* MCP65 */
408 { PCI_VDEVICE(NVIDIA, 0x045f), board_ahci }, /* MCP65 */
409 { PCI_VDEVICE(NVIDIA, 0x0550), board_ahci }, /* MCP67 */
410 { PCI_VDEVICE(NVIDIA, 0x0551), board_ahci }, /* MCP67 */
411 { PCI_VDEVICE(NVIDIA, 0x0552), board_ahci }, /* MCP67 */
412 { PCI_VDEVICE(NVIDIA, 0x0553), board_ahci }, /* MCP67 */
405 { PCI_VDEVICE(NVIDIA, 0x0554), board_ahci }, /* MCP67 */ 413 { PCI_VDEVICE(NVIDIA, 0x0554), board_ahci }, /* MCP67 */
406 { PCI_VDEVICE(NVIDIA, 0x0555), board_ahci }, /* MCP67 */ 414 { PCI_VDEVICE(NVIDIA, 0x0555), board_ahci }, /* MCP67 */
407 { PCI_VDEVICE(NVIDIA, 0x0556), board_ahci }, /* MCP67 */ 415 { PCI_VDEVICE(NVIDIA, 0x0556), board_ahci }, /* MCP67 */
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index a4790be41d1c..836947da5b14 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
54typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *scsicmd); 54typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc);
55 55
56static struct ata_device * __ata_scsi_find_dev(struct ata_port *ap, 56static 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,6 @@ 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
939 * 938 *
940 * Sets up an ATA taskfile to issue STANDBY (to stop) or READ VERIFY 939 * Sets up an ATA taskfile to issue STANDBY (to stop) or READ VERIFY
941 * (to start). Perhaps these commands should be preceded by 940 * (to start). Perhaps these commands should be preceded by
@@ -948,22 +947,25 @@ int ata_scsi_change_queue_depth(struct scsi_device *sdev, int queue_depth)
948 * RETURNS: 947 * RETURNS:
949 * Zero on success, non-zero on error. 948 * Zero on success, non-zero on error.
950 */ 949 */
951 950static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc)
952static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc,
953 const u8 *scsicmd)
954{ 951{
952 struct scsi_cmnd *scmd = qc->scsicmd;
955 struct ata_taskfile *tf = &qc->tf; 953 struct ata_taskfile *tf = &qc->tf;
954 const u8 *cdb = scmd->cmnd;
955
956 if (scmd->cmd_len < 5)
957 goto invalid_fld;
956 958
957 tf->flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR; 959 tf->flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR;
958 tf->protocol = ATA_PROT_NODATA; 960 tf->protocol = ATA_PROT_NODATA;
959 if (scsicmd[1] & 0x1) { 961 if (cdb[1] & 0x1) {
960 ; /* ignore IMMED bit, violates sat-r05 */ 962 ; /* ignore IMMED bit, violates sat-r05 */
961 } 963 }
962 if (scsicmd[4] & 0x2) 964 if (cdb[4] & 0x2)
963 goto invalid_fld; /* LOEJ bit set not supported */ 965 goto invalid_fld; /* LOEJ bit set not supported */
964 if (((scsicmd[4] >> 4) & 0xf) != 0) 966 if (((cdb[4] >> 4) & 0xf) != 0)
965 goto invalid_fld; /* power conditions not supported */ 967 goto invalid_fld; /* power conditions not supported */
966 if (scsicmd[4] & 0x1) { 968 if (cdb[4] & 0x1) {
967 tf->nsect = 1; /* 1 sector, lba=0 */ 969 tf->nsect = 1; /* 1 sector, lba=0 */
968 970
969 if (qc->dev->flags & ATA_DFLAG_LBA) { 971 if (qc->dev->flags & ATA_DFLAG_LBA) {
@@ -996,7 +998,7 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc,
996 return 0; 998 return 0;
997 999
998invalid_fld: 1000invalid_fld:
999 ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x24, 0x0); 1001 ata_scsi_set_sense(scmd, ILLEGAL_REQUEST, 0x24, 0x0);
1000 /* "Invalid field in cbd" */ 1002 /* "Invalid field in cbd" */
1001 return 1; 1003 return 1;
1002} 1004}
@@ -1005,7 +1007,6 @@ invalid_fld:
1005/** 1007/**
1006 * ata_scsi_flush_xlat - Translate SCSI SYNCHRONIZE CACHE command 1008 * ata_scsi_flush_xlat - Translate SCSI SYNCHRONIZE CACHE command
1007 * @qc: Storage for translated ATA taskfile 1009 * @qc: Storage for translated ATA taskfile
1008 * @scsicmd: SCSI command to translate (ignored)
1009 * 1010 *
1010 * Sets up an ATA taskfile to issue FLUSH CACHE or 1011 * Sets up an ATA taskfile to issue FLUSH CACHE or
1011 * FLUSH CACHE EXT. 1012 * FLUSH CACHE EXT.
@@ -1016,8 +1017,7 @@ invalid_fld:
1016 * RETURNS: 1017 * RETURNS:
1017 * Zero on success, non-zero on error. 1018 * Zero on success, non-zero on error.
1018 */ 1019 */
1019 1020static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc)
1020static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd)
1021{ 1021{
1022 struct ata_taskfile *tf = &qc->tf; 1022 struct ata_taskfile *tf = &qc->tf;
1023 1023
@@ -1034,7 +1034,7 @@ static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc, const u8 *scs
1034 1034
1035/** 1035/**
1036 * scsi_6_lba_len - Get LBA and transfer length 1036 * scsi_6_lba_len - Get LBA and transfer length
1037 * @scsicmd: SCSI command to translate 1037 * @cdb: SCSI command to translate
1038 * 1038 *
1039 * Calculate LBA and transfer length for 6-byte commands. 1039 * Calculate LBA and transfer length for 6-byte commands.
1040 * 1040 *
@@ -1042,18 +1042,17 @@ static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc, const u8 *scs
1042 * @plba: the LBA 1042 * @plba: the LBA
1043 * @plen: the transfer length 1043 * @plen: the transfer length
1044 */ 1044 */
1045 1045static void scsi_6_lba_len(const u8 *cdb, u64 *plba, u32 *plen)
1046static void scsi_6_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen)
1047{ 1046{
1048 u64 lba = 0; 1047 u64 lba = 0;
1049 u32 len = 0; 1048 u32 len = 0;
1050 1049
1051 VPRINTK("six-byte command\n"); 1050 VPRINTK("six-byte command\n");
1052 1051
1053 lba |= ((u64)scsicmd[2]) << 8; 1052 lba |= ((u64)cdb[2]) << 8;
1054 lba |= ((u64)scsicmd[3]); 1053 lba |= ((u64)cdb[3]);
1055 1054
1056 len |= ((u32)scsicmd[4]); 1055 len |= ((u32)cdb[4]);
1057 1056
1058 *plba = lba; 1057 *plba = lba;
1059 *plen = len; 1058 *plen = len;
@@ -1061,7 +1060,7 @@ static void scsi_6_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen)
1061 1060
1062/** 1061/**
1063 * scsi_10_lba_len - Get LBA and transfer length 1062 * scsi_10_lba_len - Get LBA and transfer length
1064 * @scsicmd: SCSI command to translate 1063 * @cdb: SCSI command to translate
1065 * 1064 *
1066 * Calculate LBA and transfer length for 10-byte commands. 1065 * Calculate LBA and transfer length for 10-byte commands.
1067 * 1066 *
@@ -1069,21 +1068,20 @@ static void scsi_6_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen)
1069 * @plba: the LBA 1068 * @plba: the LBA
1070 * @plen: the transfer length 1069 * @plen: the transfer length
1071 */ 1070 */
1072 1071static void scsi_10_lba_len(const u8 *cdb, u64 *plba, u32 *plen)
1073static void scsi_10_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen)
1074{ 1072{
1075 u64 lba = 0; 1073 u64 lba = 0;
1076 u32 len = 0; 1074 u32 len = 0;
1077 1075
1078 VPRINTK("ten-byte command\n"); 1076 VPRINTK("ten-byte command\n");
1079 1077
1080 lba |= ((u64)scsicmd[2]) << 24; 1078 lba |= ((u64)cdb[2]) << 24;
1081 lba |= ((u64)scsicmd[3]) << 16; 1079 lba |= ((u64)cdb[3]) << 16;
1082 lba |= ((u64)scsicmd[4]) << 8; 1080 lba |= ((u64)cdb[4]) << 8;
1083 lba |= ((u64)scsicmd[5]); 1081 lba |= ((u64)cdb[5]);
1084 1082
1085 len |= ((u32)scsicmd[7]) << 8; 1083 len |= ((u32)cdb[7]) << 8;
1086 len |= ((u32)scsicmd[8]); 1084 len |= ((u32)cdb[8]);
1087 1085
1088 *plba = lba; 1086 *plba = lba;
1089 *plen = len; 1087 *plen = len;
@@ -1091,7 +1089,7 @@ static void scsi_10_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen)
1091 1089
1092/** 1090/**
1093 * scsi_16_lba_len - Get LBA and transfer length 1091 * scsi_16_lba_len - Get LBA and transfer length
1094 * @scsicmd: SCSI command to translate 1092 * @cdb: SCSI command to translate
1095 * 1093 *
1096 * Calculate LBA and transfer length for 16-byte commands. 1094 * Calculate LBA and transfer length for 16-byte commands.
1097 * 1095 *
@@ -1099,27 +1097,26 @@ static void scsi_10_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen)
1099 * @plba: the LBA 1097 * @plba: the LBA
1100 * @plen: the transfer length 1098 * @plen: the transfer length
1101 */ 1099 */
1102 1100static void scsi_16_lba_len(const u8 *cdb, u64 *plba, u32 *plen)
1103static void scsi_16_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen)
1104{ 1101{
1105 u64 lba = 0; 1102 u64 lba = 0;
1106 u32 len = 0; 1103 u32 len = 0;
1107 1104
1108 VPRINTK("sixteen-byte command\n"); 1105 VPRINTK("sixteen-byte command\n");
1109 1106
1110 lba |= ((u64)scsicmd[2]) << 56; 1107 lba |= ((u64)cdb[2]) << 56;
1111 lba |= ((u64)scsicmd[3]) << 48; 1108 lba |= ((u64)cdb[3]) << 48;
1112 lba |= ((u64)scsicmd[4]) << 40; 1109 lba |= ((u64)cdb[4]) << 40;
1113 lba |= ((u64)scsicmd[5]) << 32; 1110 lba |= ((u64)cdb[5]) << 32;
1114 lba |= ((u64)scsicmd[6]) << 24; 1111 lba |= ((u64)cdb[6]) << 24;
1115 lba |= ((u64)scsicmd[7]) << 16; 1112 lba |= ((u64)cdb[7]) << 16;
1116 lba |= ((u64)scsicmd[8]) << 8; 1113 lba |= ((u64)cdb[8]) << 8;
1117 lba |= ((u64)scsicmd[9]); 1114 lba |= ((u64)cdb[9]);
1118 1115
1119 len |= ((u32)scsicmd[10]) << 24; 1116 len |= ((u32)cdb[10]) << 24;
1120 len |= ((u32)scsicmd[11]) << 16; 1117 len |= ((u32)cdb[11]) << 16;
1121 len |= ((u32)scsicmd[12]) << 8; 1118 len |= ((u32)cdb[12]) << 8;
1122 len |= ((u32)scsicmd[13]); 1119 len |= ((u32)cdb[13]);
1123 1120
1124 *plba = lba; 1121 *plba = lba;
1125 *plen = len; 1122 *plen = len;
@@ -1128,7 +1125,6 @@ static void scsi_16_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen)
1128/** 1125/**
1129 * ata_scsi_verify_xlat - Translate SCSI VERIFY command into an ATA one 1126 * ata_scsi_verify_xlat - Translate SCSI VERIFY command into an ATA one
1130 * @qc: Storage for translated ATA taskfile 1127 * @qc: Storage for translated ATA taskfile
1131 * @scsicmd: 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,23 +1134,28 @@ 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 1137static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc)
1142static 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;
1143 const u8 *cdb = scmd->cmnd;
1147 u64 block; 1144 u64 block;
1148 u32 n_block; 1145 u32 n_block;
1149 1146
1150 tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 1147 tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
1151 tf->protocol = ATA_PROT_NODATA; 1148 tf->protocol = ATA_PROT_NODATA;
1152 1149
1153 if (scsicmd[0] == VERIFY) 1150 if (cdb[0] == VERIFY) {
1154 scsi_10_lba_len(scsicmd, &block, &n_block); 1151 if (scmd->cmd_len < 10)
1155 else if (scsicmd[0] == VERIFY_16) 1152 goto invalid_fld;
1156 scsi_16_lba_len(scsicmd, &block, &n_block); 1153 scsi_10_lba_len(cdb, &block, &n_block);
1157 else 1154 } else if (cdb[0] == VERIFY_16) {
1155 if (scmd->cmd_len < 16)
1156 goto invalid_fld;
1157 scsi_16_lba_len(cdb, &block, &n_block);
1158 } else
1158 goto invalid_fld; 1159 goto invalid_fld;
1159 1160
1160 if (!n_block) 1161 if (!n_block)
@@ -1229,24 +1230,23 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *sc
1229 return 0; 1230 return 0;
1230 1231
1231invalid_fld: 1232invalid_fld:
1232 ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x24, 0x0); 1233 ata_scsi_set_sense(scmd, ILLEGAL_REQUEST, 0x24, 0x0);
1233 /* "Invalid field in cbd" */ 1234 /* "Invalid field in cbd" */
1234 return 1; 1235 return 1;
1235 1236
1236out_of_range: 1237out_of_range:
1237 ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x21, 0x0); 1238 ata_scsi_set_sense(scmd, ILLEGAL_REQUEST, 0x21, 0x0);
1238 /* "Logical Block Address out of range" */ 1239 /* "Logical Block Address out of range" */
1239 return 1; 1240 return 1;
1240 1241
1241nothing_to_do: 1242nothing_to_do:
1242 qc->scsicmd->result = SAM_STAT_GOOD; 1243 scmd->result = SAM_STAT_GOOD;
1243 return 1; 1244 return 1;
1244} 1245}
1245 1246
1246/** 1247/**
1247 * ata_scsi_rw_xlat - Translate SCSI r/w command into an ATA one 1248 * ata_scsi_rw_xlat - Translate SCSI r/w command into an ATA one
1248 * @qc: Storage for translated ATA taskfile 1249 * @qc: Storage for translated ATA taskfile
1249 * @scsicmd: SCSI command to translate
1250 * 1250 *
1251 * Converts any of six SCSI read/write commands into the 1251 * Converts any of six SCSI read/write commands into the
1252 * ATA counterpart, including starting sector (LBA), 1252 * ATA counterpart, including starting sector (LBA),
@@ -1262,29 +1262,33 @@ nothing_to_do:
1262 * RETURNS: 1262 * RETURNS:
1263 * Zero on success, non-zero on error. 1263 * Zero on success, non-zero on error.
1264 */ 1264 */
1265 1265static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc)
1266static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd)
1267{ 1266{
1267 struct scsi_cmnd *scmd = qc->scsicmd;
1268 const u8 *cdb = scmd->cmnd;
1268 unsigned int tf_flags = 0; 1269 unsigned int tf_flags = 0;
1269 u64 block; 1270 u64 block;
1270 u32 n_block; 1271 u32 n_block;
1271 int rc; 1272 int rc;
1272 1273
1273 if (scsicmd[0] == WRITE_10 || scsicmd[0] == WRITE_6 || 1274 if (cdb[0] == WRITE_10 || cdb[0] == WRITE_6 || cdb[0] == WRITE_16)
1274 scsicmd[0] == WRITE_16)
1275 tf_flags |= ATA_TFLAG_WRITE; 1275 tf_flags |= ATA_TFLAG_WRITE;
1276 1276
1277 /* Calculate the SCSI LBA, transfer length and FUA. */ 1277 /* Calculate the SCSI LBA, transfer length and FUA. */
1278 switch (scsicmd[0]) { 1278 switch (cdb[0]) {
1279 case READ_10: 1279 case READ_10:
1280 case WRITE_10: 1280 case WRITE_10:
1281 scsi_10_lba_len(scsicmd, &block, &n_block); 1281 if (unlikely(scmd->cmd_len < 10))
1282 if (unlikely(scsicmd[1] & (1 << 3))) 1282 goto invalid_fld;
1283 scsi_10_lba_len(cdb, &block, &n_block);
1284 if (unlikely(cdb[1] & (1 << 3)))
1283 tf_flags |= ATA_TFLAG_FUA; 1285 tf_flags |= ATA_TFLAG_FUA;
1284 break; 1286 break;
1285 case READ_6: 1287 case READ_6:
1286 case WRITE_6: 1288 case WRITE_6:
1287 scsi_6_lba_len(scsicmd, &block, &n_block); 1289 if (unlikely(scmd->cmd_len < 6))
1290 goto invalid_fld;
1291 scsi_6_lba_len(cdb, &block, &n_block);
1288 1292
1289 /* for 6-byte r/w commands, transfer length 0 1293 /* for 6-byte r/w commands, transfer length 0
1290 * means 256 blocks of data, not 0 block. 1294 * means 256 blocks of data, not 0 block.
@@ -1294,8 +1298,10 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
1294 break; 1298 break;
1295 case READ_16: 1299 case READ_16:
1296 case WRITE_16: 1300 case WRITE_16:
1297 scsi_16_lba_len(scsicmd, &block, &n_block); 1301 if (unlikely(scmd->cmd_len < 16))
1298 if (unlikely(scsicmd[1] & (1 << 3))) 1302 goto invalid_fld;
1303 scsi_16_lba_len(cdb, &block, &n_block);
1304 if (unlikely(cdb[1] & (1 << 3)))
1299 tf_flags |= ATA_TFLAG_FUA; 1305 tf_flags |= ATA_TFLAG_FUA;
1300 break; 1306 break;
1301 default: 1307 default:
@@ -1326,17 +1332,17 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
1326 goto out_of_range; 1332 goto out_of_range;
1327 /* treat all other errors as -EINVAL, fall through */ 1333 /* treat all other errors as -EINVAL, fall through */
1328invalid_fld: 1334invalid_fld:
1329 ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x24, 0x0); 1335 ata_scsi_set_sense(scmd, ILLEGAL_REQUEST, 0x24, 0x0);
1330 /* "Invalid field in cbd" */ 1336 /* "Invalid field in cbd" */
1331 return 1; 1337 return 1;
1332 1338
1333out_of_range: 1339out_of_range:
1334 ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x21, 0x0); 1340 ata_scsi_set_sense(scmd, ILLEGAL_REQUEST, 0x21, 0x0);
1335 /* "Logical Block Address out of range" */ 1341 /* "Logical Block Address out of range" */
1336 return 1; 1342 return 1;
1337 1343
1338nothing_to_do: 1344nothing_to_do:
1339 qc->scsicmd->result = SAM_STAT_GOOD; 1345 scmd->result = SAM_STAT_GOOD;
1340 return 1; 1346 return 1;
1341} 1347}
1342 1348
@@ -1456,7 +1462,6 @@ static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd,
1456 ata_xlat_func_t xlat_func) 1462 ata_xlat_func_t xlat_func)
1457{ 1463{
1458 struct ata_queued_cmd *qc; 1464 struct ata_queued_cmd *qc;
1459 u8 *scsicmd = cmd->cmnd;
1460 int is_io = xlat_func == ata_scsi_rw_xlat; 1465 int is_io = xlat_func == ata_scsi_rw_xlat;
1461 1466
1462 VPRINTK("ENTER\n"); 1467 VPRINTK("ENTER\n");
@@ -1488,7 +1493,7 @@ static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd,
1488 1493
1489 qc->complete_fn = ata_scsi_qc_complete; 1494 qc->complete_fn = ata_scsi_qc_complete;
1490 1495
1491 if (xlat_func(qc, scsicmd)) 1496 if (xlat_func(qc))
1492 goto early_finish; 1497 goto early_finish;
1493 1498
1494 /* select device, send command to hardware */ 1499 /* select device, send command to hardware */
@@ -2344,7 +2349,6 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc)
2344/** 2349/**
2345 * atapi_xlat - Initialize PACKET taskfile 2350 * atapi_xlat - Initialize PACKET taskfile
2346 * @qc: command structure to be initialized 2351 * @qc: command structure to be initialized
2347 * @scsicmd: SCSI CDB associated with this PACKET command
2348 * 2352 *
2349 * LOCKING: 2353 * LOCKING:
2350 * spin_lock_irqsave(host lock) 2354 * spin_lock_irqsave(host lock)
@@ -2352,25 +2356,25 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc)
2352 * RETURNS: 2356 * RETURNS:
2353 * Zero on success, non-zero on failure. 2357 * Zero on success, non-zero on failure.
2354 */ 2358 */
2355 2359static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
2356static unsigned int atapi_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd)
2357{ 2360{
2358 struct scsi_cmnd *cmd = qc->scsicmd; 2361 struct scsi_cmnd *scmd = qc->scsicmd;
2359 struct ata_device *dev = qc->dev; 2362 struct ata_device *dev = qc->dev;
2360 int using_pio = (dev->flags & ATA_DFLAG_PIO); 2363 int using_pio = (dev->flags & ATA_DFLAG_PIO);
2361 int nodata = (cmd->sc_data_direction == DMA_NONE); 2364 int nodata = (scmd->sc_data_direction == DMA_NONE);
2362 2365
2363 if (!using_pio) 2366 if (!using_pio)
2364 /* Check whether ATAPI DMA is safe */ 2367 /* Check whether ATAPI DMA is safe */
2365 if (ata_check_atapi_dma(qc)) 2368 if (ata_check_atapi_dma(qc))
2366 using_pio = 1; 2369 using_pio = 1;
2367 2370
2368 memcpy(&qc->cdb, scsicmd, dev->cdb_len); 2371 memset(qc->cdb, 0, dev->cdb_len);
2372 memcpy(qc->cdb, scmd->cmnd, scmd->cmd_len);
2369 2373
2370 qc->complete_fn = atapi_qc_complete; 2374 qc->complete_fn = atapi_qc_complete;
2371 2375
2372 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 2376 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
2373 if (cmd->sc_data_direction == DMA_TO_DEVICE) { 2377 if (scmd->sc_data_direction == DMA_TO_DEVICE) {
2374 qc->tf.flags |= ATA_TFLAG_WRITE; 2378 qc->tf.flags |= ATA_TFLAG_WRITE;
2375 DPRINTK("direction: write\n"); 2379 DPRINTK("direction: write\n");
2376 } 2380 }
@@ -2392,12 +2396,12 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd)
2392 qc->tf.protocol = ATA_PROT_ATAPI_DMA; 2396 qc->tf.protocol = ATA_PROT_ATAPI_DMA;
2393 qc->tf.feature |= ATAPI_PKT_DMA; 2397 qc->tf.feature |= ATAPI_PKT_DMA;
2394 2398
2395 if (atapi_dmadir && (cmd->sc_data_direction != DMA_TO_DEVICE)) 2399 if (atapi_dmadir && (scmd->sc_data_direction != DMA_TO_DEVICE))
2396 /* some SATA bridges need us to indicate data xfer direction */ 2400 /* some SATA bridges need us to indicate data xfer direction */
2397 qc->tf.feature |= ATAPI_DMADIR; 2401 qc->tf.feature |= ATAPI_DMADIR;
2398 } 2402 }
2399 2403
2400 qc->nbytes = cmd->request_bufflen; 2404 qc->nbytes = scmd->request_bufflen;
2401 2405
2402 return 0; 2406 return 0;
2403} 2407}
@@ -2517,28 +2521,27 @@ ata_scsi_map_proto(u8 byte1)
2517/** 2521/**
2518 * ata_scsi_pass_thru - convert ATA pass-thru CDB to taskfile 2522 * ata_scsi_pass_thru - convert ATA pass-thru CDB to taskfile
2519 * @qc: command structure to be initialized 2523 * @qc: command structure to be initialized
2520 * @scsicmd: SCSI command to convert
2521 * 2524 *
2522 * Handles either 12 or 16-byte versions of the CDB. 2525 * Handles either 12 or 16-byte versions of the CDB.
2523 * 2526 *
2524 * RETURNS: 2527 * RETURNS:
2525 * Zero on success, non-zero on failure. 2528 * Zero on success, non-zero on failure.
2526 */ 2529 */
2527static unsigned int 2530static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
2528ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd)
2529{ 2531{
2530 struct ata_taskfile *tf = &(qc->tf); 2532 struct ata_taskfile *tf = &(qc->tf);
2531 struct scsi_cmnd *cmd = qc->scsicmd; 2533 struct scsi_cmnd *scmd = qc->scsicmd;
2532 struct ata_device *dev = qc->dev; 2534 struct ata_device *dev = qc->dev;
2535 const u8 *cdb = scmd->cmnd;
2533 2536
2534 if ((tf->protocol = ata_scsi_map_proto(scsicmd[1])) == ATA_PROT_UNKNOWN) 2537 if ((tf->protocol = ata_scsi_map_proto(cdb[1])) == ATA_PROT_UNKNOWN)
2535 goto invalid_fld; 2538 goto invalid_fld;
2536 2539
2537 /* We may not issue DMA commands if no DMA mode is set */ 2540 /* We may not issue DMA commands if no DMA mode is set */
2538 if (tf->protocol == ATA_PROT_DMA && dev->dma_mode == 0) 2541 if (tf->protocol == ATA_PROT_DMA && dev->dma_mode == 0)
2539 goto invalid_fld; 2542 goto invalid_fld;
2540 2543
2541 if (scsicmd[1] & 0xe0) 2544 if (cdb[1] & 0xe0)
2542 /* PIO multi not supported yet */ 2545 /* PIO multi not supported yet */
2543 goto invalid_fld; 2546 goto invalid_fld;
2544 2547
@@ -2546,18 +2549,18 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd)
2546 * 12 and 16 byte CDBs use different offsets to 2549 * 12 and 16 byte CDBs use different offsets to
2547 * provide the various register values. 2550 * provide the various register values.
2548 */ 2551 */
2549 if (scsicmd[0] == ATA_16) { 2552 if (cdb[0] == ATA_16) {
2550 /* 2553 /*
2551 * 16-byte CDB - may contain extended commands. 2554 * 16-byte CDB - may contain extended commands.
2552 * 2555 *
2553 * If that is the case, copy the upper byte register values. 2556 * If that is the case, copy the upper byte register values.
2554 */ 2557 */
2555 if (scsicmd[1] & 0x01) { 2558 if (cdb[1] & 0x01) {
2556 tf->hob_feature = scsicmd[3]; 2559 tf->hob_feature = cdb[3];
2557 tf->hob_nsect = scsicmd[5]; 2560 tf->hob_nsect = cdb[5];
2558 tf->hob_lbal = scsicmd[7]; 2561 tf->hob_lbal = cdb[7];
2559 tf->hob_lbam = scsicmd[9]; 2562 tf->hob_lbam = cdb[9];
2560 tf->hob_lbah = scsicmd[11]; 2563 tf->hob_lbah = cdb[11];
2561 tf->flags |= ATA_TFLAG_LBA48; 2564 tf->flags |= ATA_TFLAG_LBA48;
2562 } else 2565 } else
2563 tf->flags &= ~ATA_TFLAG_LBA48; 2566 tf->flags &= ~ATA_TFLAG_LBA48;
@@ -2565,26 +2568,26 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd)
2565 /* 2568 /*
2566 * Always copy low byte, device and command registers. 2569 * Always copy low byte, device and command registers.
2567 */ 2570 */
2568 tf->feature = scsicmd[4]; 2571 tf->feature = cdb[4];
2569 tf->nsect = scsicmd[6]; 2572 tf->nsect = cdb[6];
2570 tf->lbal = scsicmd[8]; 2573 tf->lbal = cdb[8];
2571 tf->lbam = scsicmd[10]; 2574 tf->lbam = cdb[10];
2572 tf->lbah = scsicmd[12]; 2575 tf->lbah = cdb[12];
2573 tf->device = scsicmd[13]; 2576 tf->device = cdb[13];
2574 tf->command = scsicmd[14]; 2577 tf->command = cdb[14];
2575 } else { 2578 } else {
2576 /* 2579 /*
2577 * 12-byte CDB - incapable of extended commands. 2580 * 12-byte CDB - incapable of extended commands.
2578 */ 2581 */
2579 tf->flags &= ~ATA_TFLAG_LBA48; 2582 tf->flags &= ~ATA_TFLAG_LBA48;
2580 2583
2581 tf->feature = scsicmd[3]; 2584 tf->feature = cdb[3];
2582 tf->nsect = scsicmd[4]; 2585 tf->nsect = cdb[4];
2583 tf->lbal = scsicmd[5]; 2586 tf->lbal = cdb[5];
2584 tf->lbam = scsicmd[6]; 2587 tf->lbam = cdb[6];
2585 tf->lbah = scsicmd[7]; 2588 tf->lbah = cdb[7];
2586 tf->device = scsicmd[8]; 2589 tf->device = cdb[8];
2587 tf->command = scsicmd[9]; 2590 tf->command = cdb[9];
2588 } 2591 }
2589 /* 2592 /*
2590 * If slave is possible, enforce correct master/slave bit 2593 * If slave is possible, enforce correct master/slave bit
@@ -2611,7 +2614,7 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd)
2611 */ 2614 */
2612 tf->flags |= (ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE); 2615 tf->flags |= (ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE);
2613 2616
2614 if (cmd->sc_data_direction == DMA_TO_DEVICE) 2617 if (scmd->sc_data_direction == DMA_TO_DEVICE)
2615 tf->flags |= ATA_TFLAG_WRITE; 2618 tf->flags |= ATA_TFLAG_WRITE;
2616 2619
2617 /* 2620 /*
@@ -2620,7 +2623,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 2623 * TODO: find out if we need to do more here to
2621 * cover scatter/gather case. 2624 * cover scatter/gather case.
2622 */ 2625 */
2623 qc->nsect = cmd->request_bufflen / ATA_SECT_SIZE; 2626 qc->nsect = scmd->request_bufflen / ATA_SECT_SIZE;
2624 2627
2625 /* request result TF */ 2628 /* request result TF */
2626 qc->flags |= ATA_QCFLAG_RESULT_TF; 2629 qc->flags |= ATA_QCFLAG_RESULT_TF;
@@ -2628,7 +2631,7 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd)
2628 return 0; 2631 return 0;
2629 2632
2630 invalid_fld: 2633 invalid_fld:
2631 ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x24, 0x00); 2634 ata_scsi_set_sense(scmd, ILLEGAL_REQUEST, 0x24, 0x00);
2632 /* "Invalid field in cdb" */ 2635 /* "Invalid field in cdb" */
2633 return 1; 2636 return 1;
2634} 2637}
@@ -2701,22 +2704,29 @@ static inline void ata_scsi_dump_cdb(struct ata_port *ap,
2701#endif 2704#endif
2702} 2705}
2703 2706
2704static inline int __ata_scsi_queuecmd(struct scsi_cmnd *cmd, 2707static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd,
2705 void (*done)(struct scsi_cmnd *), 2708 void (*done)(struct scsi_cmnd *),
2706 struct ata_device *dev) 2709 struct ata_device *dev)
2707{ 2710{
2708 int rc = 0; 2711 int rc = 0;
2709 2712
2713 if (unlikely(!scmd->cmd_len)) {
2714 ata_dev_printk(dev, KERN_WARNING, "WARNING: zero len CDB\n");
2715 scmd->result = DID_ERROR << 16;
2716 done(scmd);
2717 return 0;
2718 }
2719
2710 if (dev->class == ATA_DEV_ATA) { 2720 if (dev->class == ATA_DEV_ATA) {
2711 ata_xlat_func_t xlat_func = ata_get_xlat_func(dev, 2721 ata_xlat_func_t xlat_func = ata_get_xlat_func(dev,
2712 cmd->cmnd[0]); 2722 scmd->cmnd[0]);
2713 2723
2714 if (xlat_func) 2724 if (xlat_func)
2715 rc = ata_scsi_translate(dev, cmd, done, xlat_func); 2725 rc = ata_scsi_translate(dev, scmd, done, xlat_func);
2716 else 2726 else
2717 ata_scsi_simulate(dev, cmd, done); 2727 ata_scsi_simulate(dev, scmd, done);
2718 } else 2728 } else
2719 rc = ata_scsi_translate(dev, cmd, done, atapi_xlat); 2729 rc = ata_scsi_translate(dev, scmd, done, atapi_xlat);
2720 2730
2721 return rc; 2731 return rc;
2722} 2732}
diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c
index 1c628014dae6..b1ca207e3545 100644
--- a/drivers/ata/pata_cs5530.c
+++ b/drivers/ata/pata_cs5530.c
@@ -372,7 +372,8 @@ static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
372static int cs5530_reinit_one(struct pci_dev *pdev) 372static int cs5530_reinit_one(struct pci_dev *pdev)
373{ 373{
374 /* If we fail on resume we are doomed */ 374 /* If we fail on resume we are doomed */
375 BUG_ON(cs5530_init_chip()); 375 if (cs5530_init_chip())
376 BUG();
376 return ata_pci_device_resume(pdev); 377 return ata_pci_device_resume(pdev);
377} 378}
378 379
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index ff93e8f71cf8..f0d4f7e9ed31 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -395,7 +395,7 @@ static void via_config_fifo(struct pci_dev *pdev, unsigned int flags)
395 enable &= 3; 395 enable &= 3;
396 396
397 if (flags & VIA_SET_FIFO) { 397 if (flags & VIA_SET_FIFO) {
398 u8 fifo_setting[4] = {0x00, 0x60, 0x00, 0x20}; 398 static const u8 fifo_setting[4] = {0x00, 0x60, 0x00, 0x20};
399 u8 fifo; 399 u8 fifo;
400 400
401 pci_read_config_byte(pdev, 0x43, &fifo); 401 pci_read_config_byte(pdev, 0x43, &fifo);
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index 0d316eb3c214..f6d498e1cf80 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -270,14 +270,6 @@ static const struct pci_device_id nv_pci_tbl[] = {
270 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA), GENERIC }, 270 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA), GENERIC },
271 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2), GENERIC }, 271 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2), GENERIC },
272 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3), GENERIC }, 272 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3), GENERIC },
273 { PCI_VDEVICE(NVIDIA, 0x045c), GENERIC }, /* MCP65 */
274 { PCI_VDEVICE(NVIDIA, 0x045d), GENERIC }, /* MCP65 */
275 { PCI_VDEVICE(NVIDIA, 0x045e), GENERIC }, /* MCP65 */
276 { PCI_VDEVICE(NVIDIA, 0x045f), GENERIC }, /* MCP65 */
277 { PCI_VDEVICE(NVIDIA, 0x0550), GENERIC }, /* MCP67 */
278 { PCI_VDEVICE(NVIDIA, 0x0551), GENERIC }, /* MCP67 */
279 { PCI_VDEVICE(NVIDIA, 0x0552), GENERIC }, /* MCP67 */
280 { PCI_VDEVICE(NVIDIA, 0x0553), GENERIC }, /* MCP67 */
281 { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, 273 { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
282 PCI_ANY_ID, PCI_ANY_ID, 274 PCI_ANY_ID, PCI_ANY_ID,
283 PCI_CLASS_STORAGE_IDE<<8, 0xffff00, GENERIC }, 275 PCI_CLASS_STORAGE_IDE<<8, 0xffff00, GENERIC },
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c
index d89c9590b845..46d8a94669b4 100644
--- a/drivers/ata/sata_svw.c
+++ b/drivers/ata/sata_svw.c
@@ -135,26 +135,31 @@ static void k2_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
135 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; 135 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
136 136
137 if (tf->ctl != ap->last_ctl) { 137 if (tf->ctl != ap->last_ctl) {
138 writeb(tf->ctl, ioaddr->ctl_addr); 138 writeb(tf->ctl, (void __iomem *) ioaddr->ctl_addr);
139 ap->last_ctl = tf->ctl; 139 ap->last_ctl = tf->ctl;
140 ata_wait_idle(ap); 140 ata_wait_idle(ap);
141 } 141 }
142 if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) { 142 if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) {
143 writew(tf->feature | (((u16)tf->hob_feature) << 8), ioaddr->feature_addr); 143 writew(tf->feature | (((u16)tf->hob_feature) << 8),
144 writew(tf->nsect | (((u16)tf->hob_nsect) << 8), ioaddr->nsect_addr); 144 (void __iomem *) ioaddr->feature_addr);
145 writew(tf->lbal | (((u16)tf->hob_lbal) << 8), ioaddr->lbal_addr); 145 writew(tf->nsect | (((u16)tf->hob_nsect) << 8),
146 writew(tf->lbam | (((u16)tf->hob_lbam) << 8), ioaddr->lbam_addr); 146 (void __iomem *) ioaddr->nsect_addr);
147 writew(tf->lbah | (((u16)tf->hob_lbah) << 8), ioaddr->lbah_addr); 147 writew(tf->lbal | (((u16)tf->hob_lbal) << 8),
148 (void __iomem *) ioaddr->lbal_addr);
149 writew(tf->lbam | (((u16)tf->hob_lbam) << 8),
150 (void __iomem *) ioaddr->lbam_addr);
151 writew(tf->lbah | (((u16)tf->hob_lbah) << 8),
152 (void __iomem *) ioaddr->lbah_addr);
148 } else if (is_addr) { 153 } else if (is_addr) {
149 writew(tf->feature, ioaddr->feature_addr); 154 writew(tf->feature, (void __iomem *) ioaddr->feature_addr);
150 writew(tf->nsect, ioaddr->nsect_addr); 155 writew(tf->nsect, (void __iomem *) ioaddr->nsect_addr);
151 writew(tf->lbal, ioaddr->lbal_addr); 156 writew(tf->lbal, (void __iomem *) ioaddr->lbal_addr);
152 writew(tf->lbam, ioaddr->lbam_addr); 157 writew(tf->lbam, (void __iomem *) ioaddr->lbam_addr);
153 writew(tf->lbah, ioaddr->lbah_addr); 158 writew(tf->lbah, (void __iomem *) ioaddr->lbah_addr);
154 } 159 }
155 160
156 if (tf->flags & ATA_TFLAG_DEVICE) 161 if (tf->flags & ATA_TFLAG_DEVICE)
157 writeb(tf->device, ioaddr->device_addr); 162 writeb(tf->device, (void __iomem *) ioaddr->device_addr);
158 163
159 ata_wait_idle(ap); 164 ata_wait_idle(ap);
160} 165}
@@ -166,12 +171,12 @@ static void k2_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
166 u16 nsect, lbal, lbam, lbah, feature; 171 u16 nsect, lbal, lbam, lbah, feature;
167 172
168 tf->command = k2_stat_check_status(ap); 173 tf->command = k2_stat_check_status(ap);
169 tf->device = readw(ioaddr->device_addr); 174 tf->device = readw((void __iomem *)ioaddr->device_addr);
170 feature = readw(ioaddr->error_addr); 175 feature = readw((void __iomem *)ioaddr->error_addr);
171 nsect = readw(ioaddr->nsect_addr); 176 nsect = readw((void __iomem *)ioaddr->nsect_addr);
172 lbal = readw(ioaddr->lbal_addr); 177 lbal = readw((void __iomem *)ioaddr->lbal_addr);
173 lbam = readw(ioaddr->lbam_addr); 178 lbam = readw((void __iomem *)ioaddr->lbam_addr);
174 lbah = readw(ioaddr->lbah_addr); 179 lbah = readw((void __iomem *)ioaddr->lbah_addr);
175 180
176 tf->feature = feature; 181 tf->feature = feature;
177 tf->nsect = nsect; 182 tf->nsect = nsect;
diff --git a/drivers/ata/sata_vsc.c b/drivers/ata/sata_vsc.c
index e654b990b905..0fa1b89f76d5 100644
--- a/drivers/ata/sata_vsc.c
+++ b/drivers/ata/sata_vsc.c
@@ -149,21 +149,26 @@ static void vsc_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
149 vsc_intr_mask_update(ap, tf->ctl & ATA_NIEN); 149 vsc_intr_mask_update(ap, tf->ctl & ATA_NIEN);
150 } 150 }
151 if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) { 151 if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) {
152 writew(tf->feature | (((u16)tf->hob_feature) << 8), ioaddr->feature_addr); 152 writew(tf->feature | (((u16)tf->hob_feature) << 8),
153 writew(tf->nsect | (((u16)tf->hob_nsect) << 8), ioaddr->nsect_addr); 153 (void __iomem *) ioaddr->feature_addr);
154 writew(tf->lbal | (((u16)tf->hob_lbal) << 8), ioaddr->lbal_addr); 154 writew(tf->nsect | (((u16)tf->hob_nsect) << 8),
155 writew(tf->lbam | (((u16)tf->hob_lbam) << 8), ioaddr->lbam_addr); 155 (void __iomem *) ioaddr->nsect_addr);
156 writew(tf->lbah | (((u16)tf->hob_lbah) << 8), ioaddr->lbah_addr); 156 writew(tf->lbal | (((u16)tf->hob_lbal) << 8),
157 (void __iomem *) ioaddr->lbal_addr);
158 writew(tf->lbam | (((u16)tf->hob_lbam) << 8),
159 (void __iomem *) ioaddr->lbam_addr);
160 writew(tf->lbah | (((u16)tf->hob_lbah) << 8),
161 (void __iomem *) ioaddr->lbah_addr);
157 } else if (is_addr) { 162 } else if (is_addr) {
158 writew(tf->feature, ioaddr->feature_addr); 163 writew(tf->feature, (void __iomem *) ioaddr->feature_addr);
159 writew(tf->nsect, ioaddr->nsect_addr); 164 writew(tf->nsect, (void __iomem *) ioaddr->nsect_addr);
160 writew(tf->lbal, ioaddr->lbal_addr); 165 writew(tf->lbal, (void __iomem *) ioaddr->lbal_addr);
161 writew(tf->lbam, ioaddr->lbam_addr); 166 writew(tf->lbam, (void __iomem *) ioaddr->lbam_addr);
162 writew(tf->lbah, ioaddr->lbah_addr); 167 writew(tf->lbah, (void __iomem *) ioaddr->lbah_addr);
163 } 168 }
164 169
165 if (tf->flags & ATA_TFLAG_DEVICE) 170 if (tf->flags & ATA_TFLAG_DEVICE)
166 writeb(tf->device, ioaddr->device_addr); 171 writeb(tf->device, (void __iomem *) ioaddr->device_addr);
167 172
168 ata_wait_idle(ap); 173 ata_wait_idle(ap);
169} 174}
@@ -175,12 +180,12 @@ static void vsc_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
175 u16 nsect, lbal, lbam, lbah, feature; 180 u16 nsect, lbal, lbam, lbah, feature;
176 181
177 tf->command = ata_check_status(ap); 182 tf->command = ata_check_status(ap);
178 tf->device = readw(ioaddr->device_addr); 183 tf->device = readw((void __iomem *) ioaddr->device_addr);
179 feature = readw(ioaddr->error_addr); 184 feature = readw((void __iomem *) ioaddr->error_addr);
180 nsect = readw(ioaddr->nsect_addr); 185 nsect = readw((void __iomem *) ioaddr->nsect_addr);
181 lbal = readw(ioaddr->lbal_addr); 186 lbal = readw((void __iomem *) ioaddr->lbal_addr);
182 lbam = readw(ioaddr->lbam_addr); 187 lbam = readw((void __iomem *) ioaddr->lbam_addr);
183 lbah = readw(ioaddr->lbah_addr); 188 lbah = readw((void __iomem *) ioaddr->lbah_addr);
184 189
185 tf->feature = feature; 190 tf->feature = feature;
186 tf->nsect = nsect; 191 tf->nsect = nsect;
@@ -327,8 +332,8 @@ static void __devinit vsc_sata_setup_port(struct ata_ioports *port, unsigned lon
327 port->ctl_addr = base + VSC_SATA_TF_CTL_OFFSET; 332 port->ctl_addr = base + VSC_SATA_TF_CTL_OFFSET;
328 port->bmdma_addr = base + VSC_SATA_DMA_CMD_OFFSET; 333 port->bmdma_addr = base + VSC_SATA_DMA_CMD_OFFSET;
329 port->scr_addr = base + VSC_SATA_SCR_STATUS_OFFSET; 334 port->scr_addr = base + VSC_SATA_SCR_STATUS_OFFSET;
330 writel(0, base + VSC_SATA_UP_DESCRIPTOR_OFFSET); 335 writel(0, (void __iomem *) base + VSC_SATA_UP_DESCRIPTOR_OFFSET);
331 writel(0, base + VSC_SATA_UP_DATA_BUFFER_OFFSET); 336 writel(0, (void __iomem *) base + VSC_SATA_UP_DATA_BUFFER_OFFSET);
332} 337}
333 338
334 339