From: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
To: linux-kernel@vger.kernel.org
Cc: Anton Vorontsov <cbouatmailru@gmail.com>,
Anton Vorontsov <anton.vorontsov@linaro.org>,
Ramakrishna Pallala <ramakrishna.pallala@intel.com>
Subject: [PATCH] max17042_battery: add support for battery STATUS and CHARGE_TYPE
Date: Fri, 27 Jul 2012 22:26:21 +0530 [thread overview]
Message-ID: <1343408181-21988-1-git-send-email-ramakrishna.pallala@intel.com> (raw)
This patch adds the support to report the battery power supply attributes
STATUS and CHARGE_TYPE. This patch makes use of power_supply_get_external_attr()
API to get these attributes through power supply core.
Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
---
drivers/power/max17042_battery.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/drivers/power/max17042_battery.c b/drivers/power/max17042_battery.c
index 74abc6c..56131f8 100644
--- a/drivers/power/max17042_battery.c
+++ b/drivers/power/max17042_battery.c
@@ -105,6 +105,8 @@ static void max17042_set_reg(struct i2c_client *client,
static enum power_supply_property max17042_battery_props[] = {
POWER_SUPPLY_PROP_PRESENT,
+ POWER_SUPPLY_PROP_STATUS,
+ POWER_SUPPLY_PROP_CHARGE_TYPE,
POWER_SUPPLY_PROP_CYCLE_COUNT,
POWER_SUPPLY_PROP_VOLTAGE_MAX,
POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
@@ -125,12 +127,29 @@ static int max17042_get_property(struct power_supply *psy,
{
struct max17042_chip *chip = container_of(psy,
struct max17042_chip, battery);
+ struct power_supply_attr_query query;
int ret;
if (!chip->init_complete)
return -EAGAIN;
+ memset(&query, 0x0, sizeof(query));
+ query.property = psp;
+ query.type = POWER_SUPPLY_TYPE_BATTERY;
+
switch (psp) {
+ case POWER_SUPPLY_PROP_STATUS:
+ ret = power_supply_get_external_attr(&query);
+ if (ret < 0)
+ return ret;
+ val->intval = query.res.intval;
+ break;
+ case POWER_SUPPLY_PROP_CHARGE_TYPE:
+ ret = power_supply_get_external_attr(&query);
+ if (ret < 0)
+ return ret;
+ val->intval = query.res.intval;
+ break;
case POWER_SUPPLY_PROP_PRESENT:
ret = max17042_read_reg(chip->client, MAX17042_STATUS);
if (ret < 0)
--
1.7.0.4
next reply other threads:[~2012-07-27 18:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-27 16:56 Ramakrishna Pallala [this message]
2012-08-08 9:38 ` Anton Vorontsov
2012-08-15 2:28 ` Pallala, Ramakrishna
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=1343408181-21988-1-git-send-email-ramakrishna.pallala@intel.com \
--to=ramakrishna.pallala@intel.com \
--cc=anton.vorontsov@linaro.org \
--cc=cbouatmailru@gmail.com \
--cc=linux-kernel@vger.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®