Re: [PATCH v2 05/40] scsi: prepare for using 16-bits defined sense codes
From: Damien Le Moal <dlemoal@kernel.org>
Date: 2026-09-08 00:22:40
Also in:
linux-ide, linux-s390, linux-scsi
On 9/7/26 21:16, Hannes Reinecke wrote:
quoted
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index e321471e8ca2..11910142ac50 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h@@ -518,6 +518,7 @@ extern void scsi_sanitize_inquiry_string(unsigned char*s, int len); * to match any sense key, ASC, and ASCQ value. */ #define SCMD_FAILURE_SENSE_KEY_ANY 0xff +#define SCMD_FAILURE_SENSE_CODE_ANY 0xffff #define SCMD_FAILURE_ASC_ANY 0xff #define SCMD_FAILURE_ASCQ_ANY 0xff /* Always retry a matching failure. */@@ -526,8 +527,18 @@ extern void scsi_sanitize_inquiry_string(unsigned char*s, int len); struct scsi_failure { int result; u8 sense_key; - u8 asc; - u8 ascq; + union { + struct { +#if defined(__BIG_ENDIAN) + u8 asc; + u8 ascq; +#elif defined(__LITTLE_ENDIAN) + u8 ascq; + u8 asc; +#endif + }; + u16 sense_code; + }; /* * Number of times scsi_execute_cmd will retry the failure. It does * not count for the total_allowed.Why do we have two definitions for the sense code header? Can't we combine it with the definitions in scsi_common.h ?
This is *not* the sense header. This is the struct used to filter errors for internal SCSI commands issued with scsi_execute_cmd(). And since that function is devlared in scsi_device.h, this struct declaration is here too.
quoted
@@ -537,6 +548,16 @@ struct scsi_failure {s8 retries; }; +static inline u8 scsi_failure_asc(const struct scsi_failure *failure) +{ + return scsi_sense_code_asc(failure->sense_code); +} + +static inline u8 scsi_failure_ascq(const struct scsi_failure *failure) +{ + return scsi_sense_code_ascq(failure->sense_code); +} + struct scsi_failures { /* * If a scsi_failure does not have a retry limit setup this limit willCheers, Hannes
-- Damien Le Moal Western Digital Research