regulator: max8649: Use devm_* APIs
Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
parent
268a164135
commit
dc553a7994
|
@ -230,17 +230,18 @@ static int __devinit max8649_regulator_probe(struct i2c_client *client,
|
||||||
unsigned char data;
|
unsigned char data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
info = kzalloc(sizeof(struct max8649_regulator_info), GFP_KERNEL);
|
info = devm_kzalloc(&client->dev, sizeof(struct max8649_regulator_info),
|
||||||
|
GFP_KERNEL);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
dev_err(&client->dev, "No enough memory\n");
|
dev_err(&client->dev, "No enough memory\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
info->regmap = regmap_init_i2c(client, &max8649_regmap_config);
|
info->regmap = devm_regmap_init_i2c(client, &max8649_regmap_config);
|
||||||
if (IS_ERR(info->regmap)) {
|
if (IS_ERR(info->regmap)) {
|
||||||
ret = PTR_ERR(info->regmap);
|
ret = PTR_ERR(info->regmap);
|
||||||
dev_err(&client->dev, "Failed to allocate register map: %d\n", ret);
|
dev_err(&client->dev, "Failed to allocate register map: %d\n", ret);
|
||||||
goto fail;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
info->dev = &client->dev;
|
info->dev = &client->dev;
|
||||||
|
@ -268,7 +269,7 @@ static int __devinit max8649_regulator_probe(struct i2c_client *client,
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
dev_err(info->dev, "Failed to detect ID of MAX8649:%d\n",
|
dev_err(info->dev, "Failed to detect ID of MAX8649:%d\n",
|
||||||
ret);
|
ret);
|
||||||
goto out;
|
return ret;
|
||||||
}
|
}
|
||||||
dev_info(info->dev, "Detected MAX8649 (ID:%x)\n", val);
|
dev_info(info->dev, "Detected MAX8649 (ID:%x)\n", val);
|
||||||
|
|
||||||
|
@ -306,16 +307,10 @@ static int __devinit max8649_regulator_probe(struct i2c_client *client,
|
||||||
if (IS_ERR(info->regulator)) {
|
if (IS_ERR(info->regulator)) {
|
||||||
dev_err(info->dev, "failed to register regulator %s\n",
|
dev_err(info->dev, "failed to register regulator %s\n",
|
||||||
dcdc_desc.name);
|
dcdc_desc.name);
|
||||||
ret = PTR_ERR(info->regulator);
|
return PTR_ERR(info->regulator);
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
out:
|
|
||||||
regmap_exit(info->regmap);
|
|
||||||
fail:
|
|
||||||
kfree(info);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __devexit max8649_regulator_remove(struct i2c_client *client)
|
static int __devexit max8649_regulator_remove(struct i2c_client *client)
|
||||||
|
@ -325,8 +320,6 @@ static int __devexit max8649_regulator_remove(struct i2c_client *client)
|
||||||
if (info) {
|
if (info) {
|
||||||
if (info->regulator)
|
if (info->regulator)
|
||||||
regulator_unregister(info->regulator);
|
regulator_unregister(info->regulator);
|
||||||
regmap_exit(info->regmap);
|
|
||||||
kfree(info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue