diff options
Diffstat (limited to 'drivers/scsi/constants.c')
-rw-r--r-- | drivers/scsi/constants.c | 120 |
1 files changed, 60 insertions, 60 deletions
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 2f447075adbb..9065b6f8f51b 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c | |||
@@ -1292,18 +1292,19 @@ static const struct error_info additional[] = | |||
1292 | 1292 | ||
1293 | struct error_info2 { | 1293 | struct error_info2 { |
1294 | unsigned char code1, code2_min, code2_max; | 1294 | unsigned char code1, code2_min, code2_max; |
1295 | const char * str; | ||
1295 | const char * fmt; | 1296 | const char * fmt; |
1296 | }; | 1297 | }; |
1297 | 1298 | ||
1298 | static const struct error_info2 additional2[] = | 1299 | static const struct error_info2 additional2[] = |
1299 | { | 1300 | { |
1300 | {0x40, 0x00, 0x7f, "Ram failure (%x)"}, | 1301 | {0x40, 0x00, 0x7f, "Ram failure", ""}, |
1301 | {0x40, 0x80, 0xff, "Diagnostic failure on component (%x)"}, | 1302 | {0x40, 0x80, 0xff, "Diagnostic failure on component", ""}, |
1302 | {0x41, 0x00, 0xff, "Data path failure (%x)"}, | 1303 | {0x41, 0x00, 0xff, "Data path failure", ""}, |
1303 | {0x42, 0x00, 0xff, "Power-on or self-test failure (%x)"}, | 1304 | {0x42, 0x00, 0xff, "Power-on or self-test failure", ""}, |
1304 | {0x4D, 0x00, 0xff, "Tagged overlapped commands (task tag %x)"}, | 1305 | {0x4D, 0x00, 0xff, "Tagged overlapped commands", "task tag "}, |
1305 | {0x70, 0x00, 0xff, "Decompression exception short algorithm id of %x"}, | 1306 | {0x70, 0x00, 0xff, "Decompression exception", "short algorithm id of "}, |
1306 | {0, 0, 0, NULL} | 1307 | {0, 0, 0, NULL, NULL} |
1307 | }; | 1308 | }; |
1308 | 1309 | ||
1309 | /* description of the sense key values */ | 1310 | /* description of the sense key values */ |
@@ -1349,7 +1350,8 @@ EXPORT_SYMBOL(scsi_sense_key_string); | |||
1349 | * This string may contain a "%x" and should be printed with ascq as arg. | 1350 | * This string may contain a "%x" and should be printed with ascq as arg. |
1350 | */ | 1351 | */ |
1351 | const char * | 1352 | const char * |
1352 | scsi_extd_sense_format(unsigned char asc, unsigned char ascq) { | 1353 | scsi_extd_sense_format(unsigned char asc, unsigned char ascq, const char **fmt) |
1354 | { | ||
1353 | #ifdef CONFIG_SCSI_CONSTANTS | 1355 | #ifdef CONFIG_SCSI_CONSTANTS |
1354 | int i; | 1356 | int i; |
1355 | unsigned short code = ((asc << 8) | ascq); | 1357 | unsigned short code = ((asc << 8) | ascq); |
@@ -1360,8 +1362,10 @@ scsi_extd_sense_format(unsigned char asc, unsigned char ascq) { | |||
1360 | for (i = 0; additional2[i].fmt; i++) { | 1362 | for (i = 0; additional2[i].fmt; i++) { |
1361 | if (additional2[i].code1 == asc && | 1363 | if (additional2[i].code1 == asc && |
1362 | ascq >= additional2[i].code2_min && | 1364 | ascq >= additional2[i].code2_min && |
1363 | ascq <= additional2[i].code2_max) | 1365 | ascq <= additional2[i].code2_max) { |
1364 | return additional2[i].fmt; | 1366 | *fmt = additional2[i].fmt; |
1367 | return additional2[i].str; | ||
1368 | } | ||
1365 | } | 1369 | } |
1366 | #endif | 1370 | #endif |
1367 | return NULL; | 1371 | return NULL; |
@@ -1369,49 +1373,53 @@ scsi_extd_sense_format(unsigned char asc, unsigned char ascq) { | |||
1369 | EXPORT_SYMBOL(scsi_extd_sense_format); | 1373 | EXPORT_SYMBOL(scsi_extd_sense_format); |
1370 | 1374 | ||
1371 | void | 1375 | void |
1372 | scsi_show_extd_sense(unsigned char asc, unsigned char ascq) | 1376 | scsi_show_extd_sense(const struct scsi_device *sdev, const char *name, |
1377 | unsigned char asc, unsigned char ascq) | ||
1373 | { | 1378 | { |
1374 | const char *extd_sense_fmt = scsi_extd_sense_format(asc, ascq); | 1379 | const char *extd_sense_fmt = NULL; |
1380 | const char *extd_sense_str = scsi_extd_sense_format(asc, ascq, | ||
1381 | &extd_sense_fmt); | ||
1382 | |||
1383 | if (extd_sense_str) { | ||
1384 | if (extd_sense_fmt) | ||
1385 | sdev_prefix_printk(KERN_INFO, sdev, name, | ||
1386 | "Add. Sense: %s (%s%x)", | ||
1387 | extd_sense_str, extd_sense_fmt, | ||
1388 | ascq); | ||
1389 | else | ||
1390 | sdev_prefix_printk(KERN_INFO, sdev, name, | ||
1391 | "Add. Sense: %s", extd_sense_str); | ||
1375 | 1392 | ||
1376 | if (extd_sense_fmt) { | ||
1377 | if (strstr(extd_sense_fmt, "%x")) { | ||
1378 | printk("Add. Sense: "); | ||
1379 | printk(extd_sense_fmt, ascq); | ||
1380 | } else | ||
1381 | printk("Add. Sense: %s", extd_sense_fmt); | ||
1382 | } else { | 1393 | } else { |
1383 | if (asc >= 0x80) | 1394 | sdev_prefix_printk(KERN_INFO, sdev, name, |
1384 | printk("<<vendor>> ASC=0x%x ASCQ=0x%x", asc, | 1395 | "%sASC=0x%x %sASCQ=0x%x\n", |
1385 | ascq); | 1396 | asc >= 0x80 ? "<<vendor>> " : "", asc, |
1386 | if (ascq >= 0x80) | 1397 | ascq >= 0x80 ? "<<vendor>> " : "", ascq); |
1387 | printk("ASC=0x%x <<vendor>> ASCQ=0x%x", asc, | ||
1388 | ascq); | ||
1389 | else | ||
1390 | printk("ASC=0x%x ASCQ=0x%x", asc, ascq); | ||
1391 | } | 1398 | } |
1392 | |||
1393 | printk("\n"); | ||
1394 | } | 1399 | } |
1395 | EXPORT_SYMBOL(scsi_show_extd_sense); | 1400 | EXPORT_SYMBOL(scsi_show_extd_sense); |
1396 | 1401 | ||
1397 | void | 1402 | void |
1398 | scsi_show_sense_hdr(struct scsi_sense_hdr *sshdr) | 1403 | scsi_show_sense_hdr(const struct scsi_device *sdev, const char *name, |
1404 | const struct scsi_sense_hdr *sshdr) | ||
1399 | { | 1405 | { |
1400 | const char *sense_txt; | 1406 | const char *sense_txt; |
1401 | 1407 | ||
1402 | sense_txt = scsi_sense_key_string(sshdr->sense_key); | 1408 | sense_txt = scsi_sense_key_string(sshdr->sense_key); |
1403 | if (sense_txt) | 1409 | if (sense_txt) |
1404 | printk("Sense Key : %s ", sense_txt); | 1410 | sdev_prefix_printk(KERN_INFO, sdev, name, |
1411 | "Sense Key : %s [%s]%s\n", sense_txt, | ||
1412 | scsi_sense_is_deferred(sshdr) ? | ||
1413 | "deferred" : "current", | ||
1414 | sshdr->response_code >= 0x72 ? | ||
1415 | " [descriptor]" : ""); | ||
1405 | else | 1416 | else |
1406 | printk("Sense Key : 0x%x ", sshdr->sense_key); | 1417 | sdev_prefix_printk(KERN_INFO, sdev, name, |
1407 | 1418 | "Sense Key : 0x%x [%s]%s", sshdr->sense_key, | |
1408 | printk("%s", scsi_sense_is_deferred(sshdr) ? "[deferred] " : | 1419 | scsi_sense_is_deferred(sshdr) ? |
1409 | "[current] "); | 1420 | "deferred" : "current", |
1410 | 1421 | sshdr->response_code >= 0x72 ? | |
1411 | if (sshdr->response_code >= 0x72) | 1422 | " [descriptor]" : ""); |
1412 | printk("[descriptor]"); | ||
1413 | |||
1414 | printk("\n"); | ||
1415 | } | 1423 | } |
1416 | EXPORT_SYMBOL(scsi_show_sense_hdr); | 1424 | EXPORT_SYMBOL(scsi_show_sense_hdr); |
1417 | 1425 | ||
@@ -1419,12 +1427,11 @@ EXPORT_SYMBOL(scsi_show_sense_hdr); | |||
1419 | * Print normalized SCSI sense header with a prefix. | 1427 | * Print normalized SCSI sense header with a prefix. |
1420 | */ | 1428 | */ |
1421 | void | 1429 | void |
1422 | scsi_print_sense_hdr(const char *name, struct scsi_sense_hdr *sshdr) | 1430 | scsi_print_sense_hdr(const struct scsi_device *sdev, const char *name, |
1431 | const struct scsi_sense_hdr *sshdr) | ||
1423 | { | 1432 | { |
1424 | printk(KERN_INFO "%s: ", name); | 1433 | scsi_show_sense_hdr(sdev, name, sshdr); |
1425 | scsi_show_sense_hdr(sshdr); | 1434 | scsi_show_extd_sense(sdev, name, sshdr->asc, sshdr->ascq); |
1426 | printk(KERN_INFO "%s: ", name); | ||
1427 | scsi_show_extd_sense(sshdr->asc, sshdr->ascq); | ||
1428 | } | 1435 | } |
1429 | EXPORT_SYMBOL(scsi_print_sense_hdr); | 1436 | EXPORT_SYMBOL(scsi_print_sense_hdr); |
1430 | 1437 | ||
@@ -1513,33 +1520,26 @@ scsi_decode_sense_extras(const unsigned char *sense_buffer, int sense_len, | |||
1513 | } | 1520 | } |
1514 | 1521 | ||
1515 | /* Normalize and print sense buffer with name prefix */ | 1522 | /* Normalize and print sense buffer with name prefix */ |
1516 | void __scsi_print_sense(const char *name, const unsigned char *sense_buffer, | 1523 | void __scsi_print_sense(const struct scsi_device *sdev, const char *name, |
1517 | int sense_len) | 1524 | const unsigned char *sense_buffer, int sense_len) |
1518 | { | 1525 | { |
1519 | struct scsi_sense_hdr sshdr; | 1526 | struct scsi_sense_hdr sshdr; |
1520 | 1527 | ||
1521 | printk(KERN_INFO "%s: ", name); | ||
1522 | scsi_decode_sense_buffer(sense_buffer, sense_len, &sshdr); | 1528 | scsi_decode_sense_buffer(sense_buffer, sense_len, &sshdr); |
1523 | scsi_show_sense_hdr(&sshdr); | 1529 | scsi_show_sense_hdr(sdev, name, &sshdr); |
1524 | scsi_decode_sense_extras(sense_buffer, sense_len, &sshdr); | 1530 | scsi_decode_sense_extras(sense_buffer, sense_len, &sshdr); |
1525 | printk(KERN_INFO "%s: ", name); | 1531 | scsi_show_extd_sense(sdev, name, sshdr.asc, sshdr.ascq); |
1526 | scsi_show_extd_sense(sshdr.asc, sshdr.ascq); | ||
1527 | } | 1532 | } |
1528 | EXPORT_SYMBOL(__scsi_print_sense); | 1533 | EXPORT_SYMBOL(__scsi_print_sense); |
1529 | 1534 | ||
1530 | /* Normalize and print sense buffer in SCSI command */ | 1535 | /* Normalize and print sense buffer in SCSI command */ |
1531 | void scsi_print_sense(char *name, struct scsi_cmnd *cmd) | 1536 | void scsi_print_sense(const struct scsi_cmnd *cmd) |
1532 | { | 1537 | { |
1533 | struct scsi_sense_hdr sshdr; | 1538 | struct gendisk *disk = cmd->request->rq_disk; |
1539 | const char *disk_name = disk ? disk->disk_name : NULL; | ||
1534 | 1540 | ||
1535 | scmd_printk(KERN_INFO, cmd, " "); | 1541 | __scsi_print_sense(cmd->device, disk_name, cmd->sense_buffer, |
1536 | scsi_decode_sense_buffer(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE, | 1542 | SCSI_SENSE_BUFFERSIZE); |
1537 | &sshdr); | ||
1538 | scsi_show_sense_hdr(&sshdr); | ||
1539 | scsi_decode_sense_extras(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE, | ||
1540 | &sshdr); | ||
1541 | scmd_printk(KERN_INFO, cmd, " "); | ||
1542 | scsi_show_extd_sense(sshdr.asc, sshdr.ascq); | ||
1543 | } | 1543 | } |
1544 | EXPORT_SYMBOL(scsi_print_sense); | 1544 | EXPORT_SYMBOL(scsi_print_sense); |
1545 | 1545 | ||