From: Jonghwa Lee <jonghwa3.lee@samsung.com>
To: linux-kernel@vger.kernel.org
Cc: linux-pm@vger.kernel.org, sre@kernel.org, dbaryshkov@gmail.com,
dwmw2@infradead.org, anton@enomsg.org, pavel@ucw.cz,
myungjoo.ham@samsung.com, cw00.choi@samsung.com,
Jonghwa Lee <jonghwa3.lee@samsung.com>
Subject: [PATCH V3 07/11] power: charger-manager: Get external power souce information only from EXTCON.
Date: Fri, 19 Dec 2014 17:55:19 +0900 [thread overview]
Message-ID: <1418979323-7188-8-git-send-email-jonghwa3.lee@samsung.com> (raw)
In-Reply-To: <1418979323-7188-1-git-send-email-jonghwa3.lee@samsung.com>
When charger-manager checks whether external power source is available,
it gets information from charger IC driver. However, it's not correct source,
charger IC doesn't have responsibilty to give cable connection status.
The charger-manager already gets cable information from EXTCON susbsystem,
so it can re-use it.
Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
---
drivers/power/charger-manager.c | 34 ++++++++++++++--------------------
1 file changed, 14 insertions(+), 20 deletions(-)
diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
index d29155d..dc15436 100644
--- a/drivers/power/charger-manager.c
+++ b/drivers/power/charger-manager.c
@@ -115,34 +115,28 @@ static bool is_batt_present(struct charger_manager *cm)
* is_ext_pwr_online - See if an external power source is attached to charge
* @cm: the Charger Manager representing the battery.
*
- * Returns true if at least one of the chargers of the battery has an external
- * power source attached to charge the battery regardless of whether it is
- * actually charging or not.
+ * Returns true if there is external power source.
+ * Cable connection information is only obtained by EXTCON class notification.
*/
static bool is_ext_pwr_online(struct charger_manager *cm)
{
- union power_supply_propval val;
- struct power_supply *psy;
- bool online = false;
- int i, ret;
- /* If at least one of them has one, it's yes. */
- for (i = 0; cm->desc->psy_charger_stat[i]; i++) {
- psy = power_supply_get_by_name(cm->desc->psy_charger_stat[i]);
- if (!psy) {
- dev_err(cm->dev, "Cannot find power supply \"%s\"\n",
- cm->desc->psy_charger_stat[i]);
- continue;
- }
+ struct charger_desc *desc = cm->desc;
+ struct charger_regulator *regulators = desc->charger_regulators;
+ struct charger_cable *cables;
+ int i, j, num_cables;
- ret = psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val);
- if (ret == 0 && val.intval) {
- online = true;
- break;
+ /* If at least one of them has one, it's yes. */
+ for (i = 0; i < desc->num_charger_regulators; i++) {
+ cables = regulators[i].cables;
+ num_cables = regulators[i].num_cables;
+ for (j = 0; j < num_cables; j++) {
+ if (cables[j].attached)
+ return true;
}
}
- return online;
+ return false;
}
/**
--
1.7.9.5
next prev parent reply other threads:[~2014-12-19 8:55 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-19 8:55 [PATCH V3 0/11] Improve charger manager driver for optimized operation Jonghwa Lee
2014-12-19 8:55 ` [PATCH V3 01/11] power: charger-manager: Use alarmtimer for battery monitoring in suspend Jonghwa Lee
2014-12-20 0:21 ` Pavel Machek
2015-01-21 20:44 ` Sebastian Reichel
2014-12-19 8:55 ` [PATCH V3 02/11] power: charger-manager: Use thermal subsystem interface only to get temperature Jonghwa Lee
2015-01-21 22:38 ` Sebastian Reichel
2014-12-19 8:55 ` [PATCH V3 03/11] power: charger-manager: Use power_supply_changed() not private uevent Jonghwa Lee
2014-12-19 8:55 ` [PATCH V3 04/11] power: charger-manager: Remove deprecated function, cm_notify_event() Jonghwa Lee
2014-12-19 8:55 ` [PATCH V3 05/11] power: charger-manager: Fix to use CHARGE_NOW/FULL property correctly Jonghwa Lee
2014-12-19 8:55 ` [PATCH V3 06/11] power: charger-manager: Concentrate scattered power_supply_changed() calls Jonghwa Lee
2014-12-19 8:55 ` Jonghwa Lee [this message]
2014-12-19 8:55 ` [PATCH V3 08/11] power: charger-manager: Make chraging decision focusing on battery status Jonghwa Lee
2014-12-20 0:24 ` Pavel Machek
2014-12-22 2:10 ` jonghwa3.lee
2014-12-19 8:55 ` [PATCH V3 09/11] power: charger-manager: Not to start charging directly in cable nofitication Jonghwa Lee
2014-12-19 8:55 ` [PATCH V3 10/11] power: charger-manager: Support different polling mode for sleep state Jonghwa Lee
2014-12-19 8:55 ` [PATCH V3 11/11] power: charger-manager: Support to change polling rate in runtime Jonghwa Lee
2014-12-20 0:29 ` Pavel Machek
2014-12-22 1:57 ` jonghwa3.lee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1418979323-7188-8-git-send-email-jonghwa3.lee@samsung.com \
--to=jonghwa3.lee@samsung.com \
--cc=anton@enomsg.org \
--cc=cw00.choi@samsung.com \
--cc=dbaryshkov@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
--cc=pavel@ucw.cz \
--cc=sre@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®