diff options
author | Rhyland Klein <rklein@nvidia.com> | 2011-12-06 02:50:49 +0100 |
---|---|---|
committer | Anton Vorontsov <cbouatmailru@gmail.com> | 2012-01-06 02:27:36 +0100 |
commit | 52f56c69beb049928f6e1a3d484afe27843d6c04 (patch) | |
tree | bf7ad24ea81ed723a103397ce3cdefb89c9d0e10 /drivers/power | |
parent | devicetree-bindings: Propagate bq20z75->sbs rename to dt bindings (diff) | |
download | linux-52f56c69beb049928f6e1a3d484afe27843d6c04.tar.xz linux-52f56c69beb049928f6e1a3d484afe27843d6c04.zip |
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>
Diffstat (limited to 'drivers/power')
-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, struct sbs_platform_data *pdata = client->dev.platform_data; int rc; int irq; + char *name; - chip = kzalloc(sizeof(struct sbs_info), GFP_KERNEL); - if (!chip) + name = kasprintf(GFP_KERNEL, "sbs-%s", dev_name(&client->dev)); + if (!name) { + dev_err(&client->dev, "Failed to allocate device name\n"); return -ENOMEM; + } + + chip = kzalloc(sizeof(struct sbs_info), GFP_KERNEL); + if (!chip) { + rc = -ENOMEM; + goto exit_free_name; + } chip->client = client; chip->enable_detection = false; chip->gpio_detect = false; - chip->power_supply.name = "battery"; + chip->power_supply.name = name; chip->power_supply.type = POWER_SUPPLY_TYPE_BATTERY; chip->power_supply.properties = sbs_properties; chip->power_supply.num_properties = ARRAY_SIZE(sbs_properties); @@ -775,6 +784,9 @@ exit_psupply: kfree(chip); +exit_free_name: + kfree(name); + return rc; } @@ -791,6 +803,7 @@ static int __devexit sbs_remove(struct i2c_client *client) cancel_delayed_work_sync(&chip->work); + kfree(chip->power_supply.name); kfree(chip); chip = NULL; |