forked from WildKernels/GKI_KernelSU_SUSFS
-
Notifications
You must be signed in to change notification settings - Fork 789
Expand file tree
/
Copy pathhmbird_patch.c
More file actions
78 lines (72 loc) · 2.09 KB
/
hmbird_patch.c
File metadata and controls
78 lines (72 loc) · 2.09 KB
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
#include <linux/init.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/slab.h>
#include <linux/string.h>
static int __init hmbird_patch_init(void)
{
struct device_node *ver_np;
const char *type;
int ret;
ver_np = of_find_node_by_path("/soc/oplus,hmbird/version_type");
if (!ver_np)
{
pr_info("hmbird_patch: version_type node not found\n");
return 0;
}
ret = of_property_read_string(ver_np, "type", &type);
if (ret)
{
pr_info("hmbird_patch: type property not found\n");
of_node_put(ver_np);
return 0;
}
if (strcmp(type, "HMBIRD_OGKI"))
{
of_node_put(ver_np);
return 0;
}
struct property *prop = of_find_property(ver_np, "type", NULL);
if (prop)
{
struct property *new_prop = kmalloc(sizeof(*prop), GFP_KERNEL);
if (!new_prop)
{
pr_info("hmbird_patch: kmalloc for new_prop failed\n");
of_node_put(ver_np);
return 0;
}
memcpy(new_prop, prop, sizeof(*prop));
new_prop->value = kmalloc(strlen("HMBIRD_GKI") + 1, GFP_KERNEL);
if (!new_prop->value)
{
pr_info("hmbird_patch: kmalloc for new_prop->value failed\n");
kfree(new_prop);
of_node_put(ver_np);
return 0;
}
strcpy(new_prop->value, "HMBIRD_GKI");
new_prop->length = strlen("HMBIRD_GKI") + 1;
if (of_remove_property(ver_np, prop) != 0)
{
pr_info("hmbird_patch: of_remove_property failed\n");
return 0;
}
if (of_add_property(ver_np, new_prop) != 0)
{
pr_info("hmbird_patch: of_add_property failed\n");
return 0;
}
pr_info("hmbird_patch: success from HMBIRD_OGKI to HMBIRD_GKI\n");
}
else
{
pr_info("hmbird_patch: type property structure not found\n");
}
of_node_put(ver_np);
return 0;
}
early_initcall(hmbird_patch_init);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("reigadegr");
MODULE_DESCRIPTION("Forcefully convert HMBIRD_OGKI to HMBIRD_GKI.");