|
|
88f3771 |
From 69dd0606a0d8680fe0a5e9b959f6662e582e1674 Mon Sep 17 00:00:00 2001
|
|
|
88f3771 |
From: Hans de Goede <hdegoede@redhat.com>
|
|
|
88f3771 |
Date: Tue, 2 May 2017 13:43:34 +0200
|
|
|
88f3771 |
Subject: [PATCH 03/16] power: supply: core: Add support for supplied-from
|
|
|
88f3771 |
device-property
|
|
|
88f3771 |
|
|
|
88f3771 |
On devicetree using platforms the devicetree can provide info on which
|
|
|
88f3771 |
power-supplies supply another power-supply through phandles.
|
|
|
88f3771 |
|
|
|
88f3771 |
This commit adds support for providing this info on non devicetree
|
|
|
88f3771 |
platforms through the platform code setting a supplied-from
|
|
|
88f3771 |
device-property on the power-supplies parent device.
|
|
|
88f3771 |
|
|
|
88f3771 |
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
|
88f3771 |
---
|
|
|
88f3771 |
drivers/power/supply/power_supply_core.c | 24 +++++++++++++++++++++++-
|
|
|
88f3771 |
1 file changed, 23 insertions(+), 1 deletion(-)
|
|
|
88f3771 |
|
|
|
88f3771 |
diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
|
|
|
88f3771 |
index 7ec7c7c202bd..0c09144193a6 100644
|
|
|
88f3771 |
--- a/drivers/power/supply/power_supply_core.c
|
|
|
88f3771 |
+++ b/drivers/power/supply/power_supply_core.c
|
|
|
88f3771 |
@@ -274,8 +274,30 @@ static int power_supply_check_supplies(struct power_supply *psy)
|
|
|
88f3771 |
return power_supply_populate_supplied_from(psy);
|
|
|
88f3771 |
}
|
|
|
88f3771 |
#else
|
|
|
88f3771 |
-static inline int power_supply_check_supplies(struct power_supply *psy)
|
|
|
88f3771 |
+static int power_supply_check_supplies(struct power_supply *psy)
|
|
|
88f3771 |
{
|
|
|
88f3771 |
+ int nval, ret;
|
|
|
88f3771 |
+
|
|
|
88f3771 |
+ if (!psy->dev.parent)
|
|
|
88f3771 |
+ return 0;
|
|
|
88f3771 |
+
|
|
|
88f3771 |
+ nval = device_property_read_string_array(psy->dev.parent,
|
|
|
88f3771 |
+ "supplied-from", NULL, 0);
|
|
|
88f3771 |
+ if (nval <= 0)
|
|
|
88f3771 |
+ return 0;
|
|
|
88f3771 |
+
|
|
|
88f3771 |
+ psy->supplied_from = devm_kmalloc_array(&psy->dev, nval,
|
|
|
88f3771 |
+ sizeof(char *), GFP_KERNEL);
|
|
|
88f3771 |
+ if (!psy->supplied_from)
|
|
|
88f3771 |
+ return -ENOMEM;
|
|
|
88f3771 |
+
|
|
|
88f3771 |
+ ret = device_property_read_string_array(psy->dev.parent,
|
|
|
88f3771 |
+ "supplied-from", (const char **)psy->supplied_from, nval);
|
|
|
88f3771 |
+ if (ret < 0)
|
|
|
88f3771 |
+ return ret;
|
|
|
88f3771 |
+
|
|
|
88f3771 |
+ psy->num_supplies = nval;
|
|
|
88f3771 |
+
|
|
|
88f3771 |
return 0;
|
|
|
88f3771 |
}
|
|
|
88f3771 |
#endif
|
|
|
88f3771 |
--
|
|
|
88f3771 |
2.13.0
|
|
|
88f3771 |
|