Skip to content

Commit

Permalink
kernel: refine get_ksu_state()
Browse files Browse the repository at this point in the history
Using int for get_ksu_state is not effective.
Instead we should use boolean value instead because its more easy
and simple things up.

get_ksu_state() will return true if enable_kernelsu greater or equal than 1.
and return false if enable_kernelsu less than 1.

previously:
if (get_ksu_state() < 1)

now:
if (!get_ksu_state())

Signed-off-by: rsuntk <[email protected]>
  • Loading branch information
rsuntk committed Feb 8, 2025
1 parent b734732 commit c3ebf95
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions kernel/ksu.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#ifdef CONFIG_KSU_CMDLINE
#include <linux/init.h>

// use get_ksu_state()!
unsigned int enable_kernelsu = 1; // enabled by default

static int __init read_kernelsu_state(char *s)
{
if (s)
Expand All @@ -24,16 +24,9 @@ static int __init read_kernelsu_state(char *s)
}
__setup("kernelsu.enabled=", read_kernelsu_state);

unsigned int get_ksu_state(void)
{
return enable_kernelsu;
}

bool get_ksu_state(void) { return enable_kernelsu >= 1; }
#else
unsigned int get_ksu_state(void)
{
return 1;
}
bool get_ksu_state(void) { return true; }
#endif /* CONFIG_KSU_CMDLINE */

static struct workqueue_struct *ksu_workqueue;
Expand Down Expand Up @@ -65,7 +58,7 @@ extern void ksu_ksud_exit();
int __init kernelsu_init(void)
{
#ifdef CONFIG_KSU_CMDLINE
if (enable_kernelsu < 1) {
if (!get_ksu_state()) {
pr_info_once("drivers is disabled.");
return 0;
}
Expand Down Expand Up @@ -106,8 +99,9 @@ int __init kernelsu_init(void)
void kernelsu_exit(void)
{
#ifdef CONFIG_KSU_CMDLINE
if (enable_kernelsu < 1)
if (!get_ksu_state()) {
return;
}
#endif
ksu_allowlist_exit();

Expand Down

0 comments on commit c3ebf95

Please sign in to comment.