mirror of
https://github.com/torvalds/linux.git
synced 2026-11-09 13:44:03 +01:00
scsi: ch: Use combined sense codes
Refactor the SCSI media changer driver to use the 16-bit sense_code field of struct scsi_sense_hdr and struct scsi_failure and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented. No functional change intended. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Hannes Reinecke <hare@kernel.org> Link: https://patch.msgid.link/20260908090308.1085097-12-dlemoal@kernel.org Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
This commit is contained in:
parent
28e463a7be
commit
fdec4b3a17
|
|
@ -123,38 +123,32 @@ static DEFINE_IDR(ch_index_idr);
|
|||
static DEFINE_SPINLOCK(ch_index_lock);
|
||||
|
||||
static const struct {
|
||||
unsigned char sense;
|
||||
unsigned char asc;
|
||||
unsigned char ascq;
|
||||
int errno;
|
||||
u8 sense_key;
|
||||
u16 sense_code;
|
||||
int errno;
|
||||
} ch_err[] = {
|
||||
/* Just filled in what looks right. Hav'nt checked any standard paper for
|
||||
these errno assignments, so they may be wrong... */
|
||||
{
|
||||
.sense = ILLEGAL_REQUEST,
|
||||
.asc = 0x21,
|
||||
.ascq = 0x01,
|
||||
.errno = EBADSLT, /* Invalid element address */
|
||||
.sense_key = ILLEGAL_REQUEST,
|
||||
.sense_code = INVALID_ELEMENT_ADDRESS,
|
||||
.errno = EBADSLT,
|
||||
},{
|
||||
.sense = ILLEGAL_REQUEST,
|
||||
.asc = 0x28,
|
||||
.ascq = 0x01,
|
||||
.errno = EBADE, /* Import or export element accessed */
|
||||
.sense_key = ILLEGAL_REQUEST,
|
||||
.sense_code = IMPORT_OR_EXPORT_ELEMENT_ACCESSED,
|
||||
.errno = EBADE,
|
||||
},{
|
||||
.sense = ILLEGAL_REQUEST,
|
||||
.asc = 0x3B,
|
||||
.ascq = 0x0D,
|
||||
.errno = EXFULL, /* Medium destination element full */
|
||||
.sense_key = ILLEGAL_REQUEST,
|
||||
.sense_code = MEDIUM_DESTINATION_ELEMENT_FULL,
|
||||
.errno = EXFULL,
|
||||
},{
|
||||
.sense = ILLEGAL_REQUEST,
|
||||
.asc = 0x3B,
|
||||
.ascq = 0x0E,
|
||||
.errno = EBADE, /* Medium source element empty */
|
||||
.sense_key = ILLEGAL_REQUEST,
|
||||
.sense_code = MEDIUM_SOURCE_ELEMENT_EMPTY,
|
||||
.errno = EBADE,
|
||||
},{
|
||||
.sense = ILLEGAL_REQUEST,
|
||||
.asc = 0x20,
|
||||
.ascq = 0x00,
|
||||
.errno = EBADRQC, /* Invalid command operation code */
|
||||
.sense_key = ILLEGAL_REQUEST,
|
||||
.sense_code = INVALID_COMMAND_OP_CODE,
|
||||
.errno = EBADRQC,
|
||||
},{
|
||||
/* end of list */
|
||||
}
|
||||
|
|
@ -167,12 +161,10 @@ static int ch_find_errno(struct scsi_sense_hdr *sshdr)
|
|||
int i,errno = 0;
|
||||
|
||||
/* Check to see if additional sense information is available */
|
||||
if (scsi_sense_valid(sshdr) &&
|
||||
sshdr->asc != 0) {
|
||||
if (scsi_sense_valid(sshdr) && scsi_sense_asc(sshdr) != 0) {
|
||||
for (i = 0; ch_err[i].errno != 0; i++) {
|
||||
if (ch_err[i].sense == sshdr->sense_key &&
|
||||
ch_err[i].asc == sshdr->asc &&
|
||||
ch_err[i].ascq == sshdr->ascq) {
|
||||
if (ch_err[i].sense_key == sshdr->sense_key &&
|
||||
ch_err[i].sense_code == sshdr->sense_code) {
|
||||
errno = -ch_err[i].errno;
|
||||
break;
|
||||
}
|
||||
|
|
@ -192,8 +184,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len,
|
|||
struct scsi_failure failure_defs[] = {
|
||||
{
|
||||
.sense_key = UNIT_ATTENTION,
|
||||
.asc = SCMD_FAILURE_ASC_ANY,
|
||||
.ascq = SCMD_FAILURE_ASCQ_ANY,
|
||||
.sense_code = SCMD_FAILURE_SENSE_CODE_ANY,
|
||||
.allowed = 3,
|
||||
.result = SAM_STAT_CHECK_CONDITION,
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user