From 037138239497d5d388051956dfe717e103f0e20c Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 26 Apr 2017 23:53:11 +0000 Subject: [PATCH] scst: Introduce scst_scsi_execute() This patch does not change any functionality but makes it easier to port SCST to Linux kernel v4.11. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7152 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst.h | 4 ++++ scst/src/dev_handlers/scst_cdrom.c | 10 +++----- scst/src/dev_handlers/scst_disk.c | 10 +++----- scst/src/dev_handlers/scst_modisk.c | 10 +++----- scst/src/scst_lib.c | 36 +++++++++++++++++++---------- 5 files changed, 37 insertions(+), 33 deletions(-) diff --git a/scst/include/scst.h b/scst/include/scst.h index 0933041fd..3b684be55 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -5694,6 +5694,10 @@ struct scst_data_descriptor { }; 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 bufflen, + unsigned char *sense, int timeout, int retries, + u64 flags); __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/dev_handlers/scst_cdrom.c b/scst/src/dev_handlers/scst_cdrom.c index 163c174ab..030834a2d 100644 --- a/scst/src/dev_handlers/scst_cdrom.c +++ b/scst/src/dev_handlers/scst_cdrom.c @@ -96,13 +96,9 @@ static int cdrom_attach(struct scst_device *dev) data_dir = SCST_DATA_READ; TRACE_DBG("%s", "Doing READ_CAPACITY"); - rc = scsi_execute(dev->scsi_dev, cmd, data_dir, buffer, - buffer_size, sense_buffer, - SCST_GENERIC_CDROM_REG_TIMEOUT, 3, 0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) - , NULL -#endif - ); + rc = scst_scsi_execute(dev->scsi_dev, cmd, data_dir, buffer, + buffer_size, sense_buffer, + SCST_GENERIC_CDROM_REG_TIMEOUT, 3, 0); TRACE_DBG("READ_CAPACITY done: %x", rc); diff --git a/scst/src/dev_handlers/scst_disk.c b/scst/src/dev_handlers/scst_disk.c index 074f72267..b67b28501 100644 --- a/scst/src/dev_handlers/scst_disk.c +++ b/scst/src/dev_handlers/scst_disk.c @@ -193,13 +193,9 @@ static int disk_attach(struct scst_device *dev) data_dir = SCST_DATA_READ; TRACE_DBG("%s", "Doing READ_CAPACITY"); - rc = scsi_execute(dev->scsi_dev, cmd, data_dir, buffer, - buffer_size, sense_buffer, - SCST_GENERIC_DISK_REG_TIMEOUT, 3, 0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) - , NULL -#endif - ); + rc = scst_scsi_execute(dev->scsi_dev, cmd, data_dir, buffer, + buffer_size, sense_buffer, + SCST_GENERIC_DISK_REG_TIMEOUT, 3, 0); TRACE_DBG("READ_CAPACITY done: %x", rc); diff --git a/scst/src/dev_handlers/scst_modisk.c b/scst/src/dev_handlers/scst_modisk.c index 0111955cc..66e4b7b38 100644 --- a/scst/src/dev_handlers/scst_modisk.c +++ b/scst/src/dev_handlers/scst_modisk.c @@ -197,13 +197,9 @@ static int modisk_attach(struct scst_device *dev) data_dir = SCST_DATA_READ; TRACE_DBG("%s", "Doing READ_CAPACITY"); - rc = scsi_execute(dev->scsi_dev, cmd, data_dir, buffer, - buffer_size, sense_buffer, - SCST_GENERIC_MODISK_REG_TIMEOUT, 3, 0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) - , NULL -#endif - ); + rc = scst_scsi_execute(dev->scsi_dev, cmd, data_dir, buffer, + buffer_size, sense_buffer, + SCST_GENERIC_MODISK_REG_TIMEOUT, 3, 0); TRACE_DBG("READ_CAPACITY done: %x", rc); diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index f84df53e1..933ca5a03 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -6777,6 +6777,25 @@ out: return res; } +int scst_scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, + int data_direction, void *buffer, unsigned 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; @@ -6801,12 +6820,8 @@ static void scst_send_release(struct scst_device *dev) TRACE(TRACE_DEBUG | TRACE_SCSI, "%s", "Sending RELEASE req to " "SCSI mid-level"); - rc = scsi_execute(scsi_dev, cdb, SCST_DATA_NONE, NULL, 0, - sense, 15, 0, 0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) - , NULL -#endif - ); + rc = scst_scsi_execute(scsi_dev, cdb, SCST_DATA_NONE, NULL, 0, + sense, 15, 0, 0); TRACE_DBG("RELEASE done: %x", rc); if (scsi_status_is_good(rc)) { @@ -13248,12 +13263,9 @@ int scst_obtain_device_parameters(struct scst_device *dev, memset(sense_buffer, 0, sizeof(sense_buffer)); TRACE(TRACE_SCSI, "%s", "Doing internal MODE_SENSE"); - rc = scsi_execute(dev->scsi_dev, cmd, SCST_DATA_READ, buffer, - sizeof(buffer), sense_buffer, 15, 0, 0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) - , NULL -#endif - ); + rc = scst_scsi_execute(dev->scsi_dev, cmd, SCST_DATA_READ, + buffer, sizeof(buffer), sense_buffer, + 15, 0, 0); TRACE_DBG("MODE_SENSE done: %x", rc);