summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-04-11 23:06:47 +0800
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-13 09:59:39 +0100
commitb7bd05b8d546cebbf05e98194b54d7b122aadf0e (patch)
treea274fdbbba84b208e5218da85dae75434aaa2e93
parentef6bd5a3f128254bee0b9052f3813ca3c3c82fb5 (diff)
regulator: max1586: Use devm_kzalloc()
Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--drivers/regulator/max1586.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c
index ea832b4ef64..b9444ee08da 100644
--- a/drivers/regulator/max1586.c
+++ b/drivers/regulator/max1586.c
@@ -189,18 +189,17 @@ static int __devinit max1586_pmic_probe(struct i2c_client *client,
struct max1586_data *max1586;
int i, id, ret = -ENOMEM;
- max1586 = kzalloc(sizeof(struct max1586_data) +
+ max1586 = devm_kzalloc(&client->dev, sizeof(struct max1586_data) +
sizeof(struct regulator_dev *) * (MAX1586_V6 + 1),
GFP_KERNEL);
if (!max1586)
- goto out;
+ return -ENOMEM;
max1586->client = client;
- if (!pdata->v3_gain) {
- ret = -EINVAL;
- goto out_unmap;
- }
+ if (!pdata->v3_gain)
+ return -EINVAL;
+
max1586->min_uV = MAX1586_V3_MIN_UV / 1000 * pdata->v3_gain / 1000;
max1586->max_uV = MAX1586_V3_MAX_UV / 1000 * pdata->v3_gain / 1000;
@@ -234,9 +233,6 @@ static int __devinit max1586_pmic_probe(struct i2c_client *client,
err:
while (--i >= 0)
regulator_unregister(rdev[i]);
-out_unmap:
- kfree(max1586);
-out:
return ret;
}
@@ -248,8 +244,6 @@ static int __devexit max1586_pmic_remove(struct i2c_client *client)
for (i = 0; i <= MAX1586_V6; i++)
if (max1586->rdev[i])
regulator_unregister(max1586->rdev[i]);
- kfree(max1586);
-
return 0;
}