Re: [PATCH 4/5] charger-manager: Check fully charged state of battery periodically
On 09/21/2012 02:10 PM, Anton Vorontsov wrote: > On Tue, Aug 21, 2012 at 05:06:52PM +0900, Chanwoo Choi wrote: >> This patch check periodically fully charged state of battery to protect >> overcharge and overheat. If battery is fully charged, stop charging >> and check droped voltage with 'fullbatt_vchkdrop_ms' period. When voltage >> of battery is more droped than 'fullbatt_vchkdrop_uV' voltage, >> charger-manager will restart charging for battery. >> >> Signed-off-by: Chanwoo Choi >> Signed-off-by: Myungjoo Ham >> Signed-off-by: Kyungmin Park >> --- > > Applied, thank you. > > There were some minor issues, but I fixed them up: > > [...] >> +} else if (!cm->emergency_stop >> +&& is_ext_pwr_online(cm) && !cm->charger_enabled) { > > Wrong && placement (should have been on the previous line). > >> +fullbatt_vchk(>fullbatt_vchk_work.work); >> + >> +/* >> + * Check whether fully charged state to protect overcharge >> + * if charger-manager is charging for battery. >> + */ >> +} else if (!cm->emergency_stop >> +&& is_full_charged(cm) && cm->charger_enabled) { > > Ditto. > Thanks for your reply and applied it. I will consider your comment about coding style. Best Regards, Chanwoo Choi -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/5] charger-manager: Check fully charged state of battery periodically
On 09/21/2012 02:10 PM, Anton Vorontsov wrote: On Tue, Aug 21, 2012 at 05:06:52PM +0900, Chanwoo Choi wrote: This patch check periodically fully charged state of battery to protect overcharge and overheat. If battery is fully charged, stop charging and check droped voltage with 'fullbatt_vchkdrop_ms' period. When voltage of battery is more droped than 'fullbatt_vchkdrop_uV' voltage, charger-manager will restart charging for battery. Signed-off-by: Chanwoo Choi cw00.c...@samsung.com Signed-off-by: Myungjoo Ham myungjoo@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- Applied, thank you. There were some minor issues, but I fixed them up: [...] +} else if (!cm-emergency_stop + is_ext_pwr_online(cm) !cm-charger_enabled) { Wrong placement (should have been on the previous line). +fullbatt_vchk(cm-fullbatt_vchk_work.work); + +/* + * Check whether fully charged state to protect overcharge + * if charger-manager is charging for battery. + */ +} else if (!cm-emergency_stop + is_full_charged(cm) cm-charger_enabled) { Ditto. Thanks for your reply and applied it. I will consider your comment about coding style. Best Regards, Chanwoo Choi -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/5] charger-manager: Check fully charged state of battery periodically
On Tue, Aug 21, 2012 at 05:06:52PM +0900, Chanwoo Choi wrote: > This patch check periodically fully charged state of battery to protect > overcharge and overheat. If battery is fully charged, stop charging > and check droped voltage with 'fullbatt_vchkdrop_ms' period. When voltage > of battery is more droped than 'fullbatt_vchkdrop_uV' voltage, > charger-manager will restart charging for battery. > > Signed-off-by: Chanwoo Choi > Signed-off-by: Myungjoo Ham > Signed-off-by: Kyungmin Park > --- Applied, thank you. There were some minor issues, but I fixed them up: [...] > + } else if (!cm->emergency_stop > + && is_ext_pwr_online(cm) && !cm->charger_enabled) { Wrong && placement (should have been on the previous line). > + fullbatt_vchk(>fullbatt_vchk_work.work); > + > + /* > + * Check whether fully charged state to protect overcharge > + * if charger-manager is charging for battery. > + */ > + } else if (!cm->emergency_stop > + && is_full_charged(cm) && cm->charger_enabled) { Ditto. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/5] charger-manager: Check fully charged state of battery periodically
On Tue, Aug 21, 2012 at 05:06:52PM +0900, Chanwoo Choi wrote: This patch check periodically fully charged state of battery to protect overcharge and overheat. If battery is fully charged, stop charging and check droped voltage with 'fullbatt_vchkdrop_ms' period. When voltage of battery is more droped than 'fullbatt_vchkdrop_uV' voltage, charger-manager will restart charging for battery. Signed-off-by: Chanwoo Choi cw00.c...@samsung.com Signed-off-by: Myungjoo Ham myungjoo@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- Applied, thank you. There were some minor issues, but I fixed them up: [...] + } else if (!cm-emergency_stop + is_ext_pwr_online(cm) !cm-charger_enabled) { Wrong placement (should have been on the previous line). + fullbatt_vchk(cm-fullbatt_vchk_work.work); + + /* + * Check whether fully charged state to protect overcharge + * if charger-manager is charging for battery. + */ + } else if (!cm-emergency_stop + is_full_charged(cm) cm-charger_enabled) { Ditto. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 4/5] charger-manager: Check fully charged state of battery periodically
This patch check periodically fully charged state of battery to protect overcharge and overheat. If battery is fully charged, stop charging and check droped voltage with 'fullbatt_vchkdrop_ms' period. When voltage of battery is more droped than 'fullbatt_vchkdrop_uV' voltage, charger-manager will restart charging for battery. Signed-off-by: Chanwoo Choi Signed-off-by: Myungjoo Ham Signed-off-by: Kyungmin Park --- drivers/power/charger-manager.c | 161 - include/linux/power/charger-manager.h |8 ++- 2 files changed, 123 insertions(+), 46 deletions(-) diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c index 33cc3f6..805f79d 100644 --- a/drivers/power/charger-manager.c +++ b/drivers/power/charger-manager.c @@ -228,6 +228,58 @@ static bool is_charging(struct charger_manager *cm) } /** + * is_full_charged - Returns true if the battery is fully charged. + * @cm: the Charger Manager representing the battery. + */ +static bool is_full_charged(struct charger_manager *cm) +{ + struct charger_desc *desc = cm->desc; + union power_supply_propval val; + int ret = 0; + int uV; + + /* If there is no battery, it cannot be charged */ + if (!is_batt_present(cm)) { + val.intval = 0; + goto out; + } + + if (cm->fuel_gauge && desc->fullbatt_full_capacity > 0) { + /* Not full if capacity of fuel gauge isn't full */ + ret = cm->fuel_gauge->get_property(cm->fuel_gauge, + POWER_SUPPLY_PROP_CHARGE_FULL, ); + if (!ret && val.intval > desc->fullbatt_full_capacity) { + val.intval = 1; + goto out; + } + } + + /* Full, if it's over the fullbatt voltage */ + if (desc->fullbatt_uV > 0) { + ret = get_batt_uV(cm, ); + if (!ret && uV >= desc->fullbatt_uV) { + val.intval = 1; + goto out; + } + } + + /* Full, if the capacity is more than fullbatt_soc */ + if (cm->fuel_gauge && desc->fullbatt_soc > 0) { + ret = cm->fuel_gauge->get_property(cm->fuel_gauge, + POWER_SUPPLY_PROP_CAPACITY, ); + if (!ret && val.intval >= desc->fullbatt_soc) { + val.intval = 1; + goto out; + } + } + + val.intval = 0; + +out: + return val.intval ? true : false; +} + +/** * is_polling_required - Return true if need to continue polling for this CM. * @cm: the Charger Manager representing the battery. */ @@ -427,7 +479,7 @@ static void fullbatt_vchk(struct work_struct *work) diff = desc->fullbatt_uV; diff -= batt_uV; - dev_dbg(cm->dev, "VBATT dropped %duV after full-batt.\n", diff); + dev_info(cm->dev, "VBATT dropped %duV after full-batt.\n", diff); if (diff > desc->fullbatt_vchkdrop_uV) { try_charger_restart(cm); @@ -450,10 +502,14 @@ static bool _cm_monitor(struct charger_manager *cm) dev_dbg(cm->dev, "monitoring (%2.2d.%3.3dC)\n", cm->last_temp_mC / 1000, cm->last_temp_mC % 1000); - /* It has been stopped or charging already */ - if (!!temp == !!cm->emergency_stop) + /* It has been stopped already */ + if (temp && cm->emergency_stop) return false; + /* +* Check temperature whether overheat or cold. +* If temperature is out of range normal state, stop charging. +*/ if (temp) { cm->emergency_stop = temp; if (!try_charger_enable(cm, false)) { @@ -462,10 +518,34 @@ static bool _cm_monitor(struct charger_manager *cm) else uevent_notify(cm, "COLD"); } + + /* +* Check dropped voltage of battery. If battery voltage is more +* dropped than fullbatt_vchkdrop_uV after fully charged state, +* charger-manager have to recharge battery. +*/ + } else if (!cm->emergency_stop + && is_ext_pwr_online(cm) && !cm->charger_enabled) { + fullbatt_vchk(>fullbatt_vchk_work.work); + + /* +* Check whether fully charged state to protect overcharge +* if charger-manager is charging for battery. +*/ + } else if (!cm->emergency_stop + && is_full_charged(cm) && cm->charger_enabled) { + dev_info(cm->dev, "EVENT_HANDLE: Battery Fully Charged.\n"); + uevent_notify(cm, default_event_names[CM_EVENT_BATT_FULL]); + + try_charger_enable(cm, false); + + fullbatt_vchk(>fullbatt_vchk_work.work); } else { cm->emergency_stop = 0; - if (!try_charger_enable(cm, true)) -
[PATCH 4/5] charger-manager: Check fully charged state of battery periodically
This patch check periodically fully charged state of battery to protect overcharge and overheat. If battery is fully charged, stop charging and check droped voltage with 'fullbatt_vchkdrop_ms' period. When voltage of battery is more droped than 'fullbatt_vchkdrop_uV' voltage, charger-manager will restart charging for battery. Signed-off-by: Chanwoo Choi cw00.c...@samsung.com Signed-off-by: Myungjoo Ham myungjoo@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/power/charger-manager.c | 161 - include/linux/power/charger-manager.h |8 ++- 2 files changed, 123 insertions(+), 46 deletions(-) diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c index 33cc3f6..805f79d 100644 --- a/drivers/power/charger-manager.c +++ b/drivers/power/charger-manager.c @@ -228,6 +228,58 @@ static bool is_charging(struct charger_manager *cm) } /** + * is_full_charged - Returns true if the battery is fully charged. + * @cm: the Charger Manager representing the battery. + */ +static bool is_full_charged(struct charger_manager *cm) +{ + struct charger_desc *desc = cm-desc; + union power_supply_propval val; + int ret = 0; + int uV; + + /* If there is no battery, it cannot be charged */ + if (!is_batt_present(cm)) { + val.intval = 0; + goto out; + } + + if (cm-fuel_gauge desc-fullbatt_full_capacity 0) { + /* Not full if capacity of fuel gauge isn't full */ + ret = cm-fuel_gauge-get_property(cm-fuel_gauge, + POWER_SUPPLY_PROP_CHARGE_FULL, val); + if (!ret val.intval desc-fullbatt_full_capacity) { + val.intval = 1; + goto out; + } + } + + /* Full, if it's over the fullbatt voltage */ + if (desc-fullbatt_uV 0) { + ret = get_batt_uV(cm, uV); + if (!ret uV = desc-fullbatt_uV) { + val.intval = 1; + goto out; + } + } + + /* Full, if the capacity is more than fullbatt_soc */ + if (cm-fuel_gauge desc-fullbatt_soc 0) { + ret = cm-fuel_gauge-get_property(cm-fuel_gauge, + POWER_SUPPLY_PROP_CAPACITY, val); + if (!ret val.intval = desc-fullbatt_soc) { + val.intval = 1; + goto out; + } + } + + val.intval = 0; + +out: + return val.intval ? true : false; +} + +/** * is_polling_required - Return true if need to continue polling for this CM. * @cm: the Charger Manager representing the battery. */ @@ -427,7 +479,7 @@ static void fullbatt_vchk(struct work_struct *work) diff = desc-fullbatt_uV; diff -= batt_uV; - dev_dbg(cm-dev, VBATT dropped %duV after full-batt.\n, diff); + dev_info(cm-dev, VBATT dropped %duV after full-batt.\n, diff); if (diff desc-fullbatt_vchkdrop_uV) { try_charger_restart(cm); @@ -450,10 +502,14 @@ static bool _cm_monitor(struct charger_manager *cm) dev_dbg(cm-dev, monitoring (%2.2d.%3.3dC)\n, cm-last_temp_mC / 1000, cm-last_temp_mC % 1000); - /* It has been stopped or charging already */ - if (!!temp == !!cm-emergency_stop) + /* It has been stopped already */ + if (temp cm-emergency_stop) return false; + /* +* Check temperature whether overheat or cold. +* If temperature is out of range normal state, stop charging. +*/ if (temp) { cm-emergency_stop = temp; if (!try_charger_enable(cm, false)) { @@ -462,10 +518,34 @@ static bool _cm_monitor(struct charger_manager *cm) else uevent_notify(cm, COLD); } + + /* +* Check dropped voltage of battery. If battery voltage is more +* dropped than fullbatt_vchkdrop_uV after fully charged state, +* charger-manager have to recharge battery. +*/ + } else if (!cm-emergency_stop +is_ext_pwr_online(cm) !cm-charger_enabled) { + fullbatt_vchk(cm-fullbatt_vchk_work.work); + + /* +* Check whether fully charged state to protect overcharge +* if charger-manager is charging for battery. +*/ + } else if (!cm-emergency_stop +is_full_charged(cm) cm-charger_enabled) { + dev_info(cm-dev, EVENT_HANDLE: Battery Fully Charged.\n); + uevent_notify(cm, default_event_names[CM_EVENT_BATT_FULL]); + + try_charger_enable(cm, false); + + fullbatt_vchk(cm-fullbatt_vchk_work.work); } else { cm-emergency_stop = 0; - if (!try_charger_enable(cm, true)) -