diff options
-rw-r--r-- | drivers/scsi/libata-scsi.c | 28 | ||||
-rw-r--r-- | drivers/scsi/libata.h | 2 |
2 files changed, 30 insertions, 0 deletions
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index 1c3a10fb3c44..bca9a5016b17 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
@@ -1451,6 +1451,34 @@ unsigned int ata_scsiop_report_luns(struct ata_scsi_args *args, u8 *rbuf, | |||
1451 | } | 1451 | } |
1452 | 1452 | ||
1453 | /** | 1453 | /** |
1454 | * ata_scsi_set_sense - Set SCSI sense data and status | ||
1455 | * @cmd: SCSI request to be handled | ||
1456 | * @sk: SCSI-defined sense key | ||
1457 | * @asc: SCSI-defined additional sense code | ||
1458 | * @ascq: SCSI-defined additional sense code qualifier | ||
1459 | * | ||
1460 | * Helper function that builds a valid fixed format, current | ||
1461 | * response code and the given sense key (sk), additional sense | ||
1462 | * code (asc) and additional sense code qualifier (ascq) with | ||
1463 | * a SCSI command status of %SAM_STAT_CHECK_CONDITION and | ||
1464 | * DRIVER_SENSE set in the upper bits of scsi_cmnd::result . | ||
1465 | * | ||
1466 | * LOCKING: | ||
1467 | * Not required | ||
1468 | */ | ||
1469 | |||
1470 | void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq) | ||
1471 | { | ||
1472 | cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; | ||
1473 | |||
1474 | cmd->sense_buffer[0] = 0x70; /* fixed format, current */ | ||
1475 | cmd->sense_buffer[2] = sk; | ||
1476 | cmd->sense_buffer[7] = 18 - 8; /* additional sense length */ | ||
1477 | cmd->sense_buffer[12] = asc; | ||
1478 | cmd->sense_buffer[13] = ascq; | ||
1479 | } | ||
1480 | |||
1481 | /** | ||
1454 | * ata_scsi_badcmd - End a SCSI request with an error | 1482 | * ata_scsi_badcmd - End a SCSI request with an error |
1455 | * @cmd: SCSI request to be handled | 1483 | * @cmd: SCSI request to be handled |
1456 | * @done: SCSI command completion function | 1484 | * @done: SCSI command completion function |
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h index a4b55dc9c698..4622e643ffd3 100644 --- a/drivers/scsi/libata.h +++ b/drivers/scsi/libata.h | |||
@@ -80,6 +80,8 @@ extern unsigned int ata_scsiop_report_luns(struct ata_scsi_args *args, u8 *rbuf, | |||
80 | extern void ata_scsi_badcmd(struct scsi_cmnd *cmd, | 80 | extern void ata_scsi_badcmd(struct scsi_cmnd *cmd, |
81 | void (*done)(struct scsi_cmnd *), | 81 | void (*done)(struct scsi_cmnd *), |
82 | u8 asc, u8 ascq); | 82 | u8 asc, u8 ascq); |
83 | extern void ata_scsi_set_sense(struct scsi_cmnd *cmd, | ||
84 | u8 sk, u8 asc, u8 ascq); | ||
83 | extern void ata_scsi_rbuf_fill(struct ata_scsi_args *args, | 85 | extern void ata_scsi_rbuf_fill(struct ata_scsi_args *args, |
84 | unsigned int (*actor) (struct ata_scsi_args *args, | 86 | unsigned int (*actor) (struct ata_scsi_args *args, |
85 | u8 *rbuf, unsigned int buflen)); | 87 | u8 *rbuf, unsigned int buflen)); |