diff options
author | Krzysztof Kozlowski <k.kozlowski@samsung.com> | 2015-03-12 08:44:02 +0100 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2015-03-13 23:15:12 +0100 |
commit | 2dc9215d7c94f7f9f34ccf8b1710ad73d82f6216 (patch) | |
tree | b8bae66b916e1f64dd725a68bca2182ee315bf66 /drivers/power/power_supply_core.c | |
parent | e44ea364394499d38a26ed4c9668fb378ae8797f (diff) | |
download | linux-2dc9215d7c94f7f9f34ccf8b1710ad73d82f6216.tar.bz2 |
power_supply: Move run-time configuration to separate structure
Add new structure 'power_supply_config' for holding run-time
initialization data like of_node, supplies and private driver data.
The power_supply_register() function is changed so all power supply
drivers need updating.
When registering the power supply this new 'power_supply_config' should be
used instead of directly initializing 'struct power_supply'. This allows
changing the ownership of power_supply structure from driver to the
power supply core in next patches.
When a driver does not use of_node or supplies then it should use NULL
as config. If driver uses of_node or supplies then it should allocate
config on stack and initialize it with proper values.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
[for the nvec part]
Reviewed-by: Marc Dietrich <marvin24@gmx.de>
[for drivers/platform/x86/compal-laptop.c]
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
[for drivers/hid/*]
Reviewed-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power/power_supply_core.c')
-rw-r--r-- | drivers/power/power_supply_core.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c index 1c0978f961ea..a21e36ed8d41 100644 --- a/drivers/power/power_supply_core.c +++ b/drivers/power/power_supply_core.c @@ -536,7 +536,9 @@ static void psy_unregister_cooler(struct power_supply *psy) #endif static int __power_supply_register(struct device *parent, - struct power_supply *psy, bool ws) + struct power_supply *psy, + const struct power_supply_config *cfg, + bool ws) { struct device *dev; int rc; @@ -553,6 +555,12 @@ static int __power_supply_register(struct device *parent, dev->release = power_supply_dev_release; dev_set_drvdata(dev, psy); psy->dev = dev; + if (cfg) { + psy->drv_data = cfg->drv_data; + psy->of_node = cfg->of_node; + psy->supplied_to = cfg->supplied_to; + psy->num_supplicants = cfg->num_supplicants; + } rc = dev_set_name(dev, "%s", psy->name); if (rc) @@ -605,15 +613,17 @@ dev_set_name_failed: return rc; } -int power_supply_register(struct device *parent, struct power_supply *psy) +int power_supply_register(struct device *parent, struct power_supply *psy, + const struct power_supply_config *cfg) { - return __power_supply_register(parent, psy, true); + return __power_supply_register(parent, psy, cfg, true); } EXPORT_SYMBOL_GPL(power_supply_register); -int power_supply_register_no_ws(struct device *parent, struct power_supply *psy) +int power_supply_register_no_ws(struct device *parent, struct power_supply *psy, + const struct power_supply_config *cfg) { - return __power_supply_register(parent, psy, false); + return __power_supply_register(parent, psy, cfg, false); } EXPORT_SYMBOL_GPL(power_supply_register_no_ws); @@ -624,7 +634,8 @@ static void devm_power_supply_release(struct device *dev, void *res) power_supply_unregister(*psy); } -int devm_power_supply_register(struct device *parent, struct power_supply *psy) +int devm_power_supply_register(struct device *parent, struct power_supply *psy, + const struct power_supply_config *cfg) { struct power_supply **ptr = devres_alloc(devm_power_supply_release, sizeof(*ptr), GFP_KERNEL); @@ -632,7 +643,7 @@ int devm_power_supply_register(struct device *parent, struct power_supply *psy) if (!ptr) return -ENOMEM; - ret = __power_supply_register(parent, psy, true); + ret = __power_supply_register(parent, psy, cfg, true); if (ret < 0) devres_free(ptr); else { @@ -643,7 +654,8 @@ int devm_power_supply_register(struct device *parent, struct power_supply *psy) } EXPORT_SYMBOL_GPL(devm_power_supply_register); -int devm_power_supply_register_no_ws(struct device *parent, struct power_supply *psy) +int devm_power_supply_register_no_ws(struct device *parent, struct power_supply *psy, + const struct power_supply_config *cfg) { struct power_supply **ptr = devres_alloc(devm_power_supply_release, sizeof(*ptr), GFP_KERNEL); @@ -651,7 +663,7 @@ int devm_power_supply_register_no_ws(struct device *parent, struct power_supply if (!ptr) return -ENOMEM; - ret = __power_supply_register(parent, psy, false); + ret = __power_supply_register(parent, psy, cfg, false); if (ret < 0) devres_free(ptr); else { |