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/test_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/test_power.c')
-rw-r--r-- | drivers/power/test_power.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/drivers/power/test_power.c b/drivers/power/test_power.c index f26b1fa00fe1..f6c92d1d7811 100644 --- a/drivers/power/test_power.c +++ b/drivers/power/test_power.c | |||
@@ -157,8 +157,6 @@ static struct power_supply test_power_supplies[] = { | |||
157 | [TEST_AC] = { | 157 | [TEST_AC] = { |
158 | .name = "test_ac", | 158 | .name = "test_ac", |
159 | .type = POWER_SUPPLY_TYPE_MAINS, | 159 | .type = POWER_SUPPLY_TYPE_MAINS, |
160 | .supplied_to = test_power_ac_supplied_to, | ||
161 | .num_supplicants = ARRAY_SIZE(test_power_ac_supplied_to), | ||
162 | .properties = test_power_ac_props, | 160 | .properties = test_power_ac_props, |
163 | .num_properties = ARRAY_SIZE(test_power_ac_props), | 161 | .num_properties = ARRAY_SIZE(test_power_ac_props), |
164 | .get_property = test_power_get_ac_property, | 162 | .get_property = test_power_get_ac_property, |
@@ -173,14 +171,25 @@ static struct power_supply test_power_supplies[] = { | |||
173 | [TEST_USB] = { | 171 | [TEST_USB] = { |
174 | .name = "test_usb", | 172 | .name = "test_usb", |
175 | .type = POWER_SUPPLY_TYPE_USB, | 173 | .type = POWER_SUPPLY_TYPE_USB, |
176 | .supplied_to = test_power_ac_supplied_to, | ||
177 | .num_supplicants = ARRAY_SIZE(test_power_ac_supplied_to), | ||
178 | .properties = test_power_ac_props, | 174 | .properties = test_power_ac_props, |
179 | .num_properties = ARRAY_SIZE(test_power_ac_props), | 175 | .num_properties = ARRAY_SIZE(test_power_ac_props), |
180 | .get_property = test_power_get_usb_property, | 176 | .get_property = test_power_get_usb_property, |
181 | }, | 177 | }, |
182 | }; | 178 | }; |
183 | 179 | ||
180 | static const struct power_supply_config test_power_configs[] = { | ||
181 | { | ||
182 | /* test_ac */ | ||
183 | .supplied_to = test_power_ac_supplied_to, | ||
184 | .num_supplicants = ARRAY_SIZE(test_power_ac_supplied_to), | ||
185 | }, { | ||
186 | /* test_battery */ | ||
187 | }, { | ||
188 | /* test_usb */ | ||
189 | .supplied_to = test_power_ac_supplied_to, | ||
190 | .num_supplicants = ARRAY_SIZE(test_power_ac_supplied_to), | ||
191 | }, | ||
192 | }; | ||
184 | 193 | ||
185 | static int __init test_power_init(void) | 194 | static int __init test_power_init(void) |
186 | { | 195 | { |
@@ -188,9 +197,11 @@ static int __init test_power_init(void) | |||
188 | int ret; | 197 | int ret; |
189 | 198 | ||
190 | BUILD_BUG_ON(TEST_POWER_NUM != ARRAY_SIZE(test_power_supplies)); | 199 | BUILD_BUG_ON(TEST_POWER_NUM != ARRAY_SIZE(test_power_supplies)); |
200 | BUILD_BUG_ON(TEST_POWER_NUM != ARRAY_SIZE(test_power_configs)); | ||
191 | 201 | ||
192 | for (i = 0; i < ARRAY_SIZE(test_power_supplies); i++) { | 202 | for (i = 0; i < ARRAY_SIZE(test_power_supplies); i++) { |
193 | ret = power_supply_register(NULL, &test_power_supplies[i]); | 203 | ret = power_supply_register(NULL, &test_power_supplies[i], |
204 | &test_power_configs[i]); | ||
194 | if (ret) { | 205 | if (ret) { |
195 | pr_err("%s: failed to register %s\n", __func__, | 206 | pr_err("%s: failed to register %s\n", __func__, |
196 | test_power_supplies[i].name); | 207 | test_power_supplies[i].name); |