--- src/%%NVSRC%%/nvidia_dev.c.orig	2017-09-14 20:46:30 UTC
+++ src/%%NVSRC%%/nvidia_dev.c
@@ -13,6 +13,12 @@
 #include "nv.h"
 #include "nv-freebsd.h"
 
+#ifdef NV_SUPPORT_LINUX_COMPAT /* (COMPAT_LINUX || COMPAT_LINUX32) */
+#include <compat/linux/linux_util.h>
+
+extern const char nvidia_driver_name[];
+#endif
+
 static d_open_t  nvidia_dev_open;
 static void nvidia_dev_dtor(void *arg);
 static d_ioctl_t nvidia_dev_ioctl;
@@ -162,6 +168,18 @@ static int nvidia_dev_mmap_single(
 
 int nvidia_dev_attach(struct nvidia_softc *sc)
 {
+#ifdef NV_SUPPORT_LINUX_COMPAT
+    struct linux_device_handler nvidia_dev_linux_handler = {
+        .bsd_driver_name = __DECONST(char *, nvidia_driver_name),
+        .linux_driver_name = __DECONST(char *, nvidia_driver_name),
+        .bsd_device_name = NULL,
+        .linux_device_name = NULL,
+        .linux_major = NV_MAJOR_DEVICE_NUMBER,
+        .linux_minor = device_get_unit(sc->dev),
+        .linux_char_device = 1
+    };
+#endif
+
     sc->cdev = make_dev(&nvidia_dev_cdevsw,
             device_get_unit(sc->dev),
             UID_ROOT, GID_WHEEL, 0666,
@@ -172,11 +190,31 @@ int nvidia_dev_attach(struct nvidia_softc *sc)
 
     sc->cdev->si_drv1 = sc;
 
+#ifdef NV_SUPPORT_LINUX_COMPAT
+    nvidia_dev_linux_handler.bsd_device_name = sc->cdev->si_name;
+    nvidia_dev_linux_handler.linux_device_name = sc->cdev->si_name;
+    (void)linux_device_register_handler(&nvidia_dev_linux_handler);
+#endif
+
     return 0;
 }
 
 int nvidia_dev_detach(struct nvidia_softc *sc)
 {
+#ifdef NV_SUPPORT_LINUX_COMPAT
+    struct linux_device_handler nvidia_dev_linux_handler = {
+        .bsd_driver_name = __DECONST(char *, nvidia_driver_name),
+        .linux_driver_name = __DECONST(char *, nvidia_driver_name),
+        .bsd_device_name = sc->cdev->si_name,
+        .linux_device_name = sc->cdev->si_name,
+        .linux_major = NV_MAJOR_DEVICE_NUMBER,
+        .linux_minor = device_get_unit(sc->dev),
+        .linux_char_device = 1
+    };
+
+    (void)linux_device_unregister_handler(&nvidia_dev_linux_handler);
+#endif
+
     destroy_dev(sc->cdev);
     return 0;
 }
