From f8fab6fcab80e7fdd8e4bf677fa19b5d84231aa1 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 13 Nov 2017 16:18:00 +0000 Subject: [PATCH] scst: Fix build for kernels 3.15 and older blk_rq_set_block_pc() was introduced in kernel 3.16. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7262 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/backport.h | 23 +++++++++++++++++++++++ scst/src/scst_lib.c | 15 --------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/scst/include/backport.h b/scst/include/backport.h index 4902611f5..b67455621 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -746,4 +746,27 @@ static inline int scsi_bidi_cmnd(struct scsi_cmnd *cmd) } #endif +/* */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) +static inline struct request *scsi_req(struct request *rq) +{ + return rq; +} + +static inline void scsi_req_init(struct request *rq) +{ +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0) + rq->cmd_type = REQ_TYPE_BLOCK_PC; + rq->__data_len = 0; + rq->__sector = (sector_t) -1; + rq->bio = rq->biotail = NULL; + memset(rq->__cmd, 0, sizeof(rq->__cmd)); + rq->cmd = rq->__cmd; +#else + return blk_rq_set_block_pc(rq); +#endif +} +#endif + #endif /* _SCST_BACKPORT_H_ */ diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 2220adefa..cad0bc4dc 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -7957,11 +7957,7 @@ static struct request *blk_make_request(struct request_queue *q, if (IS_ERR(rq)) return rq; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0) scsi_req_init(scsi_req(rq)); -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) - scsi_req_init(rq); -#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) rq->cmd_flags = bio_data_dir(bio) == READ ? REQ_OP_SCSI_IN : REQ_OP_SCSI_OUT; @@ -8193,15 +8189,9 @@ static struct request *blk_map_kern_sg(struct request_queue *q, if (unlikely(!rq)) return ERR_PTR(-ENOMEM); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0) scsi_req_init(scsi_req(rq)); -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) - scsi_req_init(rq); -#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) rq->cmd_flags = reading ? REQ_OP_SCSI_IN : REQ_OP_SCSI_OUT; -#else - blk_rq_set_block_pc(rq); #endif goto out; } @@ -8496,12 +8486,7 @@ int scst_scsi_exec_async(struct scst_cmd *cmd, void *data, sioc->data = data; sioc->done = done; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) req = scsi_req(rq); -#else - req = rq; -#endif - req->cmd_len = cmd_len; if (req->cmd_len <= BLK_MAX_CDB) { memset(req->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */