diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2012-05-11 06:36:57 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-05-20 11:26:59 -0400 |
commit | 63fe7dee9183118716078a9f2503f5f805d37c12 (patch) | |
tree | 1ca0906a81f331d4c8f7ee0c22320e2fc61e75d4 /drivers/mfd | |
parent | 3bf6bf9be51a0195c6b1604454fdd28ed1cc1770 (diff) |
mfd: Convert all tps65910 allocation to devm_*
Convert memory allocation and regmap initialization to
use devm_* functions.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd')
-rw-r--r-- | drivers/mfd/tps65910.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c index 01570a789cf1..22fa43070659 100644 --- a/drivers/mfd/tps65910.c +++ b/drivers/mfd/tps65910.c | |||
@@ -218,15 +218,13 @@ static __devinit int tps65910_i2c_probe(struct i2c_client *i2c, | |||
218 | if (!pmic_plat_data) | 218 | if (!pmic_plat_data) |
219 | return -EINVAL; | 219 | return -EINVAL; |
220 | 220 | ||
221 | init_data = kzalloc(sizeof(struct tps65910_platform_data), GFP_KERNEL); | 221 | init_data = devm_kzalloc(&i2c->dev, sizeof(*init_data), GFP_KERNEL); |
222 | if (init_data == NULL) | 222 | if (init_data == NULL) |
223 | return -ENOMEM; | 223 | return -ENOMEM; |
224 | 224 | ||
225 | tps65910 = kzalloc(sizeof(struct tps65910), GFP_KERNEL); | 225 | tps65910 = devm_kzalloc(&i2c->dev, sizeof(*tps65910), GFP_KERNEL); |
226 | if (tps65910 == NULL) { | 226 | if (tps65910 == NULL) |
227 | kfree(init_data); | ||
228 | return -ENOMEM; | 227 | return -ENOMEM; |
229 | } | ||
230 | 228 | ||
231 | i2c_set_clientdata(i2c, tps65910); | 229 | i2c_set_clientdata(i2c, tps65910); |
232 | tps65910->dev = &i2c->dev; | 230 | tps65910->dev = &i2c->dev; |
@@ -234,18 +232,20 @@ static __devinit int tps65910_i2c_probe(struct i2c_client *i2c, | |||
234 | tps65910->id = chip_id; | 232 | tps65910->id = chip_id; |
235 | mutex_init(&tps65910->io_mutex); | 233 | mutex_init(&tps65910->io_mutex); |
236 | 234 | ||
237 | tps65910->regmap = regmap_init_i2c(i2c, &tps65910_regmap_config); | 235 | tps65910->regmap = devm_regmap_init_i2c(i2c, &tps65910_regmap_config); |
238 | if (IS_ERR(tps65910->regmap)) { | 236 | if (IS_ERR(tps65910->regmap)) { |
239 | ret = PTR_ERR(tps65910->regmap); | 237 | ret = PTR_ERR(tps65910->regmap); |
240 | dev_err(&i2c->dev, "regmap initialization failed: %d\n", ret); | 238 | dev_err(&i2c->dev, "regmap initialization failed: %d\n", ret); |
241 | goto regmap_err; | 239 | return ret; |
242 | } | 240 | } |
243 | 241 | ||
244 | ret = mfd_add_devices(tps65910->dev, -1, | 242 | ret = mfd_add_devices(tps65910->dev, -1, |
245 | tps65910s, ARRAY_SIZE(tps65910s), | 243 | tps65910s, ARRAY_SIZE(tps65910s), |
246 | NULL, 0); | 244 | NULL, 0); |
247 | if (ret < 0) | 245 | if (ret < 0) { |
248 | goto err; | 246 | dev_err(&i2c->dev, "mfd_add_devices failed: %d\n", ret); |
247 | return ret; | ||
248 | } | ||
249 | 249 | ||
250 | init_data->irq = pmic_plat_data->irq; | 250 | init_data->irq = pmic_plat_data->irq; |
251 | init_data->irq_base = pmic_plat_data->irq_base; | 251 | init_data->irq_base = pmic_plat_data->irq_base; |
@@ -256,14 +256,6 @@ static __devinit int tps65910_i2c_probe(struct i2c_client *i2c, | |||
256 | 256 | ||
257 | tps65910_sleepinit(tps65910, pmic_plat_data); | 257 | tps65910_sleepinit(tps65910, pmic_plat_data); |
258 | 258 | ||
259 | kfree(init_data); | ||
260 | return ret; | ||
261 | |||
262 | err: | ||
263 | regmap_exit(tps65910->regmap); | ||
264 | regmap_err: | ||
265 | kfree(tps65910); | ||
266 | kfree(init_data); | ||
267 | return ret; | 259 | return ret; |
268 | } | 260 | } |
269 | 261 | ||
@@ -273,8 +265,6 @@ static __devexit int tps65910_i2c_remove(struct i2c_client *i2c) | |||
273 | 265 | ||
274 | tps65910_irq_exit(tps65910); | 266 | tps65910_irq_exit(tps65910); |
275 | mfd_remove_devices(tps65910->dev); | 267 | mfd_remove_devices(tps65910->dev); |
276 | regmap_exit(tps65910->regmap); | ||
277 | kfree(tps65910); | ||
278 | 268 | ||
279 | return 0; | 269 | return 0; |
280 | } | 270 | } |