lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1343209818-14232-1-git-send-email-ramakrishna.pallala@intel.com>
Date:	Wed, 25 Jul 2012 15:20:18 +0530
From:	Ramakrishna Pallala <ramakrishna.pallala@...el.com>
To:	linux-kernel@...r.kernel.org
Cc:	Anton Vorontsov <cbouatmailru@...il.com>,
	Anton Vorontsov <anton.vorontsov@...aro.org>,
	Ramakrishna Pallala <ramakrishna.pallala@...el.com>
Subject: [PATCH] power_supply: API to return the power supply object from supplied to list

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@...el.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