forked from 80501/iwl20x_ax_enable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iwl20x_ax_en.c
86 lines (73 loc) · 1.81 KB
/
iwl20x_ax_en.c
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
/* SPDX-License-Identifier: GPL-2.0 */
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/livepatch.h>
#include <linux/uuid.h>
#define AX_UKRAINE_ENABLE 0x03
#define AX_RUSSIA_ENABLE 0x0c
#define AX_ENABLE_BITMAP AX_UKRAINE_ENABLE|AX_RUSSIA_ENABLE
#define DSM_FUNC_11AX_ENABLEMENT 0x06
#define MCC "ID"
int new_iwl_acpi_get_dsm_u32(struct device *dev, int rev, int func,
const guid_t *guid, u32 *value);
#ifdef MCC
int new_iwl_acpi_get_mcc(struct device *dev, char *mcc);
#endif
const guid_t iwl1_guid = GUID_INIT(0xF21202BF, 0x8F78, 0x4DC6,
0xA5, 0xB3, 0x1F, 0x73,
0x8E, 0x28, 0x5A, 0xDE);
static struct klp_func funcs[] = {
{
.old_name = "iwl_acpi_get_dsm_u32",
.new_func = new_iwl_acpi_get_dsm_u32,
},
#ifdef MCC
{
.old_name = "iwl_acpi_get_mcc",
.new_func = new_iwl_acpi_get_mcc,
},
#endif
{ }
};
static struct klp_object objs[] = {
{
.name = "iwlwifi",
.funcs = funcs,
}, { }
};
static struct klp_patch patch = {
.mod = THIS_MODULE,
.objs = objs,
};
int new_iwl_acpi_get_dsm_u32(struct device *dev, int rev, int func,
const guid_t *guid, u32 *value)
{
if ((func == DSM_FUNC_11AX_ENABLEMENT)&&(guid_equal(guid, &iwl1_guid)))
{
*value = AX_ENABLE_BITMAP;
return 0;
}
return ((int (*)(struct device *, int, int, const guid_t *,
u32 *))((funcs->old_func)+MCOUNT_INSN_SIZE))(dev,
rev, func, guid, value);
}
#ifdef MCC
int new_iwl_acpi_get_mcc(struct device *dev, char *mcc)
{
strncpy(mcc, MCC, 3);
return 0;
}
#endif
static int livepatch_init(void)
{
return klp_enable_patch(&patch);
}
static void livepatch_exit(void)
{
}
module_init(livepatch_init);
module_exit(livepatch_exit);
MODULE_SOFTDEP("post: iwlwifi");
MODULE_LICENSE("GPL");
MODULE_INFO(livepatch, "Y");
MODULE_DESCRIPTION("This patch overrides _DSM and WRDD ACPI methods for iwlwifi device");