aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2011-05-31 08:30:10 -0400
committerAnton Vorontsov <cbouatmailru@gmail.com>2011-07-08 08:56:47 -0400
commitd03760318edbc78b72cb7fa96bddb65263384d24 (patch)
tree8bfb9911bbd9b5e2805585196adc6b8581ef2dda /drivers/power
parentc84cad3d0fbb09dbfb30336ab05181cdbe097634 (diff)
wm831x_backup: Support multiple instances
If there are multiple wm831x devices in the system we need to assign different names to the power supply devices in order to ensure we can create the sysfs entries for them. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/wm831x_backup.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/power/wm831x_backup.c b/drivers/power/wm831x_backup.c
index 0fd130d80f5d..e648cbea1e6a 100644
--- a/drivers/power/wm831x_backup.c
+++ b/drivers/power/wm831x_backup.c
@@ -22,6 +22,7 @@
22struct wm831x_backup { 22struct wm831x_backup {
23 struct wm831x *wm831x; 23 struct wm831x *wm831x;
24 struct power_supply backup; 24 struct power_supply backup;
25 char name[20];
25}; 26};
26 27
27static int wm831x_backup_read_voltage(struct wm831x *wm831x, 28static int wm831x_backup_read_voltage(struct wm831x *wm831x,
@@ -163,6 +164,7 @@ static enum power_supply_property wm831x_backup_props[] = {
163static __devinit int wm831x_backup_probe(struct platform_device *pdev) 164static __devinit int wm831x_backup_probe(struct platform_device *pdev)
164{ 165{
165 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 166 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
167 struct wm831x_pdata *wm831x_pdata = wm831x->dev->platform_data;
166 struct wm831x_backup *devdata; 168 struct wm831x_backup *devdata;
167 struct power_supply *backup; 169 struct power_supply *backup;
168 int ret; 170 int ret;
@@ -182,7 +184,14 @@ static __devinit int wm831x_backup_probe(struct platform_device *pdev)
182 */ 184 */
183 wm831x_config_backup(wm831x); 185 wm831x_config_backup(wm831x);
184 186
185 backup->name = "wm831x-backup"; 187 if (wm831x_pdata && wm831x_pdata->wm831x_num)
188 snprintf(devdata->name, sizeof(devdata->name),
189 "wm831x-backup.%d", wm831x_pdata->wm831x_num);
190 else
191 snprintf(devdata->name, sizeof(devdata->name),
192 "wm831x-backup");
193
194 backup->name = devdata->name;
186 backup->type = POWER_SUPPLY_TYPE_BATTERY; 195 backup->type = POWER_SUPPLY_TYPE_BATTERY;
187 backup->properties = wm831x_backup_props; 196 backup->properties = wm831x_backup_props;
188 backup->num_properties = ARRAY_SIZE(wm831x_backup_props); 197 backup->num_properties = ARRAY_SIZE(wm831x_backup_props);
@@ -203,6 +212,7 @@ static __devexit int wm831x_backup_remove(struct platform_device *pdev)
203 struct wm831x_backup *devdata = platform_get_drvdata(pdev); 212 struct wm831x_backup *devdata = platform_get_drvdata(pdev);
204 213
205 power_supply_unregister(&devdata->backup); 214 power_supply_unregister(&devdata->backup);
215 kfree(devdata->backup.name);
206 kfree(devdata); 216 kfree(devdata);
207 217
208 return 0; 218 return 0;