Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 283476
b: refs/heads/master
c: 52f56c6
h: refs/heads/master
v: v3
  • Loading branch information
Rhyland Klein authored and Anton Vorontsov committed Jan 6, 2012
1 parent c8e60a9 commit 2cf997f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e57f1b68c4066459ed9e49177cdcefa6973ce9d2
refs/heads/master: 52f56c69beb049928f6e1a3d484afe27843d6c04
19 changes: 16 additions & 3 deletions trunk/drivers/power/sbs-battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -775,6 +784,9 @@ static int __devinit sbs_probe(struct i2c_client *client,

kfree(chip);

exit_free_name:
kfree(name);

return rc;
}

Expand All @@ -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;

Expand Down

0 comments on commit 2cf997f

Please sign in to comment.