From 51ab2e8ebdd7dc21ea8622fab352252695c3faac Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 27 Aug 2018 03:26:38 +0000 Subject: [PATCH] scst: Port to Linux kernel v4.19 In Linux kernel v4.19 the function scsi_execute() has been replaced by the following macro: /* Make sure any sense buffer is the correct size. */ #define scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \ sshdr, timeout, retries, flags, rq_flags, resid) \ ({ \ BUILD_BUG_ON((sense) != NULL && \ sizeof(sense) != SCSI_SENSE_BUFFERSIZE); \ __scsi_execute(sdev, cmd, data_direction, buffer, bufflen, \ sense, sshdr, timeout, retries, flags, rq_flags, \ resid); \ }) This macro only accepts a sense buffer that has been declared as an array but no sense buffers that have been passed as a pointer to a function. To avoid build errors, convert scst_scsi_execute() from a function into a macro. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7473 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst.h | 36 ++++++++++++++++++++++++++++++++---- scst/src/scst_lib.c | 34 ---------------------------------- 2 files changed, 32 insertions(+), 38 deletions(-) diff --git a/scst/include/scst.h b/scst/include/scst.h index df61b480f..98b0d01c0 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -5728,10 +5728,38 @@ ssize_t scst_readv(struct file *file, const struct iovec *vec, ssize_t scst_writev(struct file *file, const struct iovec *vec, unsigned long vlen, loff_t *pos); void scst_write_same(struct scst_cmd *cmd, struct scst_data_descriptor *where); -int scst_scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, - int data_direction, void *buffer, unsigned int bufflen, - unsigned char *sense, int timeout, int retries, - u64 flags); +/** + * scsi_execute - insert a SCSI request and wait for the result + * @sdev: scsi device + * @cmd: scsi command + * @data_direction: data direction + * @buffer: data buffer + * @bufflen: length of buffer - DMA_TO_DEVICE, DMA_FROM_DEVICE or DMA_NONE + * @sense: optional sense buffer + * @timeout: request timeout in seconds + * @retries: number of times to retry request + * @flags: flags for ->cmd_flags, e.g. REQ_FAILFAST_DEV + * + * Returns the scsi_cmnd result field if a command was executed, or a negative + * Linux error code if we didn't get that far. + */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) +#define scst_scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \ + timeout, retries, flags) \ + scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \ + NULL /* sshdr */, timeout, retries, flags, \ + 0 /* rq_flags */, NULL /* resid */) +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) +#define scst_scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \ + timeout, retries, flags) \ + scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \ + timeout, retries, flags, NULL /* resid */) +#else +#define scst_scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \ + timeout, retries, flags) \ + scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \ + timeout, retries, flags) +#endif __be64 scst_pack_lun(const uint64_t lun, enum scst_lun_addr_method addr_method); uint64_t scst_unpack_lun(const uint8_t *lun, int len); diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index a4848be69..aa30c50d1 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -6862,40 +6862,6 @@ out: return res; } -/** - * scsi_execute - insert a SCSI request and wait for the result - * @sdev: scsi device - * @cmd: scsi command - * @data_direction: data direction - * @buffer: data buffer - * @bufflen: length of buffer - DMA_TO_DEVICE, DMA_FROM_DEVICE or DMA_NONE - * @sense: optional sense buffer - * @timeout: request timeout in seconds - * @retries: number of times to retry request - * @flags: flags for ->cmd_flags, e.g. REQ_FAILFAST_DEV - * - * Returns the scsi_cmnd result field if a command was executed, or a negative - * Linux error code if we didn't get that far. - */ -int scst_scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, - int data_direction, void *buffer, unsigned int bufflen, - unsigned char *sense, int timeout, int retries, u64 flags) -{ - return scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) - NULL, /* sshdr */ -#endif - timeout, retries, flags -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) - , 0 /* rq_flags */ -#endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) - , NULL /* resid */ -#endif - ); -} -EXPORT_SYMBOL(scst_scsi_execute); - static void scst_send_release(struct scst_device *dev) { struct scsi_device *scsi_dev;