Skip to content

Commit 5972da7

Browse files
sicelosre
authored andcommitted
power: supply: bq2415x_charger: report charging state changes to userspace
Continuously track the charging status register in order to send uevents whenever the state changes. Generate an uevent also when the chip's OTG line is toggled, in bq2415x_notifier_call(). Signed-off-by: Sicelo A. Mhlongo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 525f6a2 commit 5972da7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/power/supply/bq2415x_charger.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ struct bq2415x_device {
171171
char *name;
172172
int autotimer; /* 1 - if driver automatically reset timer, 0 - not */
173173
int automode; /* 1 - enabled, 0 - disabled; -1 - not supported */
174+
int charge_status;
174175
int id;
175176
};
176177

@@ -835,6 +836,8 @@ static int bq2415x_notifier_call(struct notifier_block *nb,
835836
if (!bq2415x_update_reported_mode(bq, prop.intval))
836837
return NOTIFY_OK;
837838

839+
power_supply_changed(bq->charger);
840+
838841
/* if automode is not enabled do not tell about reported_mode */
839842
if (bq->automode < 1)
840843
return NOTIFY_OK;
@@ -889,12 +892,19 @@ static void bq2415x_timer_work(struct work_struct *work)
889892
int ret;
890893
int error;
891894
int boost;
895+
int charge;
892896

893897
if (bq->automode > 0 && (bq->reported_mode != bq->mode)) {
894898
sysfs_notify(&bq->charger->dev.kobj, NULL, "reported_mode");
895899
bq2415x_set_mode(bq, bq->reported_mode);
896900
}
897901

902+
charge = bq2415x_exec_command(bq, BQ2415X_CHARGE_STATUS);
903+
if (bq->charge_status != charge) {
904+
power_supply_changed(bq->charger);
905+
bq->charge_status = charge;
906+
}
907+
898908
if (!bq->autotimer)
899909
return;
900910

0 commit comments

Comments
 (0)