scsi: cdrom: Use combined sense codes

Refactor the cdrom 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-37-dlemoal@kernel.org
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
This commit is contained in:
Damien Le Moal 2026-09-08 18:03:04 +09:00 committed by Martin K. Petersen (Oracle)
parent 134875ed31
commit 4152825a15

View File

@ -345,9 +345,8 @@ int cdrom_dummy_generic_packet(struct cdrom_device_info *cdi,
struct packet_command *cgc)
{
if (cgc->sshdr) {
cgc->sshdr->sense_key = 0x05;
cgc->sshdr->asc = 0x20;
cgc->sshdr->ascq = 0x00;
cgc->sshdr->sense_key = ILLEGAL_REQUEST;
cgc->sshdr->sense_code = INVALID_COMMAND_OP_CODE;
}
cgc->stat = -EIO;
@ -2979,9 +2978,8 @@ static noinline int mmc_ioctl_cdrom_read_data(struct cdrom_device_info *cdi,
cgc->sshdr = &sshdr;
cgc->data_direction = CGC_DATA_READ;
ret = cdrom_read_block(cdi, cgc, lba, 1, format, blocksize);
if (ret && sshdr.sense_key == 0x05 &&
sshdr.asc == 0x20 &&
sshdr.ascq == 0x00) {
if (ret && sshdr.sense_key == ILLEGAL_REQUEST &&
sshdr.sense_code == INVALID_COMMAND_OP_CODE) {
/*
* SCSI-II devices are not required to support
* READ_CD, so let's try switching block size