bq2415x_charger: Fix Atomic Sleep Bug
[profile/ivi/kernel-x86-ivi.git] / drivers / power / bq2415x_charger.c
index 79a37f6..e384844 100644 (file)
@@ -840,8 +840,7 @@ static int bq2415x_notifier_call(struct notifier_block *nb,
        if (bq->automode < 1)
                return NOTIFY_OK;
 
-       sysfs_notify(&bq->charger.dev->kobj, NULL, "reported_mode");
-       bq2415x_set_mode(bq, bq->reported_mode);
+       schedule_delayed_work(&bq->work, 0);
 
        return NOTIFY_OK;
 }
@@ -892,6 +891,11 @@ static void bq2415x_timer_work(struct work_struct *work)
        int error;
        int boost;
 
+       if (bq->automode > 0 && (bq->reported_mode != bq->mode)) {
+               sysfs_notify(&bq->charger.dev->kobj, NULL, "reported_mode");
+               bq2415x_set_mode(bq, bq->reported_mode);
+       }
+
        if (!bq->autotimer)
                return;