After twiddling LEDs with /sys/class/leds/
, I'm now trying to understand how to control the battery in my computer with linux kernel power supply attributes, specifically CHARGE_CONTROL_LIMIT
. However, no such attribute exists in /sys/class/power_supply/BAT0/
.
How I've tried to answer this question:
From what I understand reading man 5 sysfs
, sysfs
(usually mounted as sys
) is an interface between userspace and kernelspace.
Hypothesis:
There exists a kernel module that creates and updates the contents of
/sys/class/power_supply/BAT0/
That kernel module may, but does not seem to implement
CHARGE_CONTROL_LIMIT
. It does implement other attributes:
cat /sys/class/power_supply/BAT0/charge_full
2884000
cat /sys/class/power_supply/BAT0/charge_now
2884000
cat /sys/class/power_supply/BAT0/cycle_count
0 <--- this seems broken
cat /sys/class/power_supply/BAT0/capacity
100
To test this hypothesis, I sought the documentation/source of the responsible kernel module.
A hang-up: Trying to find the kernel module that's responsible for /sys/class/power_supply/BAT0/
ArchWiki and this page demonstrate how to look-up a kernel module, given a modalias
.
cat /sys/class/power_supply/BAT0/device/modalias
acpi:PNP0C0A:
sudo grep -E 'PNP0C0A' /lib/modules/*/modules.alias
# nothing is found
I see that the battery hardware is of type acpi
, however, there's no exact match for its modalias
in modules.alias
. (I tried a a few combinations of wildcards to find it, to no avail).
@0andriy suggested checking /drivers/platform/x86
, which I did as follows:
find /lib/modules/5.0.0-15-generic/kernel -type f -name '*.ko' | xargs modinfo | grep -E 'alias.*PNP0C0A'
# Nothing
# Trying another query, to check that the query works:
find /lib/modules/5.0.0-15-generic/kernel/drivers -type f -name '*.ko' | xargs modinfo | grep -E 'alias.*TOS'
alias: acpi*:TOS1900:*
alias: acpi*:TOS6208:*
alias: acpi*:TOS6207:*
alias: acpi*:TOS6200:*
This is an HP laptop with a recent kernel
uname -a
Linux lithium 5.0.0-15-generic #16-Ubuntu SMP Mon May 6 17:41:33 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux