aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2013-09-26 09:33:51 -0400
committerLee Jones <lee.jones@linaro.org>2013-10-23 11:21:39 -0400
commit5e172d751869ca6756a7276168e11d641dc6b58a (patch)
treed7a2438b1d237896f533ce02856a4975cf0d3553 /drivers/mfd
parent7178347e1c675aefefce09357c988db0a9bf6e96 (diff)
mfd: palmas: Fix resource leak of i2c_dummy devices
Palmas device supports multiple i2c device address and the client for these addressed are created in the driver as i2c_new_dummy(). The new devices are not getting released in error or removal path and so it is causing resource leak. Add the unregister of these newly created dummy devices to avoid resource leaks. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/palmas.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index 6aab016f4c37..ae9147873b4a 100644
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
@@ -422,7 +422,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
422 dev_err(palmas->dev, 422 dev_err(palmas->dev,
423 "can't attach client %d\n", i); 423 "can't attach client %d\n", i);
424 ret = -ENOMEM; 424 ret = -ENOMEM;
425 goto err; 425 goto err_i2c;
426 } 426 }
427 palmas->i2c_clients[i]->dev.of_node = of_node_get(node); 427 palmas->i2c_clients[i]->dev.of_node = of_node_get(node);
428 } 428 }
@@ -433,7 +433,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
433 dev_err(palmas->dev, 433 dev_err(palmas->dev,
434 "Failed to allocate regmap %d, err: %d\n", 434 "Failed to allocate regmap %d, err: %d\n",
435 i, ret); 435 i, ret);
436 goto err; 436 goto err_i2c;
437 } 437 }
438 } 438 }
439 439
@@ -452,7 +452,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
452 reg); 452 reg);
453 if (ret < 0) { 453 if (ret < 0) {
454 dev_err(palmas->dev, "POLARITY_CTRL updat failed: %d\n", ret); 454 dev_err(palmas->dev, "POLARITY_CTRL updat failed: %d\n", ret);
455 goto err; 455 goto err_i2c;
456 } 456 }
457 457
458 /* Change IRQ into clear on read mode for efficiency */ 458 /* Change IRQ into clear on read mode for efficiency */
@@ -466,7 +466,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
466 IRQF_ONESHOT | pdata->irq_flags, 0, &palmas_irq_chip, 466 IRQF_ONESHOT | pdata->irq_flags, 0, &palmas_irq_chip,
467 &palmas->irq_data); 467 &palmas->irq_data);
468 if (ret < 0) 468 if (ret < 0)
469 goto err; 469 goto err_i2c;
470 470
471no_irq: 471no_irq:
472 slave = PALMAS_BASE_TO_SLAVE(PALMAS_PU_PD_OD_BASE); 472 slave = PALMAS_BASE_TO_SLAVE(PALMAS_PU_PD_OD_BASE);
@@ -552,7 +552,6 @@ no_irq:
552 } else if (pdata->pm_off && !pm_power_off) { 552 } else if (pdata->pm_off && !pm_power_off) {
553 palmas_dev = palmas; 553 palmas_dev = palmas;
554 pm_power_off = palmas_power_off; 554 pm_power_off = palmas_power_off;
555 return ret;
556 } 555 }
557 } 556 }
558 557
@@ -560,16 +559,26 @@ no_irq:
560 559
561err_irq: 560err_irq:
562 regmap_del_irq_chip(palmas->irq, palmas->irq_data); 561 regmap_del_irq_chip(palmas->irq, palmas->irq_data);
563err: 562err_i2c:
563 for (i = 1; i < PALMAS_NUM_CLIENTS; i++) {
564 if (palmas->i2c_clients[i])
565 i2c_unregister_device(palmas->i2c_clients[i]);
566 }
564 return ret; 567 return ret;
565} 568}
566 569
567static int palmas_i2c_remove(struct i2c_client *i2c) 570static int palmas_i2c_remove(struct i2c_client *i2c)
568{ 571{
569 struct palmas *palmas = i2c_get_clientdata(i2c); 572 struct palmas *palmas = i2c_get_clientdata(i2c);
573 int i;
570 574
571 regmap_del_irq_chip(palmas->irq, palmas->irq_data); 575 regmap_del_irq_chip(palmas->irq, palmas->irq_data);
572 576
577 for (i = 1; i < PALMAS_NUM_CLIENTS; i++) {
578 if (palmas->i2c_clients[i])
579 i2c_unregister_device(palmas->i2c_clients[i]);
580 }
581
573 if (palmas == palmas_dev) { 582 if (palmas == palmas_dev) {
574 pm_power_off = NULL; 583 pm_power_off = NULL;
575 palmas_dev = NULL; 584 palmas_dev = NULL;