cryptodev: fix compilation error for kernel v4.9

The patch is needed to match the API kernel changes. This fixes:

zc.c:68:44: error: passing argument 7 of 'get_user_pages_remote' from incompatible pointer type [-Werror=incompatible-pointer-types]
     (unsigned long)addr, pgcount, write, 0, pg, NULL);
                                             ^~
In file included from zc.c:28:0:
  kernel-source/include/linux/mm.h:1276:6: note: expected 'struct vm_area_struct **' but argument is of type 'struct page **'
    long get_user_pages_remote(struct task_struct *tsk, struct mm_struct *mm,
         ^~~~~~~~~~~~~~~~~~~~~
  zc.c:63:8: error: too many arguments to function 'get_user_pages_remote'
   ret = get_user_pages_remote(
         ^~~~~~~~~~~~~~~~~~~~~
 In file included from zc.c:28:0:
 kernel-source/include/linux/mm.h:1276:6: note: declared here
   long get_user_pages_remote(struct task_struct *tsk, struct mm_struct *mm,
        ^~~~~~~~~~~~~~~~~~~~~
 cc1: some warnings being treated as errors

https://jira.digi.com/browse/DEL-5081

Signed-off-by: Jose Diaz de Grenu <Jose.DiazdeGrenu@digi.com>
This commit is contained in:
Jose Diaz de Grenu 2017-10-09 17:48:17 +02:00
parent a5cfaa921d
commit 0e5ff61a79
2 changed files with 37 additions and 1 deletions

View File

@ -0,0 +1,32 @@
From: Michael Weiser <michael.weiser@gmx.de>
Date: Fri, 11 Nov 2016 18:09:32 +0100
Subject: [PATCH] Adjust to another change in the user page API
4.9.0 will replace the write and force flags of get_user_pages_remote()
with a gup_flags parameter[1]. Distinguish the two APIs based on kernel
version we're compiling for.
[1] https://github.com/torvalds/linux/commit/9beae1ea89305a9667ceaab6d0bf46a045ad71e7
---
zc.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/zc.c b/zc.c
index a97b49f75327..e766ee3eabc7 100644
--- a/zc.c
+++ b/zc.c
@@ -65,7 +65,13 @@ int __get_userbuf(uint8_t __user *addr, uint32_t len, int write,
ret = get_user_pages(
#endif
task, mm,
- (unsigned long)addr, pgcount, write, 0, pg, NULL);
+ (unsigned long)addr, pgcount,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0))
+ write ? FOLL_WRITE : 0,
+#else
+ write, 0,
+#endif
+ pg, NULL);
up_read(&mm->mmap_sem);
if (ret != pgcount)
return -EINVAL;

View File

@ -1,3 +1,7 @@
# Copyright (C) 2016 Digi International. # Copyright (C) 2016-2017 Digi International Inc.
FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
SRC_URI_append = " file://0002-Adjust-to-another-change-in-the-user-page-API.patch"
KERNEL_MODULE_AUTOLOAD = "cryptodev" KERNEL_MODULE_AUTOLOAD = "cryptodev"