343.22 driver incompatible with Linux 3.18

Just a heads up,343.22 driver installation didn’t work for me for me with linux 3.18-rc1:
/var/lib/dkms/nvidia/343.22/build/nv-drm.c:24:27: error: field ‘base’ has incomplete type
struct drm_gem_object base;

This patch moved drm_gem_object definition : kernel/git/torvalds/linux.git - Linux kernel source tree

Fixed by adding ‘#include <drm/drm_gem.h>’ to nv-drm.c

“Breaks”?

More like “source code incompatible”, there’s a simple fix.

Fixed title

--- NVIDIA-Linux-x86_64-343.13/kernel/nv-drm.c	2014-08-01 03:14:20.000000000 +0200
+++ NVIDIA-Linux-x86_64-343.22/kernel/nv-drm.c	2014-10-20 13:51:51.921228213 +0200
@@ -17,6 +17,7 @@
 #if defined(NV_DRM_AVAILABLE)
 
 #include <drm/drmP.h>
+#include <drm/drm_gem.h>
 
 extern nv_linux_state_t *nv_linux_devices;

the above patch works but is incomplete. another hunk is needed to avoid run-time warnings:

--- kernel/nv-drm.c~    2014-09-12 00:33:06.000000000 +0200
+++ kernel/nv-drm.c     2014-10-14 11:35:52.854400737 +0200
@@ -18,6 +18,11 @@
 
 #include <drm/drmP.h>
 
+/* 3.18-rc0+ */
+#ifndef drm_gem_object
+#include <drm/drm_gem.h>
+#endif
+
 extern nv_linux_state_t *nv_linux_devices;
 
 struct nv_gem_object {
diff --git a/kernel/nv-drm.c~ b/kernel/nv-drm.c
index ecc982a..60d7aae 100644
--- kernel/nv-drm.c~
+++ kernel/nv-drm.c
@@ -129,6 +129,8 @@ static struct drm_driver nv_drm_driver = {
     .gem_prime_vmap = nv_gem_prime_vmap,
     .gem_prime_vunmap = nv_gem_prime_vunmap,
 
+    .set_busid = drm_pci_set_busid,
+
     .name = "nvidia-drm",
     .desc = "NVIDIA DRM driver",
     .date = "20130102",

The #ifndef isn’t working for me since its defined in <drm/drmP.h>

On Linux 3.16:
/var/lib/dkms/nvidia/343.22/build/nv-drm.c:23:25: fatal error: drm/drm_gen.h: No such file or directory
#include <drm/drm_gen.h>

Checking kernel version instead works.

Good catch with ‘.set_busid’ but I think that needs to be checked for 3.18 version too.

I use that patch with 3.16, 3.17 and 3.18-rc without any problems.
That’s why the ifdef is there: in 3.18 struct drm_gem_object moved to drm/drm_gem.h,
in previous versions it’s in drm/drmP.h

Also it’s drm_gem not drm_gen

Yup, was too lazy to fix the warning in dmesg (since it was workingh without it anyway).
Since object is likely not to move again anytime soon, perhaps macro against KERNEL_VERSION(3,18,0) is in order?