Changeset 582fe388 in mainline


Ignore:
Timestamp:
2011-07-24T16:48:33Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
de3432b
Parents:
45cae6b
Message:

Display sense key in string form.

Location:
uspace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbmast/scsi_ms.c

    r45cae6b r582fe388  
    6464{
    6565        scsi_sense_data_t sense_buf;
     66        unsigned sense_key;
    6667        int rc;
    6768
    6869        rc = usbmast_request_sense(mfun, &sense_buf, sizeof(sense_buf));
    6970        if (rc == EOK) {
    70                 printf("Got sense data (sense_key=0x%x, asc=0x%02x, "
    71                     "ascq=0x%02x.\n", sense_buf.flags_key & 0x0f,
     71                sense_key = sense_buf.flags_key & 0x0f;
     72                printf("Got sense data. Sense key: 0x%x (%s), ASC 0x%02x, "
     73                    "ASCQ 0x%02x.\n", sense_key,
     74                    scsi_get_sense_key_str(sense_key),
    7275                    sense_buf.additional_code,
    7376                    sense_buf.additional_cqual);
  • uspace/lib/scsi/include/scsi/spc.h

    r45cae6b r582fe388  
    205205        SCSI_SK_ABORTED_COMMAND = 0xb,
    206206        SCSI_SK_VOLUME_OVERFLOW = 0xd,
    207         SCSI_SK_MISCOMPARE      = 0xe
     207        SCSI_SK_MISCOMPARE      = 0xe,
     208
     209        SCSI_SK_LIMIT           = 0x10
    208210};
    209211
    210212extern const char *scsi_dev_type_str[SCSI_DEV_LIMIT];
     213extern const char *scsi_sense_key_str[SCSI_SK_LIMIT];
     214
    211215extern const char *scsi_get_dev_type_str(unsigned);
     216extern const char *scsi_get_sense_key_str(unsigned);
    212217
    213218#endif
  • uspace/lib/scsi/src/spc.c

    r45cae6b r582fe388  
    4444};
    4545
     46const char *scsi_sense_key_str[SCSI_SK_LIMIT] = {
     47        [SCSI_SK_NO_SENSE]              = "No Sense",
     48        [SCSI_SK_RECOVERED_ERROR]       = "Recovered Error",
     49        [SCSI_SK_NOT_READY]             = "Not Ready",
     50        [SCSI_SK_MEDIUM_ERROR]          = "Medium Error",
     51        [SCSI_SK_HARDWARE_ERROR]        = "Hardware Error",
     52        [SCSI_SK_ILLEGAL_REQUEST]       = "Illegal Request",
     53        [SCSI_SK_UNIT_ATTENTION]        = "Unit Attention",
     54        [SCSI_SK_DATA_PROTECT]          = "Data Protect",
     55        [SCSI_SK_BLANK_CHECK]           = "Blank Check",
     56        [SCSI_SK_VENDOR_SPECIFIC]       = "Vendor-specific",
     57        [SCSI_SK_COPY_ABORTED]          = "Copy Aborted",
     58        [SCSI_SK_ABORTED_COMMAND]       = "Aborted Command",
     59        [SCSI_SK_VOLUME_OVERFLOW]       = "Volume Overflow",
     60        [SCSI_SK_MISCOMPARE]            = "Miscompare"
     61};
     62
    4663/** Get peripheral device type string.
    4764 *
     
    5370{
    5471        if (dev_type >= SCSI_DEV_LIMIT || scsi_dev_type_str[dev_type] == NULL)
    55                 return "<unknown>";
     72                return "Unknown";
    5673
    5774        return scsi_dev_type_str[dev_type];
    5875}
     76
     77/** Get sense key string.
     78 *
     79 * Return string description of SCSI sense key.
     80 * The returned string is valid indefinitely, the caller should
     81 * not attempt to free it.
     82 */
     83const char *scsi_get_sense_key_str(unsigned sense_key)
     84{
     85        if (sense_key >= SCSI_SK_LIMIT || scsi_sense_key_str[sense_key] == NULL)
     86                return "Unknown";
     87
     88        return scsi_sense_key_str[sense_key];
     89}
     90
Note: See TracChangeset for help on using the changeset viewer.