Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Mark Brown and committed by
Anton Vorontsov
d0376031 c84cad3d

+11 -1
+11 -1
drivers/power/wm831x_backup.c
··· 22 22 struct wm831x_backup { 23 23 struct wm831x *wm831x; 24 24 struct power_supply backup; 25 + char name[20]; 25 26 }; 26 27 27 28 static int wm831x_backup_read_voltage(struct wm831x *wm831x, ··· 164 163 static __devinit int wm831x_backup_probe(struct platform_device *pdev) 165 164 { 166 165 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 166 + struct wm831x_pdata *wm831x_pdata = wm831x->dev->platform_data; 167 167 struct wm831x_backup *devdata; 168 168 struct power_supply *backup; 169 169 int ret; ··· 184 182 */ 185 183 wm831x_config_backup(wm831x); 186 184 187 - backup->name = "wm831x-backup"; 185 + if (wm831x_pdata && wm831x_pdata->wm831x_num) 186 + snprintf(devdata->name, sizeof(devdata->name), 187 + "wm831x-backup.%d", wm831x_pdata->wm831x_num); 188 + else 189 + snprintf(devdata->name, sizeof(devdata->name), 190 + "wm831x-backup"); 191 + 192 + backup->name = devdata->name; 188 193 backup->type = POWER_SUPPLY_TYPE_BATTERY; 189 194 backup->properties = wm831x_backup_props; 190 195 backup->num_properties = ARRAY_SIZE(wm831x_backup_props); ··· 212 203 struct wm831x_backup *devdata = platform_get_drvdata(pdev); 213 204 214 205 power_supply_unregister(&devdata->backup); 206 + kfree(devdata->backup.name); 215 207 kfree(devdata); 216 208 217 209 return 0;