Skip to contentSkip to conversation

bq24190_charger: no status updates

PATCH In review Thomas Elste 2 participants 3 messages May 28, 2015 – May 29, 2015

lore
Share & tools
lore
#0 lore raw

Hi,

while searching for the cause of charger events not being detected on a custom board with a BQ24190 charger, I think a found a minor problem in its driver:

The bq24190_charger driver uses a flag for preventing the first change in charger status, which is generated by an initial register clear, to reach power supply subsystem via power_supply_changed. This flag is set in the probe function and is supposed to be reset after a first status change. This never happens as the condition for reset depends already on the flag not being set.

I made a short patch which changes the flags reset condition.

Best regards
Thomas

#1 lore raw

PATCH 1/1 power: bq24190_charger: Change first_time flag reset condition

The initial register reset of BQ24190 generates a charger status change whose propagation via power_supply_changed is prevented using a flag. This flag gets never reset so all following events are ignored as well leading for example to userspace not detecting charger connects/disconnects.

Therefor change the reset condition of first_time flag, so only the propagation of the first charger status change is prevented.

---
 drivers/power/bq24190_charger.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/power/bq24190_charger.c +7 -4
index 407c4af..052db78 100644
@@ -1258,10 +1258,13 @@ static irqreturn_t bq24190_irq_handler_thread(int irq, void *data)
 	 * register reset so we should ignore that one (the very first
 	 * interrupt received).
 	 */
-	if (alert_userspace && !bdi->first_time) {
-		power_supply_changed(bdi->charger);
-		power_supply_changed(bdi->battery);
-		bdi->first_time = false;
+	if (alert_userspace) {
+		if (!bdi->first_time) {
+			power_supply_changed(bdi->charger);
+			power_supply_changed(bdi->battery);
+		} else {
+			bdi->first_time = false;
+		}
 	}
 
 out:
Signature · 1 line
2.0.5
#2 lore raw

Re: [PATCH] power: bq24190_charger: Change first_time flag reset condition

Hi,

Quoted 25 lines · Thomas Elste

The initial register reset of BQ24190 generates a charger status change whose propagation via power_supply_changed is prevented using a flag. This flag gets never reset so all following events are ignored as well leading for example to userspace not detecting charger connects/disconnects.

Therefor change the reset condition of first_time flag, so only the propagation of the first charger status change is prevented.

---
 drivers/power/bq24190_charger.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/power/bq24190_charger.c +0 -4
index 407c4af..052db78 100644
@@ -1258,10 +1258,13 @@ static irqreturn_t bq24190_irq_handler_thread(int irq, void *data)
 	 * register reset so we should ignore that one (the very first
 	 * interrupt received).
 	 */
-	if (alert_userspace && !bdi->first_time) {
-		power_supply_changed(bdi->charger);
-		power_supply_changed(bdi->battery);
-		bdi->first_time = false;

drivers/power/bq24190_charger.c static irqreturn_t bq24190_irq_handler_thread(int irq, void *data) · line 1270

Quoted 10 lines
drivers/power/bq24190_charger.c +7 -0
+	if (alert_userspace) {
+		if (!bdi->first_time) {
+			power_supply_changed(bdi->charger);
+			power_supply_changed(bdi->battery);
+		} else {
+			bdi->first_time = false;
+		}
 	}
 
 out:

Thanks, queued for 4.2.

-- Sebastian