thinkpad_acpi: Add support for battery thresholds
PATCH v7 2/3 thinkpad_acpi: Add support for battery thresholds
thinkpad_acpi registers two new attributes for each battery:
1) Charge start threshold /sys/class/power_supply/BATN/charge_start_threshold
Valid values are [0, 99]. A value of 0 turns off the start threshold wear control.
2) Charge stop threshold /sys/class/power_supply/BATN/charge_stop_threshold
Valid values are [1, 100]. A value of 100 turns off the stop threshold wear control. This must be configured first.
This patch depends on the following patches:
"battery: Add the battery hooking API"
v2:
* Re-write the patch to make the changes inbattery.c generic as suggested by Rafael
v3:
* Fixed a bug where you could not set the stop threshold to 100% when the start threshold is 0%
* Fixed the "Not Charging" quirk to match Lenovo's BIOS Firmware specification
v4:
* Fixed a bug where you could not set the start
threshold to >stop if stop was 100%
v5:
* Migrated from symbol_get to native linking,
to fix module dependencies
* Fixed a bug where unloading the module would
cause a BUG inside battery
* Fixed a bug where you could unload battery
before unloading thinkpad_acpi
v6:
* Fixed all the style and naming issues pointed
out by Andy Shevchenko
v7:
* No changes in this patch in v7
--- drivers/platform/x86/Kconfig | 1 + drivers/platform/x86/thinkpad_acpi.c | 442 ++++++++++++++++++++++++++++++++++- include/linux/power_supply.h | 2 + 3 files changed, 444 insertions(+), 1 deletion(-)
drivers/platform/x86/Kconfig +1 -0
@@ -399,6 +399,7 @@ config SURFACE3_WMI config THINKPAD_ACPI tristate "ThinkPad ACPI Laptop Extras" depends on ACPI + depends on ACPI_BATTERY depends on INPUT depends on RFKILL || RFKILL = n depends on ACPI_VIDEO || ACPI_VIDEO = n
drivers/platform/x86/thinkpad_acpi.c +441 -1
485 lines not on this page · raw message
include/linux/power_supply.h +2 -0
@@ -371,6 +371,8 @@ devm_power_supply_register_no_ws(struct device *parent,extern void power_supply_unregister (struct power_supply *psy);extern int power_supply_powers (struct power_supply *psy,struct device *dev); +#define to_power_supply (device) container_of(device, struct power_supply, dev) +extern void *power_supply_get_drvdata (struct power_supply *psy);/* For APM emulation, think legacy userspace. */ extern struct class *power_supply_class;
Signature · 1 line
2.7.4
kbuild test robot
build botThank you for the patch! Yet something to improve:
Hi Ognjen,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on platform-drivers-x86/for-next]
[also build test ERROR on v4.15-rc4 next-20171222]
[cannot apply to pm/linux-next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Ognjen-Galic/battery-Add-the-battery-hooking-API/20171223-144855 base: git://git.infradead.org/users/dvhart/linux-platform-drivers-x86.git for-next config: x86_64-acpi-redef (attached as .config) compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025 reproduce: # save the attached .config to linux build tree make ARCH=x86_64
All errors (new ones prefixed by >>):
In file included from include/linux/list.h:9:0,
from include/linux/module.h:9,
from drivers/power/supply/ds2780_battery.c:16:
>> include/linux/kernel.h:928:42: error: expected identifier or '(' before '{' token
#define container_of(ptr, type, member) ({ \
^
include/linux/power_supply.h:374:33: note: in expansion of macro 'container_of'
#define to_power_supply(device) container_of(device, struct power_supply, dev)
^~~~~~~~~~~~ drivers/power/supply/ds2780_battery.c:59:36: note: in expansion of macro 'to_power_supply'
static inline struct power_supply *to_power_supply(struct device *dev)
^~~~~~~~~~~~~~~
--
In file included from include/linux/list.h:9:0,
from include/linux/module.h:9,
from drivers/power/supply/ds2781_battery.c:14:
>> include/linux/kernel.h:928:42: error: expected identifier or '(' before '{' token
#define container_of(ptr, type, member) ({ \
^
include/linux/power_supply.h:374:33: note: in expansion of macro 'container_of'
#define to_power_supply(device) container_of(device, struct power_supply, dev)
^~~~~~~~~~~~ drivers/power/supply/ds2781_battery.c:57:36: note: in expansion of macro 'to_power_supply'
static inline struct power_supply *to_power_supply(struct device *dev)
^~~~~~~~~~~~~~~
--
In file included from include/linux/list.h:9:0,
from include/linux/module.h:9,
from drivers/power//supply/ds2780_battery.c:16:
>> include/linux/kernel.h:928:42: error: expected identifier or '(' before '{' token
#define container_of(ptr, type, member) ({ \
^
include/linux/power_supply.h:374:33: note: in expansion of macro 'container_of'
#define to_power_supply(device) container_of(device, struct power_supply, dev)
^~~~~~~~~~~~ drivers/power//supply/ds2780_battery.c:59:36: note: in expansion of macro 'to_power_supply'
static inline struct power_supply *to_power_supply(struct device *dev)
^~~~~~~~~~~~~~~
--
In file included from include/linux/list.h:9:0,
from include/linux/module.h:9,
from drivers/power//supply/ds2781_battery.c:14:
>> include/linux/kernel.h:928:42: error: expected identifier or '(' before '{' token
#define container_of(ptr, type, member) ({ \
^
include/linux/power_supply.h:374:33: note: in expansion of macro 'container_of'
#define to_power_supply(device) container_of(device, struct power_supply, dev)
^~~~~~~~~~~~ drivers/power//supply/ds2781_battery.c:57:36: note: in expansion of macro 'to_power_supply'
static inline struct power_supply *to_power_supply(struct device *dev)
^~~~~~~~~~~~~~~
vim +928 include/linux/kernel.h
^1da177e4 Linus Torvalds 2005-04-16 911
91f68b735 Wu Fengguang 2009-01-07 912
e8c97af0c Randy Dunlap 2017-10-13 913 /**
e8c97af0c Randy Dunlap 2017-10-13 914 * swap - swap values of @a and @b
e8c97af0c Randy Dunlap 2017-10-13 915 * @a: first value
e8c97af0c Randy Dunlap 2017-10-13 916 * @b: second value
91f68b735 Wu Fengguang 2009-01-07 917 */
ac7b90049 Peter Zijlstra 2009-02-04 918 #define swap(a, b) \
ac7b90049 Peter Zijlstra 2009-02-04 919 do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
91f68b735 Wu Fengguang 2009-01-07 920
^1da177e4 Linus Torvalds 2005-04-16 921 /**
^1da177e4 Linus Torvalds 2005-04-16 922 * container_of - cast a member of a structure out to the containing structure
^1da177e4 Linus Torvalds 2005-04-16 923 * @ptr: the pointer to the member.
^1da177e4 Linus Torvalds 2005-04-16 924 * @type: the type of the container struct this is embedded in.
^1da177e4 Linus Torvalds 2005-04-16 925 * @member: the name of the member within the struct.
^1da177e4 Linus Torvalds 2005-04-16 926 *
^1da177e4 Linus Torvalds 2005-04-16 927 */
^1da177e4 Linus Torvalds 2005-04-16 @928 #define container_of(ptr, type, member) ({ \
c7acec713 Ian Abbott 2017-07-12 929 void *__mptr = (void *)(ptr); \
c7acec713 Ian Abbott 2017-07-12 930 BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
c7acec713 Ian Abbott 2017-07-12 931 !__same_type(*(ptr), void), \
c7acec713 Ian Abbott 2017-07-12 932 "pointer type mismatch in container_of()"); \
c7acec713 Ian Abbott 2017-07-12 933 ((type *)(__mptr - offsetof(type, member))); })^1da177e4 Linus Torvalds 2005-04-16 934
:::::: The code at line 928 was first introduced by commit :::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2
:::::: TO: Linus Torvalds <torvalds(a)ppc970.osdl.org> :::::: CC: Linus Torvalds <torvalds(a)ppc970.osdl.org>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation