From 9f543ed64b1ea0f02af797cc1a88137651aa41fe Mon Sep 17 00:00:00 2001 From: Damien Le Moal Date: Tue, 8 Sep 2026 18:02:43 +0900 Subject: [PATCH] scsi: device_handlers: emc: Use combined sense codes Refactor the EMC SCSI device handler 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 Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke Link: https://patch.msgid.link/20260908090308.1085097-16-dlemoal@kernel.org Signed-off-by: Martin K. Petersen (Oracle) --- drivers/scsi/device_handler/scsi_dh_emc.c | 28 ++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh_emc.c b/drivers/scsi/device_handler/scsi_dh_emc.c index ff41b51ef462..4b0ea6045ba3 100644 --- a/drivers/scsi/device_handler/scsi_dh_emc.c +++ b/drivers/scsi/device_handler/scsi_dh_emc.c @@ -105,10 +105,10 @@ static int trespass_endio(struct scsi_device *sdev, sdev_printk(KERN_ERR, sdev, "%s: Found valid sense data 0x%2x, " "0x%2x, 0x%2x while sending CLARiiON trespass " "command.\n", CLARIION_NAME, sshdr->sense_key, - sshdr->asc, sshdr->ascq); + scsi_sense_asc(sshdr), scsi_sense_ascq(sshdr)); - if (sshdr->sense_key == 0x05 && sshdr->asc == 0x04 && - sshdr->ascq == 0x00) { + if (sshdr->sense_key == ILLEGAL_REQUEST && + sshdr->sense_code == LU_NOT_READY) { /* * Array based copy in progress -- do not send * mode_select or copy will be aborted mid-stream. @@ -117,18 +117,18 @@ static int trespass_endio(struct scsi_device *sdev, "progress while sending CLARiiON trespass " "command.\n", CLARIION_NAME); err = SCSI_DH_DEV_TEMP_BUSY; - } else if (sshdr->sense_key == 0x02 && sshdr->asc == 0x04 && - sshdr->ascq == 0x03) { - /* - * LUN Not Ready - Manual Intervention Required - * indicates in-progress ucode upgrade (NDU). - */ + } else if (sshdr->sense_key == NOT_READY && + sshdr->sense_code == + LU_NOT_READY_MANUAL_INTERVENTION_REQUIRED) { + /* Indicates in-progress ucode upgrade (NDU). */ sdev_printk(KERN_INFO, sdev, "%s: Detected in-progress " "ucode upgrade NDU operation while sending " "CLARiiON trespass command.\n", CLARIION_NAME); err = SCSI_DH_DEV_TEMP_BUSY; - } else + } else { err = SCSI_DH_DEV_FAILED; + } + return err; } @@ -288,7 +288,8 @@ static enum scsi_disposition clariion_check_sense(struct scsi_device *sdev, { switch (sense_hdr->sense_key) { case NOT_READY: - if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x03) + if (sense_hdr->sense_code == + LU_NOT_READY_MANUAL_INTERVENTION_REQUIRED) /* * LUN Not Ready - Manual Intervention Required * indicates this is a passive path. @@ -305,7 +306,7 @@ static enum scsi_disposition clariion_check_sense(struct scsi_device *sdev, return SUCCESS; break; case ILLEGAL_REQUEST: - if (sense_hdr->asc == 0x25 && sense_hdr->ascq == 0x01) + if (sense_hdr->sense_code == scsi_sense_code(0x25, 0x01)) /* * An array based copy is in progress. Do not * fail the path, do not bypass to another PG, @@ -319,7 +320,8 @@ static enum scsi_disposition clariion_check_sense(struct scsi_device *sdev, return SUCCESS; break; case UNIT_ATTENTION: - if (sense_hdr->asc == 0x29 && sense_hdr->ascq == 0x00) + if (sense_hdr->sense_code == + POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED) /* * Unit Attention Code. This is the first IO * to the new path, so just retry.