From d03c8b77291f7adf54c4f54878ca431efec5c6b0 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Mon, 31 Dec 2012 23:48:03 +0000 Subject: [PATCH] scst: Simplify __scst_get_buf() and __scst_get_sg_page() Signed-off-by: Bart Van Assche with some further simplifications git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4673 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/scst/include/scst.h b/scst/include/scst.h index 7766bd148..022b38330 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -3753,6 +3753,15 @@ static inline struct scatterlist *sg_next(struct scatterlist *sg) #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) */ +static inline struct scatterlist *sg_next_inline(struct scatterlist *sg) +{ + sg++; + if (unlikely(sg_is_chain(sg))) + sg = sg_chain_ptr(sg); + + return sg; +} + static inline void sg_clear(struct scatterlist *sg) { memset(sg, 0, sizeof(*sg)); @@ -3792,16 +3801,13 @@ static inline int __scst_get_buf(struct scst_cmd *cmd, int sg_cnt, goto out; } - if (unlikely(sg_is_chain(sg))) - sg = sg_chain_ptr(sg); - *buf = page_address(sg_page(sg)); *buf += sg->offset; res = sg->length; cmd->get_sg_buf_entry_num++; - cmd->get_sg_buf_cur_sg_entry = ++sg; + cmd->get_sg_buf_cur_sg_entry = sg_next_inline(sg); out: return res; @@ -3898,15 +3904,12 @@ static inline int __scst_get_sg_page(struct scst_cmd *cmd, int sg_cnt, goto out; } - if (unlikely(sg_is_chain(sg))) - sg = sg_chain_ptr(sg); - *page = sg_page(sg); *offset = sg->offset; res = sg->length; cmd->get_sg_buf_entry_num++; - cmd->get_sg_buf_cur_sg_entry = ++sg; + cmd->get_sg_buf_cur_sg_entry = sg_next_inline(sg); out: return res;