To make the code more clear, rename the code12 field of struct error_info
to the more natural name "code" and the fields code1, code2_min and
code2_max of struct error_info2 to the more explicit asc, ascq_min and
ascq_max.
No functional change intended.
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Johannes Thumshirn <redacted>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
---
drivers/scsi/constants.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 340785536998..4b97f574fe8c 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -292,7 +292,7 @@ bool scsi_opcode_sa_name(int opcode, int service_action,
}
struct error_info {
- unsigned short code12; /* 0x0302 looks better than 0x03,0x02 */
+ unsigned short code; /* 0x0302 looks better than 0x03,0x02 */
unsigned short size;
};
@@ -318,9 +318,11 @@ static const char *additional_text =
;
struct error_info2 {
- unsigned char code1, code2_min, code2_max;
- const char * str;
- const char * fmt;
+ u8 asc;
+ u8 ascq_min;
+ u8 ascq_max;
+ const char *str;
+ const char *fmt;
};
static const struct error_info2 additional2[] =@@ -377,20 +379,20 @@ EXPORT_SYMBOL(scsi_sense_key_string);
const char *
scsi_extd_sense_format(unsigned char asc, unsigned char ascq, const char **fmt)
{
- int i;
- unsigned short code = ((asc << 8) | ascq);
+ u16 code = scsi_sense_code(asc, ascq);
unsigned offset = 0;
+ int i;
*fmt = NULL;
for (i = 0; i < ARRAY_SIZE(additional); i++) {
- if (additional[i].code12 == code)
+ if (additional[i].code == code)
return additional_text + offset;
offset += additional[i].size;
}
for (i = 0; additional2[i].fmt; i++) {
- if (additional2[i].code1 == asc &&
- ascq >= additional2[i].code2_min &&
- ascq <= additional2[i].code2_max) {
+ if (additional2[i].asc == asc &&
+ ascq >= additional2[i].ascq_min &&
+ ascq <= additional2[i].ascq_max) {
*fmt = additional2[i].fmt;
return additional2[i].str;
}--
2.55.0