static void s3c_bat_status_update(struct power_supply *bat_ps) { int old_level, old_temp, old_is_full; dev_dbg(dev, "%s ++\n", __func__); if(!s3c_battery_initial) return; mutex_lock(&work_lock); old_temp = s3c_bat_info.bat_info.batt_temp; old_level = s3c_bat_info.bat_info.level; old_is_full = s3c_bat_info.bat_info.batt_is_full; s3c_bat_info.bat_info.batt_temp = s3c_get_bat_temp(bat_ps); s3c_bat_info.bat_info.level = s3c_get_bat_level(bat_ps); s3c_bat_info.bat_info.batt_vol = s3c_get_bat_vol(bat_ps); if (old_level != s3c_bat_info.bat_info.level || old_temp != s3c_bat_info.bat_info.batt_temp || old_is_full != s3c_bat_info.bat_info.batt_is_full || force_update) { force_update = 0; power_supply_changed(bat_ps); dev_dbg(dev, "%s : call power_supply_changed\n", __func__); } mutex_unlock(&work_lock); dev_dbg(dev, "%s --\n", __func__); }
static void s3c_bat_work(struct work_struct *work) { struct chg_data *chg = container_of(work, struct chg_data, bat_work); int ret; mutex_lock(&chg->mutex); s3c_get_bat_temp(chg); s3c_bat_discharge_reason(chg); ret = s3c_cable_status_update(chg); if (ret < 0) goto err; mutex_unlock(&chg->mutex); power_supply_changed(&chg->psy_bat); mod_timer(&chg->bat_work_timer, jiffies + msecs_to_jiffies(BAT_POLLING_INTERVAL)); wake_unlock(&chg->work_wake_lock); return; err: mutex_unlock(&chg->mutex); wake_unlock(&chg->work_wake_lock); pr_err("battery workqueue fail\n"); }
static void s3c_bat_work(struct work_struct *work) { struct chg_data *chg = container_of(work, struct chg_data, bat_work); int ret; struct timespec ts; unsigned long flags; mutex_lock(&chg->mutex); s3c_get_bat_temp(chg); s3c_bat_discharge_reason(chg); ret = s3c_cable_status_update(chg); if (ret < 0) goto err; mutex_unlock(&chg->mutex); power_supply_changed(&chg->psy_bat); chg->last_poll = alarm_get_elapsed_realtime(); ts = ktime_to_timespec(chg->last_poll); chg->timestamp = ts.tv_sec; /* prevent suspend before starting the alarm */ local_irq_save(flags); wake_unlock(&chg->work_wake_lock); s3c_program_alarm(chg, FAST_POLL); local_irq_restore(flags); return; err: mutex_unlock(&chg->mutex); wake_unlock(&chg->work_wake_lock); pr_err("battery workqueue fail\n"); }
static void s3c_bat_status_update(struct power_supply *bat_ps) { int old_level, old_temp, old_is_full; dev_dbg(dev, "%s ++\n", __func__); if(!s3c_battery_initial) return; mutex_lock(&work_lock); old_temp = s3c_bat_info.bat_info.batt_temp; old_level = s3c_bat_info.bat_info.level; old_is_full = s3c_bat_info.bat_info.batt_is_full; s3c_bat_info.bat_info.batt_temp = s3c_get_bat_temp(bat_ps); s3c_bat_info.bat_info.level = s3c_get_bat_level(bat_ps); if (!s3c_bat_info.bat_info.charging_enabled && !s3c_bat_info.bat_info.batt_is_full) { if (s3c_bat_info.bat_info.level > old_level) s3c_bat_info.bat_info.level = old_level; } s3c_bat_info.bat_info.batt_vol = s3c_get_bat_vol(bat_ps); #if (defined __TEST_MODE_INTERFACE__ && defined __BATTERY_V_F__) if (s3c_bat_info.bat_info.batt_test_mode == 1) s3c_get_v_f_adc(); #endif /* __TEST_MODE_INTERFACE__ && __BATTERY_V_F__ */ if (old_level != s3c_bat_info.bat_info.level || old_temp != s3c_bat_info.bat_info.batt_temp || old_is_full != s3c_bat_info.bat_info.batt_is_full || force_update) { force_update = 0; power_supply_changed(bat_ps); dev_dbg(dev, "%s: call power_supply_changed\n", __func__); } mutex_unlock(&work_lock); dev_dbg(dev, "%s --\n", __func__); }