diff options
Diffstat (limited to 'drivers/power/wm831x_power.c')
-rw-r--r-- | drivers/power/wm831x_power.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/drivers/power/wm831x_power.c b/drivers/power/wm831x_power.c index ddf8cf5f3204..6cc2ca6427f3 100644 --- a/drivers/power/wm831x_power.c +++ b/drivers/power/wm831x_power.c | |||
@@ -24,6 +24,9 @@ struct wm831x_power { | |||
24 | struct power_supply wall; | 24 | struct power_supply wall; |
25 | struct power_supply usb; | 25 | struct power_supply usb; |
26 | struct power_supply battery; | 26 | struct power_supply battery; |
27 | char wall_name[20]; | ||
28 | char usb_name[20]; | ||
29 | char battery_name[20]; | ||
27 | }; | 30 | }; |
28 | 31 | ||
29 | static int wm831x_power_check_online(struct wm831x *wm831x, int supply, | 32 | static int wm831x_power_check_online(struct wm831x *wm831x, int supply, |
@@ -486,6 +489,7 @@ static irqreturn_t wm831x_pwr_src_irq(int irq, void *data) | |||
486 | static __devinit int wm831x_power_probe(struct platform_device *pdev) | 489 | static __devinit int wm831x_power_probe(struct platform_device *pdev) |
487 | { | 490 | { |
488 | struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); | 491 | struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); |
492 | struct wm831x_pdata *wm831x_pdata = wm831x->dev->platform_data; | ||
489 | struct wm831x_power *power; | 493 | struct wm831x_power *power; |
490 | struct power_supply *usb; | 494 | struct power_supply *usb; |
491 | struct power_supply *battery; | 495 | struct power_supply *battery; |
@@ -503,12 +507,28 @@ static __devinit int wm831x_power_probe(struct platform_device *pdev) | |||
503 | battery = &power->battery; | 507 | battery = &power->battery; |
504 | wall = &power->wall; | 508 | wall = &power->wall; |
505 | 509 | ||
510 | if (wm831x_pdata && wm831x_pdata->wm831x_num) { | ||
511 | snprintf(power->wall_name, sizeof(power->wall_name), | ||
512 | "wm831x-wall.%d", wm831x_pdata->wm831x_num); | ||
513 | snprintf(power->battery_name, sizeof(power->wall_name), | ||
514 | "wm831x-battery.%d", wm831x_pdata->wm831x_num); | ||
515 | snprintf(power->usb_name, sizeof(power->wall_name), | ||
516 | "wm831x-usb.%d", wm831x_pdata->wm831x_num); | ||
517 | } else { | ||
518 | snprintf(power->wall_name, sizeof(power->wall_name), | ||
519 | "wm831x-wall"); | ||
520 | snprintf(power->battery_name, sizeof(power->wall_name), | ||
521 | "wm831x-battery"); | ||
522 | snprintf(power->usb_name, sizeof(power->wall_name), | ||
523 | "wm831x-usb"); | ||
524 | } | ||
525 | |||
506 | /* We ignore configuration failures since we can still read back | 526 | /* We ignore configuration failures since we can still read back |
507 | * the status without enabling the charger. | 527 | * the status without enabling the charger. |
508 | */ | 528 | */ |
509 | wm831x_config_battery(wm831x); | 529 | wm831x_config_battery(wm831x); |
510 | 530 | ||
511 | wall->name = "wm831x-wall"; | 531 | wall->name = power->wall_name; |
512 | wall->type = POWER_SUPPLY_TYPE_MAINS; | 532 | wall->type = POWER_SUPPLY_TYPE_MAINS; |
513 | wall->properties = wm831x_wall_props; | 533 | wall->properties = wm831x_wall_props; |
514 | wall->num_properties = ARRAY_SIZE(wm831x_wall_props); | 534 | wall->num_properties = ARRAY_SIZE(wm831x_wall_props); |
@@ -517,7 +537,7 @@ static __devinit int wm831x_power_probe(struct platform_device *pdev) | |||
517 | if (ret) | 537 | if (ret) |
518 | goto err_kmalloc; | 538 | goto err_kmalloc; |
519 | 539 | ||
520 | battery->name = "wm831x-battery"; | 540 | battery->name = power->battery_name; |
521 | battery->properties = wm831x_bat_props; | 541 | battery->properties = wm831x_bat_props; |
522 | battery->num_properties = ARRAY_SIZE(wm831x_bat_props); | 542 | battery->num_properties = ARRAY_SIZE(wm831x_bat_props); |
523 | battery->get_property = wm831x_bat_get_prop; | 543 | battery->get_property = wm831x_bat_get_prop; |
@@ -526,7 +546,7 @@ static __devinit int wm831x_power_probe(struct platform_device *pdev) | |||
526 | if (ret) | 546 | if (ret) |
527 | goto err_wall; | 547 | goto err_wall; |
528 | 548 | ||
529 | usb->name = "wm831x-usb", | 549 | usb->name = power->usb_name, |
530 | usb->type = POWER_SUPPLY_TYPE_USB; | 550 | usb->type = POWER_SUPPLY_TYPE_USB; |
531 | usb->properties = wm831x_usb_props; | 551 | usb->properties = wm831x_usb_props; |
532 | usb->num_properties = ARRAY_SIZE(wm831x_usb_props); | 552 | usb->num_properties = ARRAY_SIZE(wm831x_usb_props); |