aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/max1586.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-04-11 11:06:47 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-13 04:59:39 -0400
commitb7bd05b8d546cebbf05e98194b54d7b122aadf0e (patch)
treea274fdbbba84b208e5218da85dae75434aaa2e93 /drivers/regulator/max1586.c
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>
Diffstat (limited to 'drivers/regulator/max1586.c')
-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 ea832b4ef643..b9444ee08da9 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,
189 struct max1586_data *max1586; 189 struct max1586_data *max1586;
190 int i, id, ret = -ENOMEM; 190 int i, id, ret = -ENOMEM;
191 191
192 max1586 = kzalloc(sizeof(struct max1586_data) + 192 max1586 = devm_kzalloc(&client->dev, sizeof(struct max1586_data) +
193 sizeof(struct regulator_dev *) * (MAX1586_V6 + 1), 193 sizeof(struct regulator_dev *) * (MAX1586_V6 + 1),
194 GFP_KERNEL); 194 GFP_KERNEL);
195 if (!max1586) 195 if (!max1586)
196 goto out; 196 return -ENOMEM;
197 197
198 max1586->client = client; 198 max1586->client = client;
199 199
200 if (!pdata->v3_gain) { 200 if (!pdata->v3_gain)
201 ret = -EINVAL; 201 return -EINVAL;
202 goto out_unmap; 202
203 }
204 max1586->min_uV = MAX1586_V3_MIN_UV / 1000 * pdata->v3_gain / 1000; 203 max1586->min_uV = MAX1586_V3_MIN_UV / 1000 * pdata->v3_gain / 1000;
205 max1586->max_uV = MAX1586_V3_MAX_UV / 1000 * pdata->v3_gain / 1000; 204 max1586->max_uV = MAX1586_V3_MAX_UV / 1000 * pdata->v3_gain / 1000;
206 205
@@ -234,9 +233,6 @@ static int __devinit max1586_pmic_probe(struct i2c_client *client,
234err: 233err:
235 while (--i >= 0) 234 while (--i >= 0)
236 regulator_unregister(rdev[i]); 235 regulator_unregister(rdev[i]);
237out_unmap:
238 kfree(max1586);
239out:
240 return ret; 236 return ret;
241} 237}
242 238
@@ -248,8 +244,6 @@ static int __devexit max1586_pmic_remove(struct i2c_client *client)
248 for (i = 0; i <= MAX1586_V6; i++) 244 for (i = 0; i <= MAX1586_V6; i++)
249 if (max1586->rdev[i]) 245 if (max1586->rdev[i])
250 regulator_unregister(max1586->rdev[i]); 246 regulator_unregister(max1586->rdev[i]);
251 kfree(max1586);
252
253 return 0; 247 return 0;
254} 248}
255 249