Nvidia 340.xx - compile error with kernel 4.12-rc1

Hi all,

I had created a simple patch for kernel 4.12 series. However I get compile errors like this:

In file included from /home/phil/dev/git/manjaro/repositories/extra/linux412-extramodules/_broken/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.101-no-compat32/kernel/nv-drm.c:15:0:
/home/phil/dev/git/manjaro/repositories/extra/linux412-extramodules/_broken/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.101-no-compat32/kernel/nv-linux.h: At top level:
/home/phil/dev/git/manjaro/repositories/extra/linux412-extramodules/_broken/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.101-no-compat32/kernel/nv-linux.h:203:2: error: #error "This driver requires the ability to change memory types!"
 #error "This driver requires the ability to change memory types!"
  ^~~~~

I was able to create a patch for Nvidia 304.xx, however not properly yet for 340.xx series

Since kernel 4.12 is officially released now and the kernel arrived in the distribution I use, I took some time to look into this issue today. The errors are raised because the conftest script tries to detect if certain functions are available and creates the corresponding defines. This is the patch I came up with:

https://raw.githubusercontent.com/Hoshpak/void-packages/nvidia340-linux-4.12/srcpkgs/nvidia340/files/linux-4.12.patch

It conditionally includes the new header file in the conftest script and also in the one place a function defined in that file is used in the module source. The driver compiles and works fine for me on kernel 4.12 with this patch. However there might be incompatibilities with the new kernel version left my attempt at merely making it compile did not catch.

Thanks @Hoshpak - your patch works well enough for my needs running Kodi with 340.102 and 4.12.1!