Commit 1658c4b7 authored by Adithya R's avatar Adithya R Committed by arnavpuranik
Browse files

drivers/misc: Introduce kernelspace battery saver mode

Signed-off-by: notzeetaa's avatarNotZeetaa <>
Signed-off-by: arnavpuranik's avatararnavpuranik <>
parent 192f7748
......@@ -593,6 +593,20 @@ config FORCE_FAST_CHARGE
This allows users to override default charge rate for USB
bool "Battery saver mode for kernelspace"
default y
This driver creates a sysfs toggle that can be enabled when
battery saver mode is activated in userspace, and provides
functions to check the status of battery saver and to activate
it from anywhere in the kernel.
The former can be used to disable features that may otherwise
drain battery faster, such as CPU and DDR boosting.
If in doubt, say Y.
source "drivers/misc/c2port/Kconfig"
source "drivers/misc/eeprom/Kconfig"
source "drivers/misc/cb710/Kconfig"
......@@ -68,3 +68,4 @@ obj-$(CONFIG_QPNP_MISC) += qpnp-misc.o
obj-$(CONFIG_MEMORY_STATE_TIME) += memory_state_time.o
obj-$(CONFIG_ANT_CHECK) += ant_check.o
obj-$(CONFIG_FORCE_FAST_CHARGE) += fastchg.o
obj-$(CONFIG_BATTERY_SAVER) += battery_saver.o
// SPDX-License-Identifier: GPL-2.0
* Copyright (C) 2020 Adithya R <>.
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/battery_saver.h>
static bool enabled = false;
module_param(enabled, bool, 0644);
// returns whether battery saver is enabled or disabled
bool is_battery_saver_on(void)
return enabled;
// enable or disable battery saver mode
void update_battery_saver(bool status)
enabled = status;
\ No newline at end of file
// SPDX-License-Identifier: GPL-2.0
* Copyright (C) 2020 Adithya R <>.
#include <linux/types.h>
bool is_battery_saver_on(void);
void enable_battery_saver(bool status);
static inline bool is_battery_saver_on()
return false;
static inline void update_battery_saver(bool status)
#endif /* _BATTERY_SAVER_H_ */
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment