Commit b7bd05b8 authored by Axel Lin's avatar Axel Lin Committed by Mark Brown

regulator: max1586: Use devm_kzalloc()

Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent ef6bd5a3
...@@ -189,18 +189,17 @@ static int __devinit max1586_pmic_probe(struct i2c_client *client, ...@@ -189,18 +189,17 @@ static int __devinit max1586_pmic_probe(struct i2c_client *client,
struct max1586_data *max1586; struct max1586_data *max1586;
int i, id, ret = -ENOMEM; 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), sizeof(struct regulator_dev *) * (MAX1586_V6 + 1),
GFP_KERNEL); GFP_KERNEL);
if (!max1586) if (!max1586)
goto out; return -ENOMEM;
max1586->client = client; max1586->client = client;
if (!pdata->v3_gain) { if (!pdata->v3_gain)
ret = -EINVAL; return -EINVAL;
goto out_unmap;
}
max1586->min_uV = MAX1586_V3_MIN_UV / 1000 * pdata->v3_gain / 1000; max1586->min_uV = MAX1586_V3_MIN_UV / 1000 * pdata->v3_gain / 1000;
max1586->max_uV = MAX1586_V3_MAX_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, ...@@ -234,9 +233,6 @@ static int __devinit max1586_pmic_probe(struct i2c_client *client,
err: err:
while (--i >= 0) while (--i >= 0)
regulator_unregister(rdev[i]); regulator_unregister(rdev[i]);
out_unmap:
kfree(max1586);
out:
return ret; return ret;
} }
...@@ -248,8 +244,6 @@ static int __devexit max1586_pmic_remove(struct i2c_client *client) ...@@ -248,8 +244,6 @@ static int __devexit max1586_pmic_remove(struct i2c_client *client)
for (i = 0; i <= MAX1586_V6; i++) for (i = 0; i <= MAX1586_V6; i++)
if (max1586->rdev[i]) if (max1586->rdev[i])
regulator_unregister(max1586->rdev[i]); regulator_unregister(max1586->rdev[i]);
kfree(max1586);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment