Commit a08990ea authored by Matheus Castello's avatar Matheus Castello Committed by Sebastian Reichel

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: default avatarMatheus Castello <matheus@castello.eng.br>
Reviewed-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent cccdd0ca
......@@ -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);
}
......
Markdown is supported
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