All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] mfd: palmas: fix the resource leak issue and cleanups.
@ 2013-09-26 13:33 Laxman Dewangan
  2013-09-26 13:33 ` [PATCH 1/4] mfd: palmas: remove call of mfd_remove_devices Laxman Dewangan
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Laxman Dewangan @ 2013-09-26 13:33 UTC (permalink / raw)
  To: sameo, lee.jones; +Cc: linux-kernel, swarren, Laxman Dewangan

This series does the:
- removing non-require api calls.
- Fix the resource leaks.
- reset the initialisation done in probing.

Laxman Dewangan (4):
  mfd: palmas: remove call of mfd_remove_devices
  mfd: palmas: add MODULE_DEVICE_TABLE for of_device table
  mfd: palmas: reset pm_power_off if it is set for the device
  mfd: palmas: fix resource leak of i2c_dummy devices

 drivers/mfd/palmas.c |   28 +++++++++++++++++++++-------
 1 files changed, 21 insertions(+), 7 deletions(-)


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] mfd: palmas: remove call of mfd_remove_devices
  2013-09-26 13:33 [PATCH 0/4] mfd: palmas: fix the resource leak issue and cleanups Laxman Dewangan
@ 2013-09-26 13:33 ` Laxman Dewangan
  2013-09-27  8:07   ` Lee Jones
  2013-09-26 13:33 ` [PATCH 2/4] mfd: palmas: add MODULE_DEVICE_TABLE for of_device table Laxman Dewangan
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Laxman Dewangan @ 2013-09-26 13:33 UTC (permalink / raw)
  To: sameo, lee.jones; +Cc: linux-kernel, swarren, Laxman Dewangan

The driver only support the device tree and sub modules are populated
through platform, the registration of sub devices through mfd_add_devices
has been removed.

Hence in remove path of the driver, it is not require to call
mfd_remove_devices.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
 drivers/mfd/palmas.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index 135afab..9607d24 100644
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
@@ -567,7 +567,6 @@ static int palmas_i2c_remove(struct i2c_client *i2c)
 {
 	struct palmas *palmas = i2c_get_clientdata(i2c);
 
-	mfd_remove_devices(palmas->dev);
 	regmap_del_irq_chip(palmas->irq, palmas->irq_data);
 
 	return 0;
-- 
1.7.1.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] mfd: palmas: add MODULE_DEVICE_TABLE for of_device table
  2013-09-26 13:33 [PATCH 0/4] mfd: palmas: fix the resource leak issue and cleanups Laxman Dewangan
  2013-09-26 13:33 ` [PATCH 1/4] mfd: palmas: remove call of mfd_remove_devices Laxman Dewangan
@ 2013-09-26 13:33 ` Laxman Dewangan
  2013-09-27  8:04   ` Lee Jones
  2013-09-26 13:33 ` [PATCH 3/4] mfd: palmas: reset pm_power_off if it is set for the device Laxman Dewangan
  2013-09-26 13:33 ` [PATCH 4/4] mfd: palmas: fix resource leak of i2c_dummy devices Laxman Dewangan
  3 siblings, 1 reply; 9+ messages in thread
From: Laxman Dewangan @ 2013-09-26 13:33 UTC (permalink / raw)
  To: sameo, lee.jones; +Cc: linux-kernel, swarren, Laxman Dewangan

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
 drivers/mfd/palmas.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index 9607d24..3b63139 100644
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
@@ -368,6 +368,7 @@ static const struct of_device_id of_palmas_match_tbl[] = {
 	},
 	{ },
 };
+MODULE_DEVICE_TABLE(of, of_palmas_match_tbl);
 
 static int palmas_i2c_probe(struct i2c_client *i2c,
 			    const struct i2c_device_id *id)
-- 
1.7.1.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] mfd: palmas: reset pm_power_off if it is set for the device
  2013-09-26 13:33 [PATCH 0/4] mfd: palmas: fix the resource leak issue and cleanups Laxman Dewangan
  2013-09-26 13:33 ` [PATCH 1/4] mfd: palmas: remove call of mfd_remove_devices Laxman Dewangan
  2013-09-26 13:33 ` [PATCH 2/4] mfd: palmas: add MODULE_DEVICE_TABLE for of_device table Laxman Dewangan
@ 2013-09-26 13:33 ` Laxman Dewangan
  2013-09-27  8:01   ` Lee Jones
  2013-09-26 13:33 ` [PATCH 4/4] mfd: palmas: fix resource leak of i2c_dummy devices Laxman Dewangan
  3 siblings, 1 reply; 9+ messages in thread
