diff options
author | Ondrej Zary <linux@rainbow-software.org> | 2015-02-06 17:11:37 -0500 |
---|---|---|
committer | James Bottomley <JBottomley@Odin.com> | 2015-04-09 21:07:42 -0400 |
commit | 8537cba8b6e14ff86f088dd71592090606c97050 (patch) | |
tree | 868c23f351d6430f1c1762e1cf94ebbd67680824 /drivers/scsi | |
parent | dfd7c991f31261fb4fb14adf0479206b178d270d (diff) |
aha1542: Merge aha1542_host_reset and aha1542_bus_reset
aha1542_host_reset and aha1542_bus_reset are almost same, merge them
into aha1542_reset
Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: James Bottomley <JBottomley@Odin.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/aha1542.c | 82 |
1 files changed, 14 insertions, 68 deletions
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 67fdd2fad9a7..4bfba454a032 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c | |||
@@ -1070,7 +1070,7 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt) | |||
1070 | return SUCCESS; | 1070 | return SUCCESS; |
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | static int aha1542_bus_reset(Scsi_Cmnd * SCpnt) | 1073 | static int aha1542_reset(Scsi_Cmnd *SCpnt, u8 reset_cmd) |
1074 | { | 1074 | { |
1075 | struct aha1542_hostdata *aha1542 = shost_priv(SCpnt->device->host); | 1075 | struct aha1542_hostdata *aha1542 = shost_priv(SCpnt->device->host); |
1076 | int i; | 1076 | int i; |
@@ -1081,7 +1081,7 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt) | |||
1081 | * we do this? Try this first, and we can add that later | 1081 | * we do this? Try this first, and we can add that later |
1082 | * if it turns out to be useful. | 1082 | * if it turns out to be useful. |
1083 | */ | 1083 | */ |
1084 | outb(SCRST, CONTROL(SCpnt->device->host->io_port)); | 1084 | outb(reset_cmd, CONTROL(SCpnt->device->host->io_port)); |
1085 | 1085 | ||
1086 | /* | 1086 | /* |
1087 | * Wait for the thing to settle down a bit. Unfortunately | 1087 | * Wait for the thing to settle down a bit. Unfortunately |
@@ -1091,7 +1091,6 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt) | |||
1091 | * we are pretty desperate anyways. | 1091 | * we are pretty desperate anyways. |
1092 | */ | 1092 | */ |
1093 | ssleep(4); | 1093 | ssleep(4); |
1094 | |||
1095 | spin_lock_irq(SCpnt->device->host->host_lock); | 1094 | spin_lock_irq(SCpnt->device->host->host_lock); |
1096 | 1095 | ||
1097 | if (!wait_mask(STATUS(SCpnt->device->host->io_port), | 1096 | if (!wait_mask(STATUS(SCpnt->device->host->io_port), |
@@ -1099,7 +1098,12 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt) | |||
1099 | spin_unlock_irq(SCpnt->device->host->host_lock); | 1098 | spin_unlock_irq(SCpnt->device->host->host_lock); |
1100 | return FAILED; | 1099 | return FAILED; |
1101 | } | 1100 | } |
1102 | 1101 | /* | |
1102 | * We need to do this too before the 1542 can interact with | ||
1103 | * us again after host reset. | ||
1104 | */ | ||
1105 | if (reset_cmd & HRST) | ||
1106 | setup_mailboxes(SCpnt->device->host->io_port, SCpnt->device->host); | ||
1103 | /* | 1107 | /* |
1104 | * Now try to pick up the pieces. For all pending commands, | 1108 | * Now try to pick up the pieces. For all pending commands, |
1105 | * free any internal data structures, and basically clear things | 1109 | * free any internal data structures, and basically clear things |
@@ -1113,7 +1117,6 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt) | |||
1113 | Scsi_Cmnd *SCtmp; | 1117 | Scsi_Cmnd *SCtmp; |
1114 | SCtmp = aha1542->SCint[i]; | 1118 | SCtmp = aha1542->SCint[i]; |
1115 | 1119 | ||
1116 | |||
1117 | if (SCtmp->device->soft_reset) { | 1120 | if (SCtmp->device->soft_reset) { |
1118 | /* | 1121 | /* |
1119 | * If this device implements the soft reset option, | 1122 | * If this device implements the soft reset option, |
@@ -1134,71 +1137,14 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt) | |||
1134 | return SUCCESS; | 1137 | return SUCCESS; |
1135 | } | 1138 | } |
1136 | 1139 | ||
1137 | static int aha1542_host_reset(Scsi_Cmnd * SCpnt) | 1140 | static int aha1542_bus_reset(Scsi_Cmnd *SCpnt) |
1138 | { | 1141 | { |
1139 | struct aha1542_hostdata *aha1542 = shost_priv(SCpnt->device->host); | 1142 | return aha1542_reset(SCpnt, SCRST); |
1140 | int i; | 1143 | } |
1141 | |||
1142 | /* | ||
1143 | * This does a scsi reset for all devices on the bus. | ||
1144 | * In principle, we could also reset the 1542 - should | ||
1145 | * we do this? Try this first, and we can add that later | ||
1146 | * if it turns out to be useful. | ||
1147 | */ | ||
1148 | outb(HRST | SCRST, CONTROL(SCpnt->device->host->io_port)); | ||
1149 | |||
1150 | /* | ||
1151 | * Wait for the thing to settle down a bit. Unfortunately | ||
1152 | * this is going to basically lock up the machine while we | ||
1153 | * wait for this to complete. To be 100% correct, we need to | ||
1154 | * check for timeout, and if we are doing something like this | ||
1155 | * we are pretty desperate anyways. | ||
1156 | */ | ||
1157 | ssleep(4); | ||
1158 | spin_lock_irq(SCpnt->device->host->host_lock); | ||
1159 | |||
1160 | if (!wait_mask(STATUS(SCpnt->device->host->io_port), | ||
1161 | STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF, 0)) { | ||
1162 | spin_unlock_irq(SCpnt->device->host->host_lock); | ||
1163 | return FAILED; | ||
1164 | } | ||
1165 | /* | ||
1166 | * We need to do this too before the 1542 can interact with | ||
1167 | * us again. | ||
1168 | */ | ||
1169 | setup_mailboxes(SCpnt->device->host->io_port, SCpnt->device->host); | ||
1170 | |||
1171 | /* | ||
1172 | * Now try to pick up the pieces. For all pending commands, | ||
1173 | * free any internal data structures, and basically clear things | ||
1174 | * out. We do not try and restart any commands or anything - | ||
1175 | * the strategy handler takes care of that crap. | ||
1176 | */ | ||
1177 | printk(KERN_WARNING "Sent BUS RESET to scsi host %d\n", SCpnt->device->host->host_no); | ||
1178 | |||
1179 | for (i = 0; i < AHA1542_MAILBOXES; i++) { | ||
1180 | if (aha1542->SCint[i] != NULL) { | ||
1181 | Scsi_Cmnd *SCtmp; | ||
1182 | SCtmp = aha1542->SCint[i]; | ||
1183 | |||
1184 | if (SCtmp->device->soft_reset) { | ||
1185 | /* | ||
1186 | * If this device implements the soft reset option, | ||
1187 | * then it is still holding onto the command, and | ||
1188 | * may yet complete it. In this case, we don't | ||
1189 | * flush the data. | ||
1190 | */ | ||
1191 | continue; | ||
1192 | } | ||
1193 | kfree(SCtmp->host_scribble); | ||
1194 | SCtmp->host_scribble = NULL; | ||
1195 | aha1542->SCint[i] = NULL; | ||
1196 | aha1542->mb[i].status = 0; | ||
1197 | } | ||
1198 | } | ||
1199 | 1144 | ||
1200 | spin_unlock_irq(SCpnt->device->host->host_lock); | 1145 | static int aha1542_host_reset(Scsi_Cmnd *SCpnt) |
1201 | return SUCCESS; | 1146 | { |
1147 | return aha1542_reset(SCpnt, HRST | SCRST); | ||
1202 | } | 1148 | } |
1203 | 1149 | ||
1204 | static int aha1542_biosparam(struct scsi_device *sdev, | 1150 | static int aha1542_biosparam(struct scsi_device *sdev, |