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] power_supply: API to return the power supply object from supplied to list
Date: Wed, 25 Jul 2012 15:20:18 +0530 [thread overview]
Message-ID: <1343209818-14232-1-git-send-email-ramakrishna.pallala@intel.com> (raw)
This patch adds an API in the power supply core to get the
power supply object from supplied_to list based on power
supply attribute(present/online).
Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
---
drivers/power/power_supply_core.c | 19 +++++++++++++++++++
include/linux/power_supply.h | 3 +++
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
index ff990d2..8ef1d8b 100644
--- a/drivers/power/power_supply_core.c
+++ b/drivers/power/power_supply_core.c
@@ -158,6 +158,25 @@ struct power_supply *power_supply_get_by_name(char *name)
}
EXPORT_SYMBOL_GPL(power_supply_get_by_name);
+struct power_supply *power_supply_get_by_suppliedto(struct power_supply *psy,
+ enum power_supply_property psp)
+{
+ union power_supply_propval ret = {0,};
+ struct power_supply *pst;
+ int i;
+
+ for (i = 0; i < psy->num_supplicants; i++) {
+ pst = power_supply_get_by_name(psy->supplied_to[i]);
+ if (!pst || pst->get_property(pst, psp, &ret))
+ continue;
+ if (ret.intval)
+ return pst;
+ }
+
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(power_supply_get_by_suppliedto);
+
int power_supply_powers(struct power_supply *psy, struct device *dev)
{
return sysfs_create_link(&psy->dev->kobj, &dev->kobj, "powers");
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 0bafbb1..2fdcf77 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -219,6 +219,9 @@ struct power_supply_info {
};
extern struct power_supply *power_supply_get_by_name(char *name);
+extern struct power_supply *power_supply_get_by_suppliedto(
+ struct power_supply *psy,
+ enum power_supply_property psp);
extern void power_supply_changed(struct power_supply *psy);
extern int power_supply_am_i_supplied(struct power_supply *psy);
extern int power_supply_set_battery_charged(struct power_supply *psy);
--
1.7.0.4
reply other threads:[~2012-07-25 11:13 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1343209818-14232-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®