diff options
author | Graeme Gregory <gg@slimlogic.co.uk> | 2012-08-28 07:47:35 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-09-21 17:40:36 -0400 |
commit | 3f78decc321d48724809406b498708d2ab4b93d2 (patch) | |
tree | e2b0b9a564e6f9f33b0aed4ff92eb5c97ad739a9 | |
parent | 81a21cddaf14bd1144c2d173add7cbdeb95a07ca (diff) |
mfd: palmas: Improve the error exit path
Improve the error exit path so that we correctly de-allocate resources
that have been allocated upto the point where error occurs.
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r-- | drivers/mfd/palmas.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c index e7a7415b8c2b..5831dfdb3f4c 100644 --- a/drivers/mfd/palmas.c +++ b/drivers/mfd/palmas.c | |||
@@ -377,11 +377,11 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c, | |||
377 | reg = pdata->pad1; | 377 | reg = pdata->pad1; |
378 | ret = regmap_write(palmas->regmap[slave], addr, reg); | 378 | ret = regmap_write(palmas->regmap[slave], addr, reg); |
379 | if (ret) | 379 | if (ret) |
380 | goto err; | 380 | goto err_irq; |
381 | } else { | 381 | } else { |
382 | ret = regmap_read(palmas->regmap[slave], addr, ®); | 382 | ret = regmap_read(palmas->regmap[slave], addr, ®); |
383 | if (ret) | 383 | if (ret) |
384 | goto err; | 384 | goto err_irq; |
385 | } | 385 | } |
386 | 386 | ||
387 | if (!(reg & PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_0)) | 387 | if (!(reg & PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_0)) |
@@ -412,11 +412,11 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c, | |||
412 | reg = pdata->pad2; | 412 | reg = pdata->pad2; |
413 | ret = regmap_write(palmas->regmap[slave], addr, reg); | 413 | ret = regmap_write(palmas->regmap[slave], addr, reg); |
414 | if (ret) | 414 | if (ret) |
415 | goto err; | 415 | goto err_irq; |
416 | } else { | 416 | } else { |
417 | ret = regmap_read(palmas->regmap[slave], addr, ®); | 417 | ret = regmap_read(palmas->regmap[slave], addr, ®); |
418 | if (ret) | 418 | if (ret) |
419 | goto err; | 419 | goto err_irq; |
420 | } | 420 | } |
421 | 421 | ||
422 | if (!(reg & PALMAS_PRIMARY_SECONDARY_PAD2_GPIO_4)) | 422 | if (!(reg & PALMAS_PRIMARY_SECONDARY_PAD2_GPIO_4)) |
@@ -439,13 +439,13 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c, | |||
439 | 439 | ||
440 | ret = regmap_write(palmas->regmap[slave], addr, reg); | 440 | ret = regmap_write(palmas->regmap[slave], addr, reg); |
441 | if (ret) | 441 | if (ret) |
442 | goto err; | 442 | goto err_irq; |
443 | 443 | ||
444 | children = kmemdup(palmas_children, sizeof(palmas_children), | 444 | children = kmemdup(palmas_children, sizeof(palmas_children), |
445 | GFP_KERNEL); | 445 | GFP_KERNEL); |
446 | if (!children) { | 446 | if (!children) { |
447 | ret = -ENOMEM; | 447 | ret = -ENOMEM; |
448 | goto err; | 448 | goto err_irq; |
449 | } | 449 | } |
450 | 450 | ||
451 | children[PALMAS_PMIC_ID].platform_data = pdata->pmic_pdata; | 451 | children[PALMAS_PMIC_ID].platform_data = pdata->pmic_pdata; |
@@ -458,12 +458,15 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c, | |||
458 | kfree(children); | 458 | kfree(children); |
459 | 459 | ||
460 | if (ret < 0) | 460 | if (ret < 0) |
461 | goto err; | 461 | goto err_devices; |
462 | 462 | ||
463 | return ret; | 463 | return ret; |
464 | 464 | ||
465 | err: | 465 | err_devices: |
466 | mfd_remove_devices(palmas->dev); | 466 | mfd_remove_devices(palmas->dev); |
467 | err_irq: | ||
468 | regmap_del_irq_chip(palmas->irq, palmas->irq_data); | ||
469 | err: | ||
467 | return ret; | 470 | return ret; |
468 | } | 471 | } |
469 | 472 | ||