diff options
author | Matheus Castello <matheus@castello.eng.br> | 2019-12-05 12:44:10 -0300 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2019-12-19 01:51:52 +0100 |
commit | a08990ea11dc3386cc972c817a121525f7bc7321 (patch) | |
tree | f9558b46af836030faf696b6e506b962c12aa076 /drivers/power | |
parent | cccdd0ca1c0d985c3cf1dfe65a3b42387a6e3d22 (diff) | |
download | linux-stable-a08990ea11dc3386cc972c817a121525f7bc7321.tar.gz linux-stable-a08990ea11dc3386cc972c817a121525f7bc7321.tar.bz2 linux-stable-a08990ea11dc3386cc972c817a121525f7bc7321.zip |
power: supply: max17040: Send uevent in SOC and status change
Notify core through power_supply_changed() in case of changes in state
of charge and power supply status. This is useful for user-space to
efficiently update current battery level.
Signed-off-by: Matheus Castello <matheus@castello.eng.br>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/supply/max17040_battery.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c index 2a2a1fd8d4eb..c1188e94cf54 100644 --- a/drivers/power/supply/max17040_battery.c +++ b/drivers/power/supply/max17040_battery.c @@ -207,10 +207,19 @@ static void max17040_check_changes(struct i2c_client *client) static void max17040_work(struct work_struct *work) { struct max17040_chip *chip; + int last_soc, last_status; chip = container_of(work, struct max17040_chip, work.work); + + /* store SOC and status to check changes */ + last_soc = chip->soc; + last_status = chip->status; max17040_check_changes(chip->client); + /* check changes and send uevent */ + if (last_soc != chip->soc || last_status != chip->status) + power_supply_changed(chip->battery); + queue_delayed_work(system_power_efficient_wq, &chip->work, MAX17040_DELAY); } |