summarylogtreecommitdiffstats
path: root/0011-kernel-6.0.patch
blob: 6499fa2bb23b9d805ac8891abd47057364c0b121 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
--- a/kernel/nv-acpi.c	2020-01-01 00:00:00.000000000 +0000
+++ b/kernel/nv-acpi.c	2020-01-01 00:00:00.000000000 +0000
@@ -190,9 +190,9 @@
     union acpi_object control_argument_0 = { ACPI_TYPE_INTEGER };
     struct acpi_object_list control_argument_list = { 0, NULL };
     nv_stack_t *sp = NULL;
-    struct list_head *node, *next;
     nv_acpi_integer_t device_id = 0;
     int device_counter = 0;
+    acpi_handle handle = NULL;
 
     NV_KMEM_CACHE_ALLOC_STACK(sp);
     if (sp == NULL)
@@ -220,13 +220,12 @@
 
     // grab handles to all the important nodes representing devices
 
-    list_for_each_safe(node, next, &device->children) 
+    do
     {
-        struct acpi_device *dev =
-            list_entry(node, struct acpi_device, node);
-
-        if (!dev)
-            continue;
+        status = acpi_get_next_object(ACPI_TYPE_DEVICE, device->handle,
+                                      handle, &handle);
+        if (ACPI_FAILURE(status) || (handle == NULL))
+            break;
 
         if (device_counter == NV_MAXNUM_DISPLAY_DEVICES)
         {
@@ -237,7 +236,7 @@
         }
 
         status =
-            acpi_evaluate_integer(dev->handle, "_ADR", NULL, &device_id);
+            acpi_evaluate_integer(handle, "_ADR", NULL, &device_id);
         if (ACPI_FAILURE(status))
             /* Couldnt query device_id for this device */
             continue;
@@ -256,11 +255,11 @@
         }
 
         pNvAcpiObject->pNvVideo[device_counter].dev_id = device_id;
-        pNvAcpiObject->pNvVideo[device_counter].dev_handle = dev->handle;
+        pNvAcpiObject->pNvVideo[device_counter].dev_handle = handle;
     
         device_counter++;
 
-    }
+    } while (handle != NULL);
 
     // arg 0, bits 1:0, 0 = enable events
     control_argument_0.integer.type = ACPI_TYPE_INTEGER;
@@ -1202,16 +1201,15 @@
 )
 {
     acpi_status status;
-    struct acpi_device *device = NULL;
     struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
     union acpi_object *ddc;
     union acpi_object ddc_arg0 = { ACPI_TYPE_INTEGER };
     struct acpi_object_list input = { 1, &ddc_arg0 };
-    struct list_head *node, *next;
     nv_acpi_integer_t device_id = 0;
     NvU32 i;
     acpi_handle dev_handle  = NULL;
     acpi_handle lcd_dev_handle  = NULL;
+    acpi_handle handle = NULL;
 
     if (!nv_acpi_get_device_handle(nv, &dev_handle))
         return RM_ERR_NOT_SUPPORTED;
@@ -1219,16 +1217,6 @@
     if (!dev_handle)
         return RM_ERR_INVALID_ARGUMENT;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
-    device = acpi_fetch_acpi_dev(dev_handle);
-    status = 0;
-#else
-    status = acpi_bus_get_device(dev_handle, &device);
-#endif
-
-    if (ACPI_FAILURE(status) || !device)
-        return RM_ERR_INVALID_ARGUMENT;
-
     if (!NV_MAY_SLEEP())
     {
 #if defined(DEBUG)
@@ -1239,15 +1227,15 @@
         return RM_ERR_NOT_SUPPORTED;
     }
 
-    list_for_each_safe(node, next, &device->children) 
+    while (lcd_dev_handle == NULL)
     {
-        struct acpi_device *dev =
-            list_entry(node, struct acpi_device, node);
+        status = acpi_get_next_object(ACPI_TYPE_DEVICE, dev_handle,
+                                      handle, &handle);
+        if (ACPI_FAILURE(status) || (handle == NULL))
+            break;
 
-        if (!dev)
-            continue;
+        status = acpi_evaluate_integer(handle, "_ADR", NULL, &device_id);
 
-        status = acpi_evaluate_integer(dev->handle, "_ADR", NULL, &device_id);
         if (ACPI_FAILURE(status))
             /* Couldnt query device_id for this device */
             continue;
@@ -1256,7 +1244,7 @@
 
         if ((device_id == 0x0110) || (device_id == 0x0118) || (device_id == 0x0400)) /* Only for an LCD*/
         {
-            lcd_dev_handle = dev->handle;
+            lcd_dev_handle = handle;
             nv_printf(NV_DBG_INFO, "NVRM: %s Found LCD: %x\n", __FUNCTION__, device_id);
             break;
         }