mirror of
https://github.com/torvalds/linux.git
synced 2026-11-09 13:44:03 +01:00
scsi: st: Use combined sense codes
Refactor the SCSI tape driver to use the 16-bit sense_code field of struct scsi_sense_hdr 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-13-dlemoal@kernel.org Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
This commit is contained in:
parent
fdec4b3a17
commit
9a21d5e121
|
|
@ -421,11 +421,13 @@ static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt)
|
|||
STp->cln_sense_mask) != 0);
|
||||
}
|
||||
if (cmdstatp->have_sense &&
|
||||
cmdstatp->sense_hdr.asc == 0 && cmdstatp->sense_hdr.ascq == 0x17)
|
||||
STp->cleaning_req = 1; /* ASC and ASCQ => cleaning requested */
|
||||
cmdstatp->sense_hdr.sense_code == CLEANING_REQUESTED)
|
||||
STp->cleaning_req = 1;
|
||||
if (cmdstatp->have_sense && scode == UNIT_ATTENTION &&
|
||||
cmdstatp->sense_hdr.asc == 0x29 && !STp->pos_unknown) {
|
||||
STp->pos_unknown = 1; /* ASC => power on / reset */
|
||||
scsi_sense_asc(&cmdstatp->sense_hdr) ==
|
||||
ASC_POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED &&
|
||||
!STp->pos_unknown) {
|
||||
STp->pos_unknown = 1;
|
||||
st_printk(KERN_WARNING, STp, "Power on/reset recognized.");
|
||||
}
|
||||
|
||||
|
|
@ -1003,7 +1005,8 @@ static int test_ready(struct scsi_tape *STp, int do_wait)
|
|||
scode = cmdstatp->sense_hdr.sense_key;
|
||||
|
||||
if (scode == UNIT_ATTENTION) { /* New media? */
|
||||
if (cmdstatp->sense_hdr.asc == 0x28) { /* New media */
|
||||
if (scsi_sense_asc(&cmdstatp->sense_hdr) ==
|
||||
ASC_NOT_READY_TO_READY_CHANGE_MEDIUM_MAY_HAVE_CHANGED) {
|
||||
new_session = 1;
|
||||
DEBC_printk(STp, "New tape session.");
|
||||
}
|
||||
|
|
@ -1026,14 +1029,13 @@ static int test_ready(struct scsi_tape *STp, int do_wait)
|
|||
waits++;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
if ((STp->device)->scsi_level >= SCSI_2 &&
|
||||
cmdstatp->sense_hdr.asc == 0x3a) /* Check ASC */
|
||||
retval = CHKRES_NO_TAPE;
|
||||
else
|
||||
retval = CHKRES_NOT_READY;
|
||||
break;
|
||||
}
|
||||
if ((STp->device)->scsi_level >= SCSI_2 &&
|
||||
scsi_sense_asc(&cmdstatp->sense_hdr) ==
|
||||
ASC_MEDIUM_NOT_PRESENT)
|
||||
retval = CHKRES_NO_TAPE;
|
||||
else
|
||||
retval = CHKRES_NOT_READY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3105,9 +3107,10 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
|
|||
cmd_in == MTSETDRVBUFFER ||
|
||||
cmd_in == SET_DENS_AND_BLK) {
|
||||
if (cmdstatp->sense_hdr.sense_key == ILLEGAL_REQUEST &&
|
||||
cmdstatp->sense_hdr.asc == 0x24 &&
|
||||
(STp->device)->scsi_level <= SCSI_2 &&
|
||||
!(STp->use_pf & PF_TESTED)) {
|
||||
scsi_sense_asc(&cmdstatp->sense_hdr) ==
|
||||
ASC_INVALID_FIELD_IN_CDB &&
|
||||
(STp->device)->scsi_level <= SCSI_2 &&
|
||||
!(STp->use_pf & PF_TESTED)) {
|
||||
/* Try the other possible state of Page Format if not
|
||||
already tried */
|
||||
STp->use_pf = (STp->use_pf ^ USE_PF) | PF_TESTED;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user