diff options
| -rw-r--r-- | drivers/power/supply/olpc_battery.c | 64 |
1 files changed, 35 insertions, 29 deletions
diff --git a/drivers/power/supply/olpc_battery.c b/drivers/power/supply/olpc_battery.c index 0d67158c13d6..c628d3a47e14 100644 --- a/drivers/power/supply/olpc_battery.c +++ b/drivers/power/supply/olpc_battery.c | |||
| @@ -551,7 +551,7 @@ static ssize_t olpc_bat_eeprom_read(struct file *filp, struct kobject *kobj, | |||
| 551 | return count; | 551 | return count; |
| 552 | } | 552 | } |
| 553 | 553 | ||
| 554 | static const struct bin_attribute olpc_bat_eeprom = { | 554 | static struct bin_attribute olpc_bat_eeprom = { |
| 555 | .attr = { | 555 | .attr = { |
| 556 | .name = "eeprom", | 556 | .name = "eeprom", |
| 557 | .mode = S_IRUGO, | 557 | .mode = S_IRUGO, |
| @@ -575,7 +575,7 @@ static ssize_t olpc_bat_error_read(struct device *dev, | |||
| 575 | return sprintf(buf, "%d\n", ec_byte); | 575 | return sprintf(buf, "%d\n", ec_byte); |
| 576 | } | 576 | } |
| 577 | 577 | ||
| 578 | static const struct device_attribute olpc_bat_error = { | 578 | static struct device_attribute olpc_bat_error = { |
| 579 | .attr = { | 579 | .attr = { |
| 580 | .name = "error", | 580 | .name = "error", |
| 581 | .mode = S_IRUGO, | 581 | .mode = S_IRUGO, |
| @@ -583,6 +583,27 @@ static const struct device_attribute olpc_bat_error = { | |||
| 583 | .show = olpc_bat_error_read, | 583 | .show = olpc_bat_error_read, |
| 584 | }; | 584 | }; |
| 585 | 585 | ||
| 586 | static struct attribute *olpc_bat_sysfs_attrs[] = { | ||
| 587 | &olpc_bat_error.attr, | ||
| 588 | NULL | ||
| 589 | }; | ||
| 590 | |||
| 591 | static struct bin_attribute *olpc_bat_sysfs_bin_attrs[] = { | ||
| 592 | &olpc_bat_eeprom, | ||
| 593 | NULL | ||
| 594 | }; | ||
| 595 | |||
| 596 | static const struct attribute_group olpc_bat_sysfs_group = { | ||
| 597 | .attrs = olpc_bat_sysfs_attrs, | ||
| 598 | .bin_attrs = olpc_bat_sysfs_bin_attrs, | ||
| 599 | |||
| 600 | }; | ||
| 601 | |||
| 602 | static const struct attribute_group *olpc_bat_sysfs_groups[] = { | ||
| 603 | &olpc_bat_sysfs_group, | ||
| 604 | NULL | ||
| 605 | }; | ||
| 606 | |||
| 586 | /********************************************************************* | 607 | /********************************************************************* |
| 587 | * Initialisation | 608 | * Initialisation |
| 588 | *********************************************************************/ | 609 | *********************************************************************/ |
| @@ -615,7 +636,8 @@ static int olpc_battery_suspend(struct platform_device *pdev, | |||
| 615 | 636 | ||
| 616 | static int olpc_battery_probe(struct platform_device *pdev) | 637 | static int olpc_battery_probe(struct platform_device *pdev) |
| 617 | { | 638 | { |
| 618 | struct power_supply_config psy_cfg = {}; | 639 | struct power_supply_config bat_psy_cfg = {}; |
| 640 | struct power_supply_config ac_psy_cfg = {}; | ||
| 619 | struct olpc_battery_data *data; | 641 | struct olpc_battery_data *data; |
| 620 | uint8_t status; | 642 | uint8_t status; |
| 621 | uint8_t ecver; | 643 | uint8_t ecver; |
| @@ -654,10 +676,11 @@ static int olpc_battery_probe(struct platform_device *pdev) | |||
| 654 | 676 | ||
| 655 | /* Ignore the status. It doesn't actually matter */ | 677 | /* Ignore the status. It doesn't actually matter */ |
| 656 | 678 | ||
| 657 | psy_cfg.of_node = pdev->dev.of_node; | 679 | ac_psy_cfg.of_node = pdev->dev.of_node; |
| 658 | psy_cfg.drv_data = data; | 680 | ac_psy_cfg.drv_data = data; |
| 659 | 681 | ||
| 660 | data->olpc_ac = devm_power_supply_register(&pdev->dev, &olpc_ac_desc, &psy_cfg); | 682 | data->olpc_ac = devm_power_supply_register(&pdev->dev, &olpc_ac_desc, |
| 683 | &ac_psy_cfg); | ||
| 661 | if (IS_ERR(data->olpc_ac)) | 684 | if (IS_ERR(data->olpc_ac)) |
| 662 | return PTR_ERR(data->olpc_ac); | 685 | return PTR_ERR(data->olpc_ac); |
| 663 | 686 | ||
| @@ -671,37 +694,21 @@ static int olpc_battery_probe(struct platform_device *pdev) | |||
| 671 | olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo1_bat_props); | 694 | olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo1_bat_props); |
| 672 | } | 695 | } |
| 673 | 696 | ||
| 674 | data->olpc_bat = devm_power_supply_register(&pdev->dev, &olpc_bat_desc, &psy_cfg); | 697 | bat_psy_cfg.of_node = pdev->dev.of_node; |
| 698 | bat_psy_cfg.drv_data = data; | ||
| 699 | bat_psy_cfg.attr_grp = olpc_bat_sysfs_groups; | ||
| 700 | |||
| 701 | data->olpc_bat = devm_power_supply_register(&pdev->dev, &olpc_bat_desc, | ||
| 702 | &bat_psy_cfg); | ||
| 675 | if (IS_ERR(data->olpc_bat)) | 703 | if (IS_ERR(data->olpc_bat)) |
| 676 | return PTR_ERR(data->olpc_bat); | 704 | return PTR_ERR(data->olpc_bat); |
| 677 | 705 | ||
| 678 | ret = device_create_bin_file(&data->olpc_bat->dev, &olpc_bat_eeprom); | ||
| 679 | if (ret) | ||
| 680 | return ret; | ||
| 681 | |||
| 682 | ret = device_create_file(&data->olpc_bat->dev, &olpc_bat_error); | ||
| 683 | if (ret) | ||
| 684 | goto error_failed; | ||
| 685 | |||
| 686 | if (olpc_ec_wakeup_available()) { | 706 | if (olpc_ec_wakeup_available()) { |
| 687 | device_set_wakeup_capable(&data->olpc_ac->dev, true); | 707 | device_set_wakeup_capable(&data->olpc_ac->dev, true); |
| 688 | device_set_wakeup_capable(&data->olpc_bat->dev, true); | 708 | device_set_wakeup_capable(&data->olpc_bat->dev, true); |
| 689 | } | 709 | } |
| 690 | 710 | ||
| 691 | return 0; | 711 | return 0; |
| 692 | |||
| 693 | error_failed: | ||
| 694 | device_remove_bin_file(&data->olpc_bat->dev, &olpc_bat_eeprom); | ||
| 695 | return ret; | ||
| 696 | } | ||
| 697 | |||
| 698 | static int olpc_battery_remove(struct platform_device *pdev) | ||
| 699 | { | ||
| 700 | struct olpc_battery_data *data = platform_get_drvdata(pdev); | ||
| 701 | |||
| 702 | device_remove_file(&data->olpc_bat->dev, &olpc_bat_error); | ||
| 703 | device_remove_bin_file(&data->olpc_bat->dev, &olpc_bat_eeprom); | ||
| 704 | return 0; | ||
| 705 | } | 712 | } |
| 706 | 713 | ||
| 707 | static const struct of_device_id olpc_battery_ids[] = { | 714 | static const struct of_device_id olpc_battery_ids[] = { |
| @@ -717,7 +724,6 @@ static struct platform_driver olpc_battery_driver = { | |||
| 717 | .of_match_table = olpc_battery_ids, | 724 | .of_match_table = olpc_battery_ids, |
| 718 | }, | 725 | }, |
| 719 | .probe = olpc_battery_probe, | 726 | .probe = olpc_battery_probe, |
| 720 | .remove = olpc_battery_remove, | ||
| 721 | .suspend = olpc_battery_suspend, | 727 | .suspend = olpc_battery_suspend, |
| 722 | }; | 728 | }; |
| 723 | 729 | ||
