2017-02-08 10:11 GMT+00:00 Cristian Stoica <cristian.sto...@nxp.com>:
> There are many changes related to get_user_pages and the code is rewritten
> for clarity.
>
> Signed-off-by: Cristian Stoica <cristian.sto...@nxp.com>
> ---
>  zc.c | 28 +++++++++++++++++-----------
>  1 file changed, 17 insertions(+), 11 deletions(-)
>
> diff --git a/zc.c b/zc.c
> index e766ee3..2f4ea99 100644
> --- a/zc.c
> +++ b/zc.c
> @@ -59,19 +59,25 @@ int __get_userbuf(uint8_t __user *addr, uint32_t len, int 
> write,
>         }
>
>         down_read(&mm->mmap_sem);
> -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0))
> -       ret = get_user_pages_remote(
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0))
> +       ret = get_user_pages(task, mm,
> +                       (unsigned long)addr, pgcount, write, 0, pg, NULL);
>  #else
> -       ret = get_user_pages(
> -#endif
> -                       task, mm,
> -                       (unsigned long)addr, pgcount,
> -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0))
> -                       write ? FOLL_WRITE : 0,
> -#else
> -                       write, 0,
> -#endif
> +#  if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0))
> +       ret = get_user_pages_remote(task, mm,
> +                       (unsigned long)addr, pgcount, write, 0, pg, NULL);
> +#  else
> +#    if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0))
> +       ret = get_user_pages_remote(task, mm,
> +                       (unsigned long)addr, pgcount, write ? FOLL_WRITE : 0,
>                         pg, NULL);
> +#    else
> +       ret = get_user_pages_remote(task, mm,
> +                       (unsigned long)addr, pgcount, write ? FOLL_WRITE : 0,
> +                       pg, NULL, NULL);
> +#    endif
> +#  endif
> +#endif
>         up_read(&mm->mmap_sem);
>         if (ret != pgcount)
>                 return -EINVAL;

Would not be more readable using #elif too, sort of

#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0))
       ret = get_user_pages(task, mm,
                       (unsigned long)addr, pgcount, write, 0, pg, NULL);
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0))
       ret = get_user_pages_remote(task, mm,
                       (unsigned long)addr, pgcount, write, 0, pg, NULL);
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0))
       ret = get_user_pages_remote(task, mm,
                       (unsigned long)addr, pgcount, write ?
FOLL_WRITE : 0, pg, NULL);
#else
       ret = get_user_pages_remote(task, mm,
                       (unsigned long)addr, pgcount, write ? FOLL_WRITE : 0,
                       pg, NULL, NULL);
#endif

?

Frediano

_______________________________________________
Cryptodev-linux-devel mailing list
Cryptodev-linux-devel@gna.org
https://mail.gna.org/listinfo/cryptodev-linux-devel

Reply via email to