From: Laxman Dewangan @ 2013-09-26 13:33 UTC (permalink / raw)
  To: sameo, lee.jones; +Cc: linux-kernel, swarren, Laxman Dewangan

If Palams supports the system power controller and pm_power_off
is implemented through the Palmas driver then reset the pm_power_off
in driver remove.

This will avoid the call of Palmas driver after removal of driver.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
 drivers/mfd/palmas.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index 3b63139..6aab016 100644
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
@@ -570,6 +570,11 @@ static int palmas_i2c_remove(struct i2c_client *i2c)
 
 	regmap_del_irq_chip(palmas->irq, palmas->irq_data);
 
+	if (palmas == palmas_dev) {
+		pm_power_off = NULL;
+		palmas_dev = NULL;
+	}
+
 	return 0;
 }
 
-- 
1.7.1.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] mfd: palmas: fix resource leak of i2c_dummy devices
  2013-09-26 13:33 [PATCH 0/4] mfd: palmas: fix the resource leak issue and cleanups Laxman Dewangan
                   ` (2 preceding siblings ...)
  2013-09-26 13:33 ` [PATCH 3/4] mfd: palmas: reset pm_power_off if it is set for the device Laxman Dewangan
@ 2013-09-26 13:33 ` Laxman Dewangan
  2013-09-27  7:49   ` Lee Jones
  3 siblings, 1 reply; 9+ messages in thread
From: Laxman Dewangan @ 2013-09-26 13:33 UTC (permalink / raw)
  To: sameo, lee.jones; +Cc: linux-kernel, swarren, Laxman Dewangan

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>
---
 drivers/mfd/palmas.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index 6aab016..ae91478 100644
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
@@ -422,7 +422,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
 				dev_err(palmas->dev,
 					"can't attach client %d\n", i);
 				ret = -ENOMEM;
-				goto err;
+				goto err_i2c;
 			}
 			palmas->i2c_clients[i]->dev.of_node = of_node_get(node);
 		}
@@ -433,7 +433,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
 			dev_err(palmas->dev,
 				"Failed to allocate regmap %d, err: %d\n",
 				i, ret);
-			goto err;
+			goto err_i2c;
 		}
 	}
 
@@ -452,7 +452,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
 			reg);
 	if (ret < 0) {
 		dev_err(palmas->dev, "POLARITY_CTRL updat failed: %d\n", ret);
-		goto err;
+		goto err_i2c;
 	}
 
 	/* Change IRQ into clear on read mode for efficiency */
@@ -466,7 +466,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
 			IRQF_ONESHOT | pdata->irq_flags, 0, &palmas_irq_chip,
 			&palmas->irq_data);
 	if (ret < 0)
-		goto err;
+		goto err_i2c;
 
 no_irq:
 	slave = PALMAS_BASE_TO_SLAVE(PALMAS_PU_PD_OD_BASE);
@@ -552,7 +552,6 @@ no_irq:
 		} else if (pdata->pm_off && !pm_power_off) {
 			palmas_dev = palmas;
 			pm_power_off = palmas_power_off;
-			return ret;
 		}
 	}
 
@@ -560,16 +559,26 @@ no_irq:
 
 err_irq:
 	regmap_del_irq_chip(palmas->irq, palmas->irq_data);
