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/smb347-charger.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/smb347-charger.c')
-rw-r--r-- | drivers/power/smb347-charger.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/power/smb347-charger.c b/drivers/power/smb347-charger.c index e9702de262e5..4396a1ffeb1a 100644 --- a/drivers/power/smb347-charger.c +++ b/drivers/power/smb347-charger.c | |||
@@ -1194,6 +1194,7 @@ static int smb347_probe(struct i2c_client *client, | |||
1194 | { | 1194 | { |
1195 | static char *battery[] = { "smb347-battery" }; | 1195 | static char *battery[] = { "smb347-battery" }; |
1196 | const struct smb347_charger_platform_data *pdata; | 1196 | const struct smb347_charger_platform_data *pdata; |
1197 | struct power_supply_config psy_cfg = {}; /* Only for mains and usb */ | ||
1197 | struct device *dev = &client->dev; | 1198 | struct device *dev = &client->dev; |
1198 | struct smb347_charger *smb; | 1199 | struct smb347_charger *smb; |
1199 | int ret; | 1200 | int ret; |
@@ -1223,15 +1224,15 @@ static int smb347_probe(struct i2c_client *client, | |||
1223 | if (ret < 0) | 1224 | if (ret < 0) |
1224 | return ret; | 1225 | return ret; |
1225 | 1226 | ||
1227 | psy_cfg.supplied_to = battery; | ||
1228 | psy_cfg.num_supplicants = ARRAY_SIZE(battery); | ||
1226 | if (smb->pdata->use_mains) { | 1229 | if (smb->pdata->use_mains) { |
1227 | smb->mains.name = "smb347-mains"; | 1230 | smb->mains.name = "smb347-mains"; |
1228 | smb->mains.type = POWER_SUPPLY_TYPE_MAINS; | 1231 | smb->mains.type = POWER_SUPPLY_TYPE_MAINS; |
1229 | smb->mains.get_property = smb347_mains_get_property; | 1232 | smb->mains.get_property = smb347_mains_get_property; |
1230 | smb->mains.properties = smb347_mains_properties; | 1233 | smb->mains.properties = smb347_mains_properties; |
1231 | smb->mains.num_properties = ARRAY_SIZE(smb347_mains_properties); | 1234 | smb->mains.num_properties = ARRAY_SIZE(smb347_mains_properties); |
1232 | smb->mains.supplied_to = battery; | 1235 | ret = power_supply_register(dev, &smb->mains, &psy_cfg); |
1233 | smb->mains.num_supplicants = ARRAY_SIZE(battery); | ||
1234 | ret = power_supply_register(dev, &smb->mains); | ||
1235 | if (ret < 0) | 1236 | if (ret < 0) |
1236 | return ret; | 1237 | return ret; |
1237 | } | 1238 | } |
@@ -1242,9 +1243,7 @@ static int smb347_probe(struct i2c_client *client, | |||
1242 | smb->usb.get_property = smb347_usb_get_property; | 1243 | smb->usb.get_property = smb347_usb_get_property; |
1243 | smb->usb.properties = smb347_usb_properties; | 1244 | smb->usb.properties = smb347_usb_properties; |
1244 | smb->usb.num_properties = ARRAY_SIZE(smb347_usb_properties); | 1245 | smb->usb.num_properties = ARRAY_SIZE(smb347_usb_properties); |
1245 | smb->usb.supplied_to = battery; | 1246 | ret = power_supply_register(dev, &smb->usb, &psy_cfg); |
1246 | smb->usb.num_supplicants = ARRAY_SIZE(battery); | ||
1247 | ret = power_supply_register(dev, &smb->usb); | ||
1248 | if (ret < 0) { | 1247 | if (ret < 0) { |
1249 | if (smb->pdata->use_mains) | 1248 | if (smb->pdata->use_mains) |
1250 | power_supply_unregister(&smb->mains); | 1249 | power_supply_unregister(&smb->mains); |
@@ -1259,7 +1258,7 @@ static int smb347_probe(struct i2c_client *client, | |||
1259 | smb->battery.num_properties = ARRAY_SIZE(smb347_battery_properties); | 1258 | smb->battery.num_properties = ARRAY_SIZE(smb347_battery_properties); |
1260 | 1259 | ||
1261 | 1260 | ||
1262 | ret = power_supply_register(dev, &smb->battery); | 1261 | ret = power_supply_register(dev, &smb->battery, NULL); |
1263 | if (ret < 0) { | 1262 | if (ret < 0) { |
1264 | if (smb->pdata->use_usb) | 1263 | if (smb->pdata->use_usb) |
1265 | power_supply_unregister(&smb->usb); | 1264 | power_supply_unregister(&smb->usb); |