From: Ramakrishna Pallala Date: Wed, 2 May 2012 23:05:30 +0000 (+0530) Subject: MFLD/Battery: Clean up battery status setting logic X-Git-Tag: 2.1b_release~707 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=846cd3607beee9cbaad52bd11c21be97a76a7b86;p=kernel%2Fkernel-mfld-blackbay.git MFLD/Battery: Clean up battery status setting logic BZ: 17854 The current code doesn't set the battery status to NOT Charging even if the writes to MSIC register fails, it only logs the error. This patch sets the battery status to NOT Charging if there is a MSIC register write fail and also cleans up the battery status setting logic. Change-Id: Iea83c2ba2473d523d8d36c3242ca3e5307451c0f Signed-off-by: Ramakrishna Pallala Reviewed-on: http://android.intel.com:8080/47166 Reviewed-by: Tc, Jenny Tested-by: Kallappa Manjanna, MadhukumarX Reviewed-by: Koskinen, Ilkka Reviewed-by: buildbot Tested-by: buildbot --- diff --git a/drivers/power/intel_mdf_battery.c b/drivers/power/intel_mdf_battery.c index d457de0..d70a2f6 100644 --- a/drivers/power/intel_mdf_battery.c +++ b/drivers/power/intel_mdf_battery.c @@ -1372,14 +1372,6 @@ static int msic_batt_do_charging(struct msic_power_module_info *mbi, return -EIO; } - mutex_lock(&mbi->batt_lock); - if (is_maint_mode) - mbi->batt_props.status = POWER_SUPPLY_STATUS_FULL; - else - mbi->batt_props.status = POWER_SUPPLY_STATUS_CHARGING; - mutex_unlock(&mbi->batt_lock); - - power_supply_changed(&mbi->usb); return 0; } @@ -1781,12 +1773,22 @@ static void msic_batt_temp_charging(struct work_struct *work) /* enable charging here */ dev_info(msic_dev, "Enable Charging\n"); ret = msic_batt_do_charging(mbi, &charge_param, is_maint_chrg); - dump_registers(MSIC_CHRG_REG_DUMP_EVENT); - if (ret) { + /* update battery status */ + mutex_lock(&mbi->batt_lock); + if (ret < 0 && !is_chrg_enbl) { dev_warn(msic_dev, "msic_batt_do_charging failed\n"); - goto lbl_sched_work; + mbi->batt_props.status = POWER_SUPPLY_STATUS_NOT_CHARGING; + } else { + if (is_maint_chrg) + mbi->batt_props.status = POWER_SUPPLY_STATUS_FULL; + else + mbi->batt_props.status = POWER_SUPPLY_STATUS_CHARGING; + is_chrg_enbl = true; } - is_chrg_enbl = true; + mutex_unlock(&mbi->batt_lock); + + dump_registers(MSIC_CHRG_REG_DUMP_EVENT); + power_supply_changed(&mbi->usb); lbl_sched_work: /* Schedule the work after 30 Seconds */