diff options
author | Rhyland Klein <rklein@nvidia.com> | 2011-12-05 20:50:49 -0500 |
---|---|---|
committer | Anton Vorontsov <cbouatmailru@gmail.com> | 2012-01-05 20:27:36 -0500 |
commit | 52f56c69beb049928f6e1a3d484afe27843d6c04 (patch) | |
tree | bf7ad24ea81ed723a103397ce3cdefb89c9d0e10 | |
parent | e57f1b68c4066459ed9e49177cdcefa6973ce9d2 (diff) |
sbs-battery: Change power supply name
The power supply name used to be fixed as "battery". This change allows
for multiple batteries by generating the name rather than using a fixed
value.
Signed-off-by: Rhyland Klein <rklein@nvidia.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
-rw-r--r-- | drivers/power/sbs-battery.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/drivers/power/sbs-battery.c b/drivers/power/sbs-battery.c index 00bd9e079e80..b677b88da00f 100644 --- a/drivers/power/sbs-battery.c +++ b/drivers/power/sbs-battery.c | |||
@@ -682,15 +682,24 @@ static int __devinit sbs_probe(struct i2c_client *client, | |||
682 | struct sbs_platform_data *pdata = client->dev.platform_data; | 682 | struct sbs_platform_data *pdata = client->dev.platform_data; |
683 | int rc; | 683 | int rc; |
684 | int irq; | 684 | int irq; |
685 | char *name; | ||
685 | 686 | ||
686 | chip = kzalloc(sizeof(struct sbs_info), GFP_KERNEL); | 687 | name = kasprintf(GFP_KERNEL, "sbs-%s", dev_name(&client->dev)); |
687 | if (!chip) | 688 | if (!name) { |
689 | dev_err(&client->dev, "Failed to allocate device name\n"); | ||
688 | return -ENOMEM; | 690 | return -ENOMEM; |
691 | } | ||
692 | |||
693 | chip = kzalloc(sizeof(struct sbs_info), GFP_KERNEL); | ||
694 | if (!chip) { | ||
695 | rc = -ENOMEM; | ||
696 | goto exit_free_name; | ||
697 | } | ||
689 | 698 | ||
690 | chip->client = client; | 699 | chip->client = client; |
691 | chip->enable_detection = false; | 700 | chip->enable_detection = false; |
692 | chip->gpio_detect = false; | 701 | chip->gpio_detect = false; |
693 | chip->power_supply.name = "battery"; | 702 | chip->power_supply.name = name; |
694 | chip->power_supply.type = POWER_SUPPLY_TYPE_BATTERY; | 703 | chip->power_supply.type = POWER_SUPPLY_TYPE_BATTERY; |
695 | chip->power_supply.properties = sbs_properties; | 704 | chip->power_supply.properties = sbs_properties; |
696 | chip->power_supply.num_properties = ARRAY_SIZE(sbs_properties); | 705 | chip->power_supply.num_properties = ARRAY_SIZE(sbs_properties); |
@@ -775,6 +784,9 @@ exit_psupply: | |||
775 | 784 | ||
776 | kfree(chip); | 785 | kfree(chip); |
777 | 786 | ||
787 | exit_free_name: | ||
788 | kfree(name); | ||
789 | |||
778 | return rc; | 790 | return rc; |
779 | } | 791 | } |
780 | 792 | ||
@@ -791,6 +803,7 @@ static int __devexit sbs_remove(struct i2c_client *client) | |||
791 | 803 | ||
792 | cancel_delayed_work_sync(&chip->work); | 804 | cancel_delayed_work_sync(&chip->work); |
793 | 805 | ||
806 | kfree(chip->power_supply.name); | ||
794 | kfree(chip); | 807 | kfree(chip); |
795 | chip = NULL; | 808 | chip = NULL; |
796 | 809 | ||