From 497fb8b9f2e69d36122a346f00351cf61bd42e44 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 13 Jan 2019 21:11:54 +0000 Subject: [PATCH] scst: Backport kernel_read() to kernel versions before v4.14 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7880 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/backport.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/scst/include/backport.h b/scst/include/backport.h index 26604c190..55c3b477f 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -434,6 +434,33 @@ static inline ssize_t call_write_iter(struct file *file, struct kiocb *kio, } #endif +/* See also commit bdd1d2d3d251 ("fs: fix kernel_read prototype") # v4.14 */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) +static inline ssize_t +kernel_read_backport(struct file *file, void *buf, size_t count, loff_t *pos) +{ + return kernel_read(file, *pos, buf, count); +} + +#define kernel_read(file, buf, count, pos) \ + kernel_read_backport((file), (buf), (count), (pos)) + +/* + * See also commit 7bb307e894d5 ("export kernel_write(), convert open-coded + * instances") # v3.10. + */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) +static inline ssize_t +kernel_write_backport(struct file *file, void *buf, size_t count, loff_t *pos) +{ + return kernel_write(file, *pos, buf, count); +} + +#define kernel_write(file, buf, count, pos) \ + kernel_write_backport((file), (buf), (count), (pos)) +#endif +#endif + /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) || \ LINUX_VERSION_CODE >= KERNEL_VERSION(4, 21, 0)