-err:
+err_i2c:
+	for (i = 1; i < PALMAS_NUM_CLIENTS; i++) {
+		if (palmas->i2c_clients[i])
+			i2c_unregister_device(palmas->i2c_clients[i]);
+	}
 	return ret;
 }
 
 static int palmas_i2c_remove(struct i2c_client *i2c)
 {
 	struct palmas *palmas = i2c_get_clientdata(i2c);
+	int i;
 
 	regmap_del_irq_chip(palmas->irq, palmas->irq_data);
 
+	for (i = 1; i < PALMAS_NUM_CLIENTS; i++) {
+		if (palmas->i2c_clients[i])
+			i2c_unregister_device(palmas->i2c_clients[i]);
+	}
+
 	if (palmas == palmas_dev) {
 		pm_power_off = NULL;
 		palmas_dev = NULL;
-- 
1.7.1.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 4/4] mfd: palmas: fix resource leak of i2c_dummy devices
  2013-09-26 13:33 ` [PATCH 4/4] mfd: palmas: fix resource leak of i2c_dummy devices Laxman Dewangan
@ 2013-09-27  7:49   ` Lee Jones
  0 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2013-09-27  7:49 UTC (permalink / raw)
  To: Laxman Dewangan; +Cc: sameo, linux-kernel, swarren

On Thu, 26 Sep 2013, Laxman Dewangan wrote:

> 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>
> ---
>  drivers/mfd/palmas.c |   21 +++++++++++++++------
>  1 files changed, 15 insertions(+), 6 deletions(-)

Patch looks sane.

>  no_irq:
>  	slave = PALMAS_BASE_TO_SLAVE(PALMAS_PU_PD_OD_BASE);
> @@ -552,7 +552,6 @@ no_irq:
>  		} else if (pdata->pm_off && !pm_power_off) {
>  			palmas_dev = palmas;
>  			pm_power_off = palmas_power_off;
> -			return ret;
>  		}
>  	}

Sneaky! ;)

Applied, thanks.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/4] mfd: palmas: reset pm_power_off if it is set for the device
  2013-09-26 13:33 ` [PATCH 3/4] mfd: palmas: reset pm_power_off if it is set for the device Laxman Dewangan
@ 2013-09-27  8:01   ` Lee Jones
  0 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2013-09-27  8:01 UTC (permalink / raw)
  To: Laxman Dewangan; +Cc: sameo, linux-kernel, swarren

On Thu, 26 Sep 2013, Laxman Dewangan wrote:

> If Palams supports the system power controller and pm_power_off
> is implemented through the Palmas driver then reset the pm_power_off
> in driver remove.
> 
> This will avoid the call of Palmas driver after removal of driver.
> 
> Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
> ---
>  drivers/mfd/palmas.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)

Looks good. Applied, thanks.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/4] mfd: palmas: add MODULE_DEVICE_TABLE for of_device table
  2013-09-26 13:33 ` [PATCH 2/4] mfd: palmas: add MODULE_DEVICE_TABLE for of_device table Laxman Dewangan
@ 2013-09-27  8:04   ` Lee Jones
  0 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2013-09-27  8:04 UTC (permalink / raw)
  To: Laxman Dewangan; +Cc: sameo, linux-kernel, swarren

On Thu, 26 Sep 2013, Laxman Dewangan wrote:

> Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
> ---
>  drivers/mfd/palmas.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c

Applied, thanks.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/4] mfd: palmas: remove call of mfd_remove_devices
  2013-09-26 13:33 ` [PATCH 1/4] mfd: palmas: remove call of mfd_remove_devices Laxman Dewangan
@ 2013-09-27  8:07   ` Lee Jones
  0 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2013-09-27  8:07 UTC (permalink / raw)
  To: Laxman Dewangan; +Cc: sameo, linux-kernel, swarren

On Thu, 26 Sep 2013, Laxman Dewangan wrote:

> The driver only support the device tree and sub modules are populated
> through platform, the registration of sub devices through mfd_add_devices
> has been removed.
> 
> Hence in remove path of the driver, it is not require to call
> mfd_remove_devices.
> 
> Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
> ---
>  drivers/mfd/palmas.c |    1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)

Applied, thanks.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-09-27  8:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-26 13:33 [PATCH 0/4] mfd: palmas: fix the resource leak issue and cleanups Laxman Dewangan
2013-09-26 13:33 ` [PATCH 1/4] mfd: palmas: remove call of mfd_remove_devices Laxman Dewangan
2013-09-27  8:07   ` Lee Jones
2013-09-26 13:33 ` [PATCH 2/4] mfd: palmas: add MODULE_DEVICE_TABLE for of_device table Laxman Dewangan
2013-09-27  8:04   ` Lee Jones
2013-09-26 13:33 ` [PATCH 3/4] mfd: palmas: reset pm_power_off if it is set for the device Laxman Dewangan
2013-09-27  8:01   ` Lee Jones
2013-09-26 13:33 ` [PATCH 4/4] mfd: palmas: fix resource leak of i2c_dummy devices Laxman Dewangan
2013-09-27  7:49   ` Lee Jones

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.