aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power/da9030_battery.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/power/da9030_battery.c')
-rw-r--r--drivers/power/da9030_battery.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/power/da9030_battery.c b/drivers/power/da9030_battery.c
index 1662bb0f23a5..3364198134a1 100644
--- a/drivers/power/da9030_battery.c
+++ b/drivers/power/da9030_battery.c
@@ -22,8 +22,6 @@
22#include <linux/debugfs.h> 22#include <linux/debugfs.h>
23#include <linux/seq_file.h> 23#include <linux/seq_file.h>
24 24
25#define DA9030_STATUS_CHDET (1 << 3)
26
27#define DA9030_FAULT_LOG 0x0a 25#define DA9030_FAULT_LOG 0x0a
28#define DA9030_FAULT_LOG_OVER_TEMP (1 << 7) 26#define DA9030_FAULT_LOG_OVER_TEMP (1 << 7)
29#define DA9030_FAULT_LOG_VBAT_OVER (1 << 4) 27#define DA9030_FAULT_LOG_VBAT_OVER (1 << 4)
@@ -244,6 +242,8 @@ static void da9030_set_charge(struct da9030_charger *charger, int on)
244 } 242 }
245 243
246 da903x_write(charger->master, DA9030_CHARGE_CONTROL, val); 244 da903x_write(charger->master, DA9030_CHARGE_CONTROL, val);
245
246 power_supply_changed(&charger->psy);
247} 247}
248 248
249static void da9030_charger_check_state(struct da9030_charger *charger) 249static void da9030_charger_check_state(struct da9030_charger *charger)
@@ -258,6 +258,12 @@ static void da9030_charger_check_state(struct da9030_charger *charger)
258 da9030_set_charge(charger, 1); 258 da9030_set_charge(charger, 1);
259 } 259 }
260 } else { 260 } else {
261 /* Charger has been pulled out */
262 if (!charger->chdet) {
263 da9030_set_charge(charger, 0);
264 return;
265 }
266
261 if (charger->adc.vbat_res >= 267 if (charger->adc.vbat_res >=
262 charger->thresholds.vbat_charge_stop) { 268 charger->thresholds.vbat_charge_stop) {
263 da9030_set_charge(charger, 0); 269 da9030_set_charge(charger, 0);
@@ -395,13 +401,11 @@ static int da9030_battery_event(struct notifier_block *nb, unsigned long event,
395{ 401{
396 struct da9030_charger *charger = 402 struct da9030_charger *charger =
397 container_of(nb, struct da9030_charger, nb); 403 container_of(nb, struct da9030_charger, nb);
398 int status;
399 404
400 switch (event) { 405 switch (event) {
401 case DA9030_EVENT_CHDET: 406 case DA9030_EVENT_CHDET:
402 status = da903x_query_status(charger->master, 407 cancel_delayed_work_sync(&charger->work);
403 DA9030_STATUS_CHDET); 408 schedule_work(&charger->work.work);
404 da9030_set_charge(charger, status);
405 break; 409 break;
406 case DA9030_EVENT_VBATMON: 410 case DA9030_EVENT_VBATMON:
407 da9030_battery_vbat_event(charger); 411 da9030_battery_vbat_event(charger);
@@ -565,7 +569,8 @@ static int da9030_battery_remove(struct platform_device *dev)
565 da903x_unregister_notifier(charger->master, &charger->nb, 569 da903x_unregister_notifier(charger->master, &charger->nb,
566 DA9030_EVENT_CHDET | DA9030_EVENT_VBATMON | 570 DA9030_EVENT_CHDET | DA9030_EVENT_VBATMON |
567 DA9030_EVENT_CHIOVER | DA9030_EVENT_TBAT); 571 DA9030_EVENT_CHIOVER | DA9030_EVENT_TBAT);
568 cancel_delayed_work(&charger->work); 572 cancel_delayed_work_sync(&charger->work);
573 da9030_set_charge(charger, 0);
569 power_supply_unregister(&charger->psy); 574 power_supply_unregister(&charger->psy);
570 575
571 kfree(charger); 576 kfree(charger);