aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/constants.c
diff options
context:
space:
mode:
authorMartin K. Petersen <martin.petersen@oracle.com>2007-02-27 22:39:44 -0500
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2007-03-11 12:14:02 -0400
commit684b7fe976554d12e6266d7280c87a0f3feff02e (patch)
tree42037688e8867faf8e859096985e6e0c19b13474 /drivers/scsi/constants.c
parent862794fa3fd4c8a44ee22582418736c93e0d3c3a (diff)
[SCSI] constants.c: cleanup, verbose result printing
Clean up constants.c and make result printing more user friendly: - Refactor the command and sense functions so that the actual formatting can be called from the various helper functions with the correct prefix. - Replace scsi_print_hostbyte() and scsi_print_driverbyte() with scsi_print_result() which is verbose when CONFIG_SCSI_CONSTANTS is on. Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/constants.c')
-rw-r--r--drivers/scsi/constants.c267
1 files changed, 145 insertions, 122 deletions
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 61f6024b61ba..611487545af4 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -202,31 +202,29 @@ static const char * get_sa_name(const struct value_name_pair * arr,
202} 202}
203 203
204/* attempt to guess cdb length if cdb_len==0 . No trailing linefeed. */ 204/* attempt to guess cdb length if cdb_len==0 . No trailing linefeed. */
205static void print_opcode_name(unsigned char * cdbp, int cdb_len, 205static void print_opcode_name(unsigned char * cdbp, int cdb_len)
206 int start_of_line)
207{ 206{
208 int sa, len, cdb0; 207 int sa, len, cdb0;
209 const char * name; 208 const char * name;
210 const char * leadin = start_of_line ? KERN_INFO : "";
211 209
212 cdb0 = cdbp[0]; 210 cdb0 = cdbp[0];
213 switch(cdb0) { 211 switch(cdb0) {
214 case VARIABLE_LENGTH_CMD: 212 case VARIABLE_LENGTH_CMD:
215 len = cdbp[7] + 8; 213 len = cdbp[7] + 8;
216 if (len < 10) { 214 if (len < 10) {
217 printk("%sshort variable length command, " 215 printk("short variable length command, "
218 "len=%d ext_len=%d", leadin, len, cdb_len); 216 "len=%d ext_len=%d", len, cdb_len);
219 break; 217 break;
220 } 218 }
221 sa = (cdbp[8] << 8) + cdbp[9]; 219 sa = (cdbp[8] << 8) + cdbp[9];
222 name = get_sa_name(maint_in_arr, MAINT_IN_SZ, sa); 220 name = get_sa_name(maint_in_arr, MAINT_IN_SZ, sa);
223 if (name) { 221 if (name) {
224 printk("%s%s", leadin, name); 222 printk("%s", name);
225 if ((cdb_len > 0) && (len != cdb_len)) 223 if ((cdb_len > 0) && (len != cdb_len))
226 printk(", in_cdb_len=%d, ext_len=%d", 224 printk(", in_cdb_len=%d, ext_len=%d",
227 len, cdb_len); 225 len, cdb_len);
228 } else { 226 } else {
229 printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 227 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
230 if ((cdb_len > 0) && (len != cdb_len)) 228 if ((cdb_len > 0) && (len != cdb_len))
231 printk(", in_cdb_len=%d, ext_len=%d", 229 printk(", in_cdb_len=%d, ext_len=%d",
232 len, cdb_len); 230 len, cdb_len);
@@ -236,83 +234,80 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len,
236 sa = cdbp[1] & 0x1f; 234 sa = cdbp[1] & 0x1f;
237 name = get_sa_name(maint_in_arr, MAINT_IN_SZ, sa); 235 name = get_sa_name(maint_in_arr, MAINT_IN_SZ, sa);
238 if (name) 236 if (name)
239 printk("%s%s", leadin, name); 237 printk("%s", name);
240 else 238 else
241 printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 239 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
242 break; 240 break;
243 case MAINTENANCE_OUT: 241 case MAINTENANCE_OUT:
244 sa = cdbp[1] & 0x1f; 242 sa = cdbp[1] & 0x1f;
245 name = get_sa_name(maint_out_arr, MAINT_OUT_SZ, sa); 243 name = get_sa_name(maint_out_arr, MAINT_OUT_SZ, sa);
246 if (name) 244 if (name)
247 printk("%s%s", leadin, name); 245 printk("%s", name);
248 else 246 else
249 printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 247 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
250 break; 248 break;
251 case SERVICE_ACTION_IN_12: 249 case SERVICE_ACTION_IN_12:
252 sa = cdbp[1] & 0x1f; 250 sa = cdbp[1] & 0x1f;
253 name = get_sa_name(serv_in12_arr, SERV_IN12_SZ, sa); 251 name = get_sa_name(serv_in12_arr, SERV_IN12_SZ, sa);
254 if (name) 252 if (name)
255 printk("%s%s", leadin, name); 253 printk("%s", name);
256 else 254 else
257 printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 255 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
258 break; 256 break;
259 case SERVICE_ACTION_OUT_12: 257 case SERVICE_ACTION_OUT_12:
260 sa = cdbp[1] & 0x1f; 258 sa = cdbp[1] & 0x1f;
261 name = get_sa_name(serv_out12_arr, SERV_OUT12_SZ, sa); 259 name = get_sa_name(serv_out12_arr, SERV_OUT12_SZ, sa);
262 if (name) 260 if (name)
263 printk("%s%s", leadin, name); 261 printk("%s", name);
264 else 262 else
265 printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 263 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
266 break; 264 break;
267 case SERVICE_ACTION_IN_16: 265 case SERVICE_ACTION_IN_16:
268 sa = cdbp[1] & 0x1f; 266 sa = cdbp[1] & 0x1f;
269 name = get_sa_name(serv_in16_arr, SERV_IN16_SZ, sa); 267 name = get_sa_name(serv_in16_arr, SERV_IN16_SZ, sa);
270 if (name) 268 if (name)
271 printk("%s%s", leadin, name); 269 printk("%s", name);
272 else 270 else
273 printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 271 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
274 break; 272 break;
275 case SERVICE_ACTION_OUT_16: 273 case SERVICE_ACTION_OUT_16:
276 sa = cdbp[1] & 0x1f; 274 sa = cdbp[1] & 0x1f;
277 name = get_sa_name(serv_out16_arr, SERV_OUT16_SZ, sa); 275 name = get_sa_name(serv_out16_arr, SERV_OUT16_SZ, sa);
278 if (name) 276 if (name)
279 printk("%s%s", leadin, name); 277 printk("%s", name);
280 else 278 else
281 printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 279 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
282 break; 280 break;
283 default: 281 default:
284 if (cdb0 < 0xc0) { 282 if (cdb0 < 0xc0) {
285 name = cdb_byte0_names[cdb0]; 283 name = cdb_byte0_names[cdb0];
286 if (name) 284 if (name)
287 printk("%s%s", leadin, name); 285 printk("%s", name);
288 else 286 else
289 printk("%scdb[0]=0x%x (reserved)", 287 printk("cdb[0]=0x%x (reserved)", cdb0);
290 leadin, cdb0);
291 } else 288 } else
292 printk("%scdb[0]=0x%x (vendor)", leadin, cdb0); 289 printk("cdb[0]=0x%x (vendor)", cdb0);
293 break; 290 break;
294 } 291 }
295} 292}
296 293
297#else /* ifndef CONFIG_SCSI_CONSTANTS */ 294#else /* ifndef CONFIG_SCSI_CONSTANTS */
298 295
299static void print_opcode_name(unsigned char * cdbp, int cdb_len, 296static void print_opcode_name(unsigned char * cdbp, int cdb_len)
300 int start_of_line)
301{ 297{
302 int sa, len, cdb0; 298 int sa, len, cdb0;
303 const char * leadin = start_of_line ? KERN_INFO : "";
304 299
305 cdb0 = cdbp[0]; 300 cdb0 = cdbp[0];
306 switch(cdb0) { 301 switch(cdb0) {
307 case VARIABLE_LENGTH_CMD: 302 case VARIABLE_LENGTH_CMD:
308 len = cdbp[7] + 8; 303 len = cdbp[7] + 8;
309 if (len < 10) { 304 if (len < 10) {
310 printk("%sshort opcode=0x%x command, len=%d " 305 printk("short opcode=0x%x command, len=%d "
311 "ext_len=%d", leadin, cdb0, len, cdb_len); 306 "ext_len=%d", cdb0, len, cdb_len);
312 break; 307 break;
313 } 308 }
314 sa = (cdbp[8] << 8) + cdbp[9]; 309 sa = (cdbp[8] << 8) + cdbp[9];
315 printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 310 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
316 if (len != cdb_len) 311 if (len != cdb_len)
317 printk(", in_cdb_len=%d, ext_len=%d", len, cdb_len); 312 printk(", in_cdb_len=%d, ext_len=%d", len, cdb_len);
318 break; 313 break;
@@ -323,49 +318,48 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len,
323 case SERVICE_ACTION_IN_16: 318 case SERVICE_ACTION_IN_16:
324 case SERVICE_ACTION_OUT_16: 319 case SERVICE_ACTION_OUT_16:
325 sa = cdbp[1] & 0x1f; 320 sa = cdbp[1] & 0x1f;
326 printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 321 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
327 break; 322 break;
328 default: 323 default:
329 if (cdb0 < 0xc0) 324 if (cdb0 < 0xc0)
330 printk("%scdb[0]=0x%x", leadin, cdb0); 325 printk("cdb[0]=0x%x", cdb0);
331 else 326 else
332 printk("%scdb[0]=0x%x (vendor)", leadin, cdb0); 327 printk("cdb[0]=0x%x (vendor)", cdb0);
333 break; 328 break;
334 } 329 }
335} 330}
336#endif 331#endif
337 332
338void __scsi_print_command(unsigned char *command) 333void __scsi_print_command(unsigned char *cdb)
339{ 334{
340 int k, len; 335 int k, len;
341 336
342 print_opcode_name(command, 0, 1); 337 print_opcode_name(cdb, 0);
343 if (VARIABLE_LENGTH_CMD == command[0]) 338 if (VARIABLE_LENGTH_CMD == cdb[0])
344 len = command[7] + 8; 339 len = cdb[7] + 8;
345 else 340 else
346 len = COMMAND_SIZE(command[0]); 341 len = COMMAND_SIZE(cdb[0]);
347 /* print out all bytes in cdb */ 342 /* print out all bytes in cdb */
348 for (k = 0; k < len; ++k) 343 for (k = 0; k < len; ++k)
349 printk(" %02x", command[k]); 344 printk(" %02x", cdb[k]);
350 printk("\n"); 345 printk("\n");
351} 346}
352EXPORT_SYMBOL(__scsi_print_command); 347EXPORT_SYMBOL(__scsi_print_command);
353 348
354/* This function (perhaps with the addition of peripheral device type) 349void scsi_print_command(struct scsi_cmnd *cmd)
355 * is more approriate than __scsi_print_command(). Perhaps that static
356 * can be dropped later if it replaces the __scsi_print_command version.
357 */
358static void scsi_print_cdb(unsigned char *cdb, int cdb_len, int start_of_line)
359{ 350{
360 int k; 351 int k;
361 352
362 print_opcode_name(cdb, cdb_len, start_of_line); 353 scmd_printk(KERN_INFO, cmd, "CDB: ");
354 print_opcode_name(cmd->cmnd, cmd->cmd_len);
355
363 /* print out all bytes in cdb */ 356 /* print out all bytes in cdb */
364 printk(":"); 357 printk(":");
365 for (k = 0; k < cdb_len; ++k) 358 for (k = 0; k < cmd->cmd_len; ++k)
366 printk(" %02x", cdb[k]); 359 printk(" %02x", cmd->cmnd[k]);
367 printk("\n"); 360 printk("\n");
368} 361}
362EXPORT_SYMBOL(scsi_print_command);
369 363
370/** 364/**
371 * 365 *
@@ -1176,67 +1170,77 @@ scsi_extd_sense_format(unsigned char asc, unsigned char ascq) {
1176} 1170}
1177EXPORT_SYMBOL(scsi_extd_sense_format); 1171EXPORT_SYMBOL(scsi_extd_sense_format);
1178 1172
1179/* Print extended sense information; no leadin, no linefeed */ 1173void
1180static void
1181scsi_show_extd_sense(unsigned char asc, unsigned char ascq) 1174scsi_show_extd_sense(unsigned char asc, unsigned char ascq)
1182{ 1175{
1183 const char *extd_sense_fmt = scsi_extd_sense_format(asc, ascq); 1176 const char *extd_sense_fmt = scsi_extd_sense_format(asc, ascq);
1184 1177
1185 if (extd_sense_fmt) { 1178 if (extd_sense_fmt) {
1186 if (strstr(extd_sense_fmt, "%x")) { 1179 if (strstr(extd_sense_fmt, "%x")) {
1187 printk("Additional sense: "); 1180 printk("Add. Sense: ");
1188 printk(extd_sense_fmt, ascq); 1181 printk(extd_sense_fmt, ascq);
1189 } else 1182 } else
1190 printk("Additional sense: %s", extd_sense_fmt); 1183 printk("Add. Sense: %s", extd_sense_fmt);
1191 } else { 1184 } else {
1192 if (asc >= 0x80) 1185 if (asc >= 0x80)
1193 printk("<<vendor>> ASC=0x%x ASCQ=0x%x", asc, ascq); 1186 printk("<<vendor>> ASC=0x%x ASCQ=0x%x", asc,
1187 ascq);
1194 if (ascq >= 0x80) 1188 if (ascq >= 0x80)
1195 printk("ASC=0x%x <<vendor>> ASCQ=0x%x", asc, ascq); 1189 printk("ASC=0x%x <<vendor>> ASCQ=0x%x", asc,
1190 ascq);
1196 else 1191 else
1197 printk("ASC=0x%x ASCQ=0x%x", asc, ascq); 1192 printk("ASC=0x%x ASCQ=0x%x", asc, ascq);
1198 } 1193 }
1194
1195 printk("\n");
1199} 1196}
1197EXPORT_SYMBOL(scsi_show_extd_sense);
1200 1198
1201void 1199void
1202scsi_print_sense_hdr(const char *name, struct scsi_sense_hdr *sshdr) 1200scsi_show_sense_hdr(struct scsi_sense_hdr *sshdr)
1203{ 1201{
1204 const char *sense_txt; 1202 const char *sense_txt;
1205 /* An example of deferred is when an earlier write to disk cache
1206 * succeeded, but now the disk discovers that it cannot write the
1207 * data to the magnetic media.
1208 */
1209 const char *error = scsi_sense_is_deferred(sshdr) ?
1210 "<<DEFERRED>>" : "Current";
1211 printk(KERN_INFO "%s: %s", name, error);
1212 if (sshdr->response_code >= 0x72)
1213 printk(" [descriptor]");
1214 1203
1215 sense_txt = scsi_sense_key_string(sshdr->sense_key); 1204 sense_txt = scsi_sense_key_string(sshdr->sense_key);
1216 if (sense_txt) 1205 if (sense_txt)
1217 printk(": sense key: %s\n", sense_txt); 1206 printk("Sense Key : %s ", sense_txt);
1218 else 1207 else
1219 printk(": sense key=0x%x\n", sshdr->sense_key); 1208 printk("Sense Key : 0x%x ", sshdr->sense_key);
1220 printk(KERN_INFO " "); 1209
1221 scsi_show_extd_sense(sshdr->asc, sshdr->ascq); 1210 printk("%s", scsi_sense_is_deferred(sshdr) ? "[deferred] " :
1211 "[current] ");
1212
1213 if (sshdr->response_code >= 0x72)
1214 printk("[descriptor]");
1215
1222 printk("\n"); 1216 printk("\n");
1223} 1217}
1218EXPORT_SYMBOL(scsi_show_sense_hdr);
1219
1220/*
1221 * Print normalized SCSI sense header with a prefix.
1222 */
1223void
1224scsi_print_sense_hdr(const char *name, struct scsi_sense_hdr *sshdr)
1225{
1226 printk(KERN_INFO "%s: ", name);
1227 scsi_show_sense_hdr(sshdr);
1228 printk(KERN_INFO "%s: ", name);
1229 scsi_show_extd_sense(sshdr->asc, sshdr->ascq);
1230}
1224EXPORT_SYMBOL(scsi_print_sense_hdr); 1231EXPORT_SYMBOL(scsi_print_sense_hdr);
1225 1232
1226/* Print sense information */
1227void 1233void
1228__scsi_print_sense(const char *name, const unsigned char *sense_buffer, 1234scsi_decode_sense_buffer(const unsigned char *sense_buffer, int sense_len,
1229 int sense_len) 1235 struct scsi_sense_hdr *sshdr)
1230{ 1236{
1231 int k, num, res; 1237 int k, num, res;
1232 unsigned int info;
1233 struct scsi_sense_hdr ssh;
1234 1238
1235 res = scsi_normalize_sense(sense_buffer, sense_len, &ssh); 1239 res = scsi_normalize_sense(sense_buffer, sense_len, sshdr);
1236 if (0 == res) { 1240 if (0 == res) {
1237 /* this may be SCSI-1 sense data */ 1241 /* this may be SCSI-1 sense data */
1238 num = (sense_len < 32) ? sense_len : 32; 1242 num = (sense_len < 32) ? sense_len : 32;
1239 printk(KERN_INFO "Unrecognized sense data (in hex):"); 1243 printk("Unrecognized sense data (in hex):");
1240 for (k = 0; k < num; ++k) { 1244 for (k = 0; k < num; ++k) {
1241 if (0 == (k % 16)) { 1245 if (0 == (k % 16)) {
1242 printk("\n"); 1246 printk("\n");
@@ -1247,11 +1251,20 @@ __scsi_print_sense(const char *name, const unsigned char *sense_buffer,
1247 printk("\n"); 1251 printk("\n");
1248 return; 1252 return;
1249 } 1253 }
1250 scsi_print_sense_hdr(name, &ssh); 1254}
1251 if (ssh.response_code < 0x72) { 1255
1256void
1257scsi_decode_sense_extras(const unsigned char *sense_buffer, int sense_len,
1258 struct scsi_sense_hdr *sshdr)
1259{
1260 int k, num, res;
1261
1262 if (sshdr->response_code < 0x72)
1263 {
1252 /* only decode extras for "fixed" format now */ 1264 /* only decode extras for "fixed" format now */
1253 char buff[80]; 1265 char buff[80];
1254 int blen, fixed_valid; 1266 int blen, fixed_valid;
1267 unsigned int info;
1255 1268
1256 fixed_valid = sense_buffer[0] & 0x80; 1269 fixed_valid = sense_buffer[0] & 0x80;
1257 info = ((sense_buffer[3] << 24) | (sense_buffer[4] << 16) | 1270 info = ((sense_buffer[3] << 24) | (sense_buffer[4] << 16) |
@@ -1281,13 +1294,13 @@ __scsi_print_sense(const char *name, const unsigned char *sense_buffer,
1281 res += snprintf(buff + res, blen - res, "ILI"); 1294 res += snprintf(buff + res, blen - res, "ILI");
1282 } 1295 }
1283 if (res > 0) 1296 if (res > 0)
1284 printk(KERN_INFO "%s\n", buff); 1297 printk("%s\n", buff);
1285 } else if (ssh.additional_length > 0) { 1298 } else if (sshdr->additional_length > 0) {
1286 /* descriptor format with sense descriptors */ 1299 /* descriptor format with sense descriptors */
1287 num = 8 + ssh.additional_length; 1300 num = 8 + sshdr->additional_length;
1288 num = (sense_len < num) ? sense_len : num; 1301 num = (sense_len < num) ? sense_len : num;
1289 printk(KERN_INFO "Descriptor sense data with sense " 1302 printk("Descriptor sense data with sense descriptors "
1290 "descriptors (in hex):"); 1303 "(in hex):");
1291 for (k = 0; k < num; ++k) { 1304 for (k = 0; k < num; ++k) {
1292 if (0 == (k % 16)) { 1305 if (0 == (k % 16)) {
1293 printk("\n"); 1306 printk("\n");
@@ -1295,29 +1308,42 @@ __scsi_print_sense(const char *name, const unsigned char *sense_buffer,
1295 } 1308 }
1296 printk("%02x ", sense_buffer[k]); 1309 printk("%02x ", sense_buffer[k]);
1297 } 1310 }
1311
1298 printk("\n"); 1312 printk("\n");
1299 } 1313 }
1314
1300} 1315}
1301EXPORT_SYMBOL(__scsi_print_sense);
1302 1316
1303void scsi_print_sense(const char *devclass, struct scsi_cmnd *cmd) 1317/* Normalize and print sense buffer with name prefix */
1318void __scsi_print_sense(const char *name, const unsigned char *sense_buffer,
1319 int sense_len)
1304{ 1320{
1305 const char *name = devclass; 1321 struct scsi_sense_hdr sshdr;
1306 1322
1307 if (cmd->request->rq_disk) 1323 printk(KERN_INFO "%s: ", name);
1308 name = cmd->request->rq_disk->disk_name; 1324 scsi_decode_sense_buffer(sense_buffer, sense_len, &sshdr);
1309 __scsi_print_sense(name, cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE); 1325 scsi_show_sense_hdr(&sshdr);
1326 scsi_decode_sense_extras(sense_buffer, sense_len, &sshdr);
1327 printk(KERN_INFO "%s: ", name);
1328 scsi_show_extd_sense(sshdr.asc, sshdr.ascq);
1310} 1329}
1311EXPORT_SYMBOL(scsi_print_sense); 1330EXPORT_SYMBOL(__scsi_print_sense);
1312 1331
1313void scsi_print_command(struct scsi_cmnd *cmd) 1332/* Normalize and print sense buffer in SCSI command */
1333void scsi_print_sense(char *name, struct scsi_cmnd *cmd)
1314{ 1334{
1315 /* Assume appended output (i.e. not at start of line) */ 1335 struct scsi_sense_hdr sshdr;
1316 sdev_printk("", cmd->device, "\n"); 1336
1317 printk(KERN_INFO " command: "); 1337 scmd_printk(KERN_INFO, cmd, "");
1318 scsi_print_cdb(cmd->cmnd, cmd->cmd_len, 0); 1338 scsi_decode_sense_buffer(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE,
1339 &sshdr);
1340 scsi_show_sense_hdr(&sshdr);
1341 scsi_decode_sense_extras(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE,
1342 &sshdr);
1343 scmd_printk(KERN_INFO, cmd, "");
1344 scsi_show_extd_sense(sshdr.asc, sshdr.ascq);
1319} 1345}
1320EXPORT_SYMBOL(scsi_print_command); 1346EXPORT_SYMBOL(scsi_print_sense);
1321 1347
1322#ifdef CONFIG_SCSI_CONSTANTS 1348#ifdef CONFIG_SCSI_CONSTANTS
1323 1349
@@ -1327,25 +1353,6 @@ static const char * const hostbyte_table[]={
1327"DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY"}; 1353"DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY"};
1328#define NUM_HOSTBYTE_STRS ARRAY_SIZE(hostbyte_table) 1354#define NUM_HOSTBYTE_STRS ARRAY_SIZE(hostbyte_table)
1329 1355
1330void scsi_print_hostbyte(int scsiresult)
1331{
1332 int hb = host_byte(scsiresult);
1333
1334 printk("Hostbyte=0x%02x", hb);
1335 if (hb < NUM_HOSTBYTE_STRS)
1336 printk("(%s) ", hostbyte_table[hb]);
1337 else
1338 printk("is invalid ");
1339}
1340#else
1341void scsi_print_hostbyte(int scsiresult)
1342{
1343 printk("Hostbyte=0x%02x ", host_byte(scsiresult));
1344}
1345#endif
1346
1347#ifdef CONFIG_SCSI_CONSTANTS
1348
1349static const char * const driverbyte_table[]={ 1356static const char * const driverbyte_table[]={
1350"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR", 1357"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR",
1351"DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"}; 1358"DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"};
@@ -1356,19 +1363,35 @@ static const char * const driversuggest_table[]={"SUGGEST_OK",
1356"SUGGEST_5", "SUGGEST_6", "SUGGEST_7", "SUGGEST_SENSE"}; 1363"SUGGEST_5", "SUGGEST_6", "SUGGEST_7", "SUGGEST_SENSE"};
1357#define NUM_SUGGEST_STRS ARRAY_SIZE(driversuggest_table) 1364#define NUM_SUGGEST_STRS ARRAY_SIZE(driversuggest_table)
1358 1365
1359void scsi_print_driverbyte(int scsiresult) 1366void scsi_show_result(int result)
1360{ 1367{
1361 int dr = (driver_byte(scsiresult) & DRIVER_MASK); 1368 int hb = host_byte(result);
1362 int su = ((driver_byte(scsiresult) & SUGGEST_MASK) >> 4); 1369 int db = (driver_byte(result) & DRIVER_MASK);
1370 int su = ((driver_byte(result) & SUGGEST_MASK) >> 4);
1363 1371
1364 printk("Driverbyte=0x%02x ", driver_byte(scsiresult)); 1372 printk("Result: hostbyte=%s driverbyte=%s,%s\n",
1365 printk("(%s,%s) ", 1373 (hb < NUM_HOSTBYTE_STRS ? hostbyte_table[hb] : "invalid"),
1366 (dr < NUM_DRIVERBYTE_STRS ? driverbyte_table[dr] : "invalid"), 1374 (db < NUM_DRIVERBYTE_STRS ? driverbyte_table[db] : "invalid"),
1367 (su < NUM_SUGGEST_STRS ? driversuggest_table[su] : "invalid")); 1375 (su < NUM_SUGGEST_STRS ? driversuggest_table[su] : "invalid"));
1368} 1376}
1377
1369#else 1378#else
1370void scsi_print_driverbyte(int scsiresult) 1379
1380void scsi_show_result(int result)
1371{ 1381{
1372 printk("Driverbyte=0x%02x ", driver_byte(scsiresult)); 1382 printk("Result: hostbyte=0x%02x driverbyte=0x%02x\n",
1383 host_byte(result), driver_byte(result));
1373} 1384}
1385
1374#endif 1386#endif
1387EXPORT_SYMBOL(scsi_show_result);
1388
1389
1390void scsi_print_result(struct scsi_cmnd *cmd)
1391{
1392 scmd_printk(KERN_INFO, cmd, "");
1393 scsi_show_result(cmd->result);
1394}
1395EXPORT_SYMBOL(scsi_print_result);
1396
1397