u2mfn: build for both 4.6+ and older kernels

This commit is contained in:
Marek Marczykowski-Górecki 2016-05-09 14:31:36 +02:00
parent 79cb426825
commit 98aed38ec5
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -75,8 +75,13 @@ static long u2mfn_ioctl(struct file *f, unsigned int cmd,
switch (cmd) { switch (cmd) {
case U2MFN_GET_MFN_FOR_PAGE: case U2MFN_GET_MFN_FOR_PAGE:
down_read(&current->mm->mmap_sem); down_read(&current->mm->mmap_sem);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
ret = get_user_pages ret = get_user_pages
(data, 1, 1, 0, &user_page, 0); (data, 1, 1, 0, &user_page, 0);
#else
ret = get_user_pages
(current, current->mm, data, 1, 1, 0, &user_page, 0);
#endif
up_read(&current->mm->mmap_sem); up_read(&current->mm->mmap_sem);
if (ret != 1) { if (ret != 1) {
printk("U2MFN_GET_MFN_FOR_PAGE: get_user_pages failed, ret=0x%lx\n", ret); printk("U2MFN_GET_MFN_FOR_PAGE: get_user_pages failed, ret=0x%lx\n", ret);