Commit 742413a4 authored by Lee Jones's avatar Lee Jones Committed by Samuel Ortiz

mfd: max77686: Convert to managed resources for allocating memory

Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent fa75d4a6
...@@ -85,12 +85,12 @@ static int max77686_i2c_probe(struct i2c_client *i2c, ...@@ -85,12 +85,12 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
pdata = max77686_i2c_parse_dt_pdata(&i2c->dev); pdata = max77686_i2c_parse_dt_pdata(&i2c->dev);
if (!pdata) { if (!pdata) {
ret = -EIO;
dev_err(&i2c->dev, "No platform data found.\n"); dev_err(&i2c->dev, "No platform data found.\n");
goto err; return -EIO;
} }
max77686 = kzalloc(sizeof(struct max77686_dev), GFP_KERNEL); max77686 = devm_kzalloc(&i2c->dev,
sizeof(struct max77686_dev), GFP_KERNEL);
if (max77686 == NULL) if (max77686 == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -108,7 +108,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c, ...@@ -108,7 +108,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
ret = PTR_ERR(max77686->regmap); ret = PTR_ERR(max77686->regmap);
dev_err(max77686->dev, "Failed to allocate register map: %d\n", dev_err(max77686->dev, "Failed to allocate register map: %d\n",
ret); ret);
kfree(max77686);
return ret; return ret;
} }
...@@ -116,8 +115,7 @@ static int max77686_i2c_probe(struct i2c_client *i2c, ...@@ -116,8 +115,7 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
MAX77686_REG_DEVICE_ID, &data) < 0) { MAX77686_REG_DEVICE_ID, &data) < 0) {
dev_err(max77686->dev, dev_err(max77686->dev,
"device not found on this channel (this is not an error)\n"); "device not found on this channel (this is not an error)\n");
ret = -ENODEV; return -ENODEV;
goto err;
} else } else
dev_info(max77686->dev, "device found\n"); dev_info(max77686->dev, "device found\n");
...@@ -128,17 +126,11 @@ static int max77686_i2c_probe(struct i2c_client *i2c, ...@@ -128,17 +126,11 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
ret = mfd_add_devices(max77686->dev, -1, max77686_devs, ret = mfd_add_devices(max77686->dev, -1, max77686_devs,
ARRAY_SIZE(max77686_devs), NULL, 0, NULL); ARRAY_SIZE(max77686_devs), NULL, 0, NULL);
if (ret < 0) {
mfd_remove_devices(max77686->dev);
i2c_unregister_device(max77686->rtc);
}
if (ret < 0)
goto err_mfd;
return ret;
err_mfd:
mfd_remove_devices(max77686->dev);
i2c_unregister_device(max77686->rtc);
err:
kfree(max77686);
return ret; return ret;
} }
...@@ -148,7 +140,6 @@ static int max77686_i2c_remove(struct i2c_client *i2c) ...@@ -148,7 +140,6 @@ static int max77686_i2c_remove(struct i2c_client *i2c)
mfd_remove_devices(max77686->dev); mfd_remove_devices(max77686->dev);
i2c_unregister_device(max77686->rtc); i2c_unregister_device(max77686->rtc);
kfree(max77686);
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