File tree Expand file tree Collapse file tree 4 files changed +61
-0
lines changed
Expand file tree Collapse file tree 4 files changed +61
-0
lines changed Original file line number Diff line number Diff line change @@ -606,6 +606,19 @@ config FORCE_FAST_CHARGE
606606 help
607607 This allows users to override default charge rate for USB
608608
609+ config BATTERY_SAVER
610+ bool "Battery saver mode for kernelspace"
611+ help
612+ This driver creates a sysfs toggle that can be enabled when
613+ battery saver mode is activated in userspace, and provides
614+ functions to check the status of battery saver and to activate
615+ it from anywhere in the kernel.
616+
617+ The former can be used to disable features that may otherwise
618+ drain battery faster, such as CPU and DDR boosting.
619+
620+ If in doubt, say N.
621+
609622source "drivers/misc/c2port/Kconfig"
610623source "drivers/misc/eeprom/Kconfig"
611624source "drivers/misc/cb710/Kconfig"
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ obj-$(CONFIG_UID_SYS_STATS) += uid_sys_stats.o
6666obj-$(CONFIG_MEMORY_STATE_TIME) += memory_state_time.o
6767obj-$(CONFIG_QPNP_MISC) += qpnp-misc.o
6868obj-$(CONFIG_ANT_CHECK) += ant_check.o
69+ obj-$(CONFIG_BATTERY_SAVER) += battery_saver.o
6970
7071obj-$(CONFIG_OKL4_USER_VIRQ) += okl4-virq.o
7172obj-$(CONFIG_OKL4_RINGBUF) += okl4-ringbuf.o
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: GPL-2.0
2+ /*
3+ * Copyright (C) 2020 Adithya R <gh0strider.2k18.reborn@gmail.com>.
4+ */
5+
6+ #include <linux/module.h>
7+ #include <linux/moduleparam.h>
8+ #include <linux/battery_saver.h>
9+
10+ static bool enabled = false;
11+ module_param (enabled , bool , 0644 );
12+
13+ // returns whether battery saver is enabled or disabled
14+ bool is_battery_saver_on (void )
15+ {
16+ return enabled ;
17+ }
18+
19+ // enable or disable battery saver mode
20+ void update_battery_saver (bool status )
21+ {
22+ enabled = status ;
23+ }
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: GPL-2.0
2+ /*
3+ * Copyright (C) 2020 Adithya R <gh0strider.2k18.reborn@gmail.com>.
4+ */
5+
6+ #ifndef _BATTERY_SAVER_H_
7+ #define _BATTERY_SAVER_H_
8+
9+ #include <linux/types.h>
10+
11+ #ifdef CONFIG_BATTERY_SAVER
12+ bool is_battery_saver_on (void );
13+ void enable_battery_saver (bool status );
14+ #else
15+ static inline bool is_battery_saver_on ()
16+ {
17+ return false;
18+ }
19+ static inline void update_battery_saver (bool status )
20+ {
21+ }
22+ #endif
23+
24+ #endif /* _BATTERY_SAVER_H_ */
You can’t perform that action at this time.
0 commit comments