View | Details | Raw Unified | Return to bug 249505 | Differences between
and this patch

Collapse All | Expand All

(-)x11/nvidia-driver/Makefile (-1 / +2 lines)
Lines 73-79 SUB_PATCHES+= extra-patch-src-nvidia_ctl.c \ Link Here
73
		extra-patch-src-nvidia_linux.c
73
		extra-patch-src-nvidia_linux.c
74
.else
74
.else
75
EXTRA_PATCHES+=	${FILESDIR}/460-patch-lib-libGLX_nvidia-Makefile
75
EXTRA_PATCHES+=	${FILESDIR}/460-patch-lib-libGLX_nvidia-Makefile
76
SUB_PATCHES+=	460-patch-src-nvidia_linux.c
76
SUB_PATCHES+=	460-patch-src-nvidia_ctl.c \
77
		460-patch-src-nvidia_linux.c
77
.endif
78
.endif
78
79
79
OPTIONS_DEFINE=	ACPI_PM LINUX WBINVD DOCS
80
OPTIONS_DEFINE=	ACPI_PM LINUX WBINVD DOCS
(-)x11/nvidia-driver/files/460-patch-src-nvidia_ctl.c.in (+73 lines)
Added Link Here
1
--- src/%%NVSRC%%/nvidia_ctl.c.orig	2021-01-21 21:50:34 UTC
2
+++ src/%%NVSRC%%/nvidia_ctl.c
3
@@ -13,6 +13,12 @@
4
 #include "nv.h"
5
 #include "nv-freebsd.h"
6
 
7
+#ifdef NV_SUPPORT_LINUX_COMPAT /* (COMPAT_LINUX || COMPAT_LINUX32) */
8
+#include <compat/linux/linux_util.h>
9
+
10
+const char nvidia_driver_name[] = "nvidia";
11
+#endif
12
+
13
 static d_open_t  nvidia_ctl_open;
14
 static d_ioctl_t nvidia_ctl_ioctl;
15
 static d_poll_t  nvidia_ctl_poll;
16
@@ -162,6 +168,18 @@ static int nvidia_ctl_poll(
17
 
18
 int nvidia_ctl_attach(void)
19
 {
20
+#ifdef NV_SUPPORT_LINUX_COMPAT
21
+    struct linux_device_handler nvidia_ctl_linux_handler = {
22
+        .bsd_driver_name = __DECONST(char *, nvidia_driver_name),
23
+        .linux_driver_name = __DECONST(char *, nvidia_driver_name),
24
+        .bsd_device_name = __DECONST(char *, nvidia_ctl_cdevsw.d_name),
25
+        .linux_device_name = __DECONST(char *, nvidia_ctl_cdevsw.d_name),
26
+        .linux_major = NV_MAJOR_DEVICE_NUMBER,
27
+        .linux_minor = 255,
28
+        .linux_char_device = 1
29
+    };
30
+#endif
31
+
32
     if (nvidia_count == 0) {
33
         nvidia_ctl_cdev = make_dev(&nvidia_ctl_cdevsw,
34
                 CDEV_CTL_MINOR,
35
@@ -169,6 +187,10 @@ int nvidia_ctl_attach(void)
36
                 "%s", nvidia_ctl_cdevsw.d_name);
37
         if (nvidia_ctl_cdev == NULL)
38
             return ENOMEM;
39
+
40
+#ifdef NV_SUPPORT_LINUX_COMPAT
41
+        (void)linux_device_register_handler(&nvidia_ctl_linux_handler);
42
+#endif
43
     }
44
 
45
     nvidia_count++;
46
@@ -177,10 +199,26 @@ int nvidia_ctl_attach(void)
47
 
48
 int nvidia_ctl_detach(void)
49
 {
50
+#ifdef NV_SUPPORT_LINUX_COMPAT
51
+    struct linux_device_handler nvidia_ctl_linux_handler = {
52
+        .bsd_driver_name = __DECONST(char *, nvidia_driver_name),
53
+        .linux_driver_name = __DECONST(char *, nvidia_driver_name),
54
+        .bsd_device_name = __DECONST(char *, nvidia_ctl_cdevsw.d_name),
55
+        .linux_device_name = __DECONST(char *, nvidia_ctl_cdevsw.d_name),
56
+        .linux_major = NV_MAJOR_DEVICE_NUMBER,
57
+        .linux_minor = 255,
58
+        .linux_char_device = 1
59
+    };
60
+#endif
61
+
62
     nvidia_count--;
63
 
64
-    if (nvidia_count == 0)
65
+    if (nvidia_count == 0) {
66
+#ifdef NV_SUPPORT_LINUX_COMPAT
67
+        (void)linux_device_unregister_handler(&nvidia_ctl_linux_handler);
68
+#endif
69
         destroy_dev(nvidia_ctl_cdev);
70
+    }
71
 
72
     return 0;
73
 }

Return to bug 249505