summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorRong Dian <b38775@freescale.com>2012-06-21 11:22:33 +0800
committerJason Liu <r64343@freescale.com>2012-07-20 13:38:59 +0800
commit83093cf018bf03dbb3a2400fca95107b850cabf7 (patch)
tree4766c8622696d463e0d88df3ece2e07435a37ebe /drivers/power
parentd95ecbd625a9b9d1cd98e49a6d065eba26e99692 (diff)
ENGR00214367-1 power_supply: add get_supplier_property
add get_supplier_property interface. This patch was written by: Heikki Krogerus <heikki.krogerus@linux.intel.com> originally. Signed-off-by: Rong Dian <b38775@freescale.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/power_supply_core.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
index 329b46b2327d..338d4a68365c 100644
--- a/drivers/power/power_supply_core.c
+++ b/drivers/power/power_supply_core.c
@@ -94,6 +94,37 @@ int power_supply_am_i_supplied(struct power_supply *psy)
}
EXPORT_SYMBOL_GPL(power_supply_am_i_supplied);
+static int power_supply_find_supplier(struct device *dev, void *data)
+{
+ struct power_supply *psy = (struct power_supply *)data;
+ struct power_supply *epsy = dev_get_drvdata(dev);
+ int i;
+
+ for (i = 0; i < epsy->num_supplicants; i++)
+ if (!strcmp(epsy->supplied_to[i], psy->name))
+ return 1;
+ return 0;
+}
+
+int power_supply_get_supplier_property(struct power_supply *psy,
+ enum power_supply_property psp,
+ union power_supply_propval *val)
+{
+ struct power_supply *epsy;
+ struct device *dev;
+
+ dev = class_find_device(power_supply_class, NULL, psy,
+ power_supply_find_supplier);
+ if (!dev)
+ return 1;
+
+ epsy = dev_get_drvdata(dev);
+ put_device(dev);
+
+ return epsy->get_property(epsy, psp, val);
+}
+EXPORT_SYMBOL_GPL(power_supply_get_supplier_property);
+
static int __power_supply_is_system_supplied(struct device *dev, void *data)
{
union power_supply_propval ret = {0,};