From 6edaec0d400083363cf4437e0f239f4e1d2a7682 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 3 Sep 2021 05:01:43 +0000 Subject: [PATCH 1/2] scst: Make msg_byte() and driver_byte() available when building against v5.14 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9504 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/backport.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/scst/include/backport.h b/scst/include/backport.h index 353d975be..d58fe830c 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -2118,6 +2118,37 @@ static inline struct ib_pd *ib_alloc_pd_backport(struct ib_device *device) }) #endif +/* */ + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) +#ifndef msg_byte +/* + * See also commit 54cf31d07aa8 ("scsi: core: Drop message byte helper"; + * v5.14-rc1). + */ +static inline uint8_t msg_byte(uint32_t result) +{ + return (result >> 8) & 0xff; +} +#endif +#ifndef host_byte +static inline uint8_t host_byte(uint32_t result) +{ + return (result >> 16) & 0xff; +} +#endif +#ifndef driver_byte +/* + * See also commit 54c29086195f ("scsi: core: Drop the now obsolete driver_byte + * definitions"; v5.14-rc1). + */ +static inline uint8_t driver_byte(uint32_t result) +{ + return (result >> 24) & 0xff; +} +#endif +#endif + /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) || \ From 3624c1baafdfa518789550e23f771d134fc7418f Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 3 Sep 2021 05:05:13 +0000 Subject: [PATCH 2/2] scst: Open-code the status_byte() macro The status_byte() macro and also the SAM_STAT_* macros shifted right by one bit have been removed from kernel v5.14. Hence open-code status_byte() and change GOOD into SAM_STAT_GOOD etc. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9505 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_disk.c | 2 +- scst/src/scst_lib.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scst/src/dev_handlers/scst_disk.c b/scst/src/dev_handlers/scst_disk.c index fd01b8d1c..e841db45c 100644 --- a/scst/src/dev_handlers/scst_disk.c +++ b/scst/src/dev_handlers/scst_disk.c @@ -264,7 +264,7 @@ static void disk_cmd_done(void *data, char *sense, int result, int resid) WARN_ON_ONCE(IS_ERR_VALUE((long)result)); - if (status_byte(result) == GOOD) + if ((result & 0xff) == SAM_STAT_GOOD) goto out_complete; work->result = result; diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 3020bd570..91a6f8f0e 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -12928,7 +12928,7 @@ static void scst_check_internal_sense(struct scst_device *dev, int result, sl = scst_set_sense(sense, sense_len, dev->d_sense, SCST_LOAD_SENSE(scst_sense_reset_UA)); scst_dev_check_set_UA(dev, NULL, sense, sl); - } else if ((status_byte(result) == CHECK_CONDITION) && + } else if ((result & 0xff) == SAM_STAT_CHECK_CONDITION && scst_is_ua_sense(sense, sense_len)) scst_dev_check_set_UA(dev, NULL, sense, sense_len); @@ -13809,7 +13809,7 @@ int scst_obtain_device_parameters(struct scst_device *dev, scst_check_internal_sense(dev, rc, sense_buffer, sizeof(sense_buffer)); #if 0 - if ((status_byte(rc) == CHECK_CONDITION) && + if ((rc & 0xff) == SAM_STAT_CHECK_CONDITION && scst_sense_valid(sense_buffer)) { #else /*