diff options
author | Krzysztof Kozlowski <k.kozlowski@samsung.com> | 2015-03-12 03:44:02 -0400 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2015-03-13 18:15:12 -0400 |
commit | 2dc9215d7c94f7f9f34ccf8b1710ad73d82f6216 (patch) | |
tree | b8bae66b916e1f64dd725a68bca2182ee315bf66 /drivers/power/pda_power.c | |
parent | e44ea364394499d38a26ed4c9668fb378ae8797f (diff) |
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/pda_power.c')
-rw-r--r-- | drivers/power/pda_power.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c index 0c52e2a0d90c..fd55fad1d0db 100644 --- a/drivers/power/pda_power.c +++ b/drivers/power/pda_power.c | |||
@@ -83,8 +83,6 @@ static char *pda_power_supplied_to[] = { | |||
83 | static struct power_supply pda_psy_ac = { | 83 | static struct power_supply pda_psy_ac = { |
84 | .name = "ac", | 84 | .name = "ac", |
85 | .type = POWER_SUPPLY_TYPE_MAINS, | 85 | .type = POWER_SUPPLY_TYPE_MAINS, |
86 | .supplied_to = pda_power_supplied_to, | ||
87 | .num_supplicants = ARRAY_SIZE(pda_power_supplied_to), | ||
88 | .properties = pda_power_props, | 86 | .properties = pda_power_props, |
89 | .num_properties = ARRAY_SIZE(pda_power_props), | 87 | .num_properties = ARRAY_SIZE(pda_power_props), |
90 | .get_property = pda_power_get_property, | 88 | .get_property = pda_power_get_property, |
@@ -93,8 +91,6 @@ static struct power_supply pda_psy_ac = { | |||
93 | static struct power_supply pda_psy_usb = { | 91 | static struct power_supply pda_psy_usb = { |
94 | .name = "usb", | 92 | .name = "usb", |
95 | .type = POWER_SUPPLY_TYPE_USB, | 93 | .type = POWER_SUPPLY_TYPE_USB, |
96 | .supplied_to = pda_power_supplied_to, | ||
97 | .num_supplicants = ARRAY_SIZE(pda_power_supplied_to), | ||
98 | .properties = pda_power_props, | 94 | .properties = pda_power_props, |
99 | .num_properties = ARRAY_SIZE(pda_power_props), | 95 | .num_properties = ARRAY_SIZE(pda_power_props), |
100 | .get_property = pda_power_get_property, | 96 | .get_property = pda_power_get_property, |
@@ -262,6 +258,7 @@ static int otg_handle_notification(struct notifier_block *nb, | |||
262 | 258 | ||
263 | static int pda_power_probe(struct platform_device *pdev) | 259 | static int pda_power_probe(struct platform_device *pdev) |
264 | { | 260 | { |
261 | struct power_supply_config psy_cfg = {}; | ||
265 | int ret = 0; | 262 | int ret = 0; |
266 | 263 | ||
267 | dev = &pdev->dev; | 264 | dev = &pdev->dev; |
@@ -309,10 +306,11 @@ static int pda_power_probe(struct platform_device *pdev) | |||
309 | usb_irq = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "usb"); | 306 | usb_irq = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "usb"); |
310 | 307 | ||
311 | if (pdata->supplied_to) { | 308 | if (pdata->supplied_to) { |
312 | pda_psy_ac.supplied_to = pdata->supplied_to; | 309 | psy_cfg.supplied_to = pdata->supplied_to; |
313 | pda_psy_ac.num_supplicants = pdata->num_supplicants; | 310 | psy_cfg.num_supplicants = pdata->num_supplicants; |
314 | pda_psy_usb.supplied_to = pdata->supplied_to; | 311 | } else { |
315 | pda_psy_usb.num_supplicants = pdata->num_supplicants; | 312 | psy_cfg.supplied_to = pda_power_supplied_to; |
313 | psy_cfg.num_supplicants = ARRAY_SIZE(pda_power_supplied_to); | ||
316 | } | 314 | } |
317 | 315 | ||
318 | #if IS_ENABLED(CONFIG_USB_PHY) | 316 | #if IS_ENABLED(CONFIG_USB_PHY) |
@@ -326,7 +324,7 @@ static int pda_power_probe(struct platform_device *pdev) | |||
326 | #endif | 324 | #endif |
327 | 325 | ||
328 | if (pdata->is_ac_online) { | 326 | if (pdata->is_ac_online) { |
329 | ret = power_supply_register(&pdev->dev, &pda_psy_ac); | 327 | ret = power_supply_register(&pdev->dev, &pda_psy_ac, &psy_cfg); |
330 | if (ret) { | 328 | if (ret) { |
331 | dev_err(dev, "failed to register %s power supply\n", | 329 | dev_err(dev, "failed to register %s power supply\n", |
332 | pda_psy_ac.name); | 330 | pda_psy_ac.name); |
@@ -347,7 +345,7 @@ static int pda_power_probe(struct platform_device *pdev) | |||
347 | } | 345 | } |
348 | 346 | ||
349 | if (pdata->is_usb_online) { | 347 | if (pdata->is_usb_online) { |
350 | ret = power_supply_register(&pdev->dev, &pda_psy_usb); | 348 | ret = power_supply_register(&pdev->dev, &pda_psy_usb, &psy_cfg); |
351 | if (ret) { | 349 | if (ret) { |
352 | dev_err(dev, "failed to register %s power supply\n", | 350 | dev_err(dev, "failed to register %s power supply\n", |
353 | pda_psy_usb.name); | 351 | pda_psy_usb.name); |