Re: [PATCH v2 3/4] regulator-core: free requested GPIOs and manage the enable list

2013-01-26 Thread Mark Brown
On Tue, Jan 15, 2013 at 04:35:50AM +, Kim, Milo wrote:
>  The regulator_ena_gpio_request() allocates the enable GPIO and add the list.
>  Related resources should be released if they are not used any more.
>  To free requested GPIO and remove it from the enable GPIO list,
>  new function, 'regulator_ena_gpio_free()' is added.

Ah, sorry - I hadn't realised this patch had the cleanup code.  This
needs a bit of an update - as I said for one of the earlier patches we
need to reference count to make sure we only free the GPIO when it has
no users.  With this patch we will free the GPIO when the first
regulator to use it is freed which might mean other regulators are still
using it.


signature.asc
Description: Digital signature


Re: [PATCH v2 3/4] regulator-core: free requested GPIOs and manage the enable list

2013-01-26 Thread Mark Brown
On Tue, Jan 15, 2013 at 04:35:50AM +, Kim, Milo wrote:
  The regulator_ena_gpio_request() allocates the enable GPIO and add the list.
  Related resources should be released if they are not used any more.
  To free requested GPIO and remove it from the enable GPIO list,
  new function, 'regulator_ena_gpio_free()' is added.

Ah, sorry - I hadn't realised this patch had the cleanup code.  This
needs a bit of an update - as I said for one of the earlier patches we
need to reference count to make sure we only free the GPIO when it has
no users.  With this patch we will free the GPIO when the first
regulator to use it is freed which might mean other regulators are still
using it.


signature.asc
Description: Digital signature


[PATCH v2 3/4] regulator-core: free requested GPIOs and manage the enable list

2013-01-14 Thread Kim, Milo
 The regulator_ena_gpio_request() allocates the enable GPIO and add the list.
 Related resources should be released if they are not used any more.
 To free requested GPIO and remove it from the enable GPIO list,
 new function, 'regulator_ena_gpio_free()' is added.

Signed-off-by: Milo(Woogyom) Kim 
---
 drivers/regulator/core.c |   19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index dc713c4..8631234 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1501,6 +1501,19 @@ static int regulator_ena_gpio_request(struct 
regulator_dev *rdev,
return 0;
 }
 
+static void regulator_ena_gpio_free(struct regulator_dev *rdev)
+{
+   struct regulator_enable_gpio *pin, *n;
+
+   list_for_each_entry_safe(pin, n, _ena_gpio_list, list) {
+   if (pin->regulator == rdev && pin->gpio) {
+   gpio_free(pin->gpio);
+   list_del(>list);
+   kfree(pin);
+   }
+   }
+}
+
 /**
  * Balance enable_count of each GPIO and actual GPIO pin control.
  * GPIO is enabled in case of initial use. (enable_count is 0)
@@ -3590,8 +3603,7 @@ unset_supplies:
 scrub:
if (rdev->supply)
_regulator_put(rdev->supply);
-   if (rdev->ena_gpio)
-   gpio_free(rdev->ena_gpio);
+   regulator_ena_gpio_free(rdev);
kfree(rdev->constraints);
 wash:
device_unregister(>dev);
@@ -3626,8 +3638,7 @@ void regulator_unregister(struct regulator_dev *rdev)
unset_regulator_supplies(rdev);
list_del(>list);
kfree(rdev->constraints);
-   if (rdev->ena_gpio)
-   gpio_free(rdev->ena_gpio);
+   regulator_ena_gpio_free(rdev);
device_unregister(>dev);
mutex_unlock(_list_mutex);
 }
-- 
1.7.9.5


Best Regards,
Milo


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 3/4] regulator-core: free requested GPIOs and manage the enable list

2013-01-14 Thread Kim, Milo
 The regulator_ena_gpio_request() allocates the enable GPIO and add the list.
 Related resources should be released if they are not used any more.
 To free requested GPIO and remove it from the enable GPIO list,
 new function, 'regulator_ena_gpio_free()' is added.

Signed-off-by: Milo(Woogyom) Kim milo@ti.com
---
 drivers/regulator/core.c |   19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index dc713c4..8631234 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1501,6 +1501,19 @@ static int regulator_ena_gpio_request(struct 
regulator_dev *rdev,
return 0;
 }
 
+static void regulator_ena_gpio_free(struct regulator_dev *rdev)
+{
+   struct regulator_enable_gpio *pin, *n;
+
+   list_for_each_entry_safe(pin, n, regulator_ena_gpio_list, list) {
+   if (pin-regulator == rdev  pin-gpio) {
+   gpio_free(pin-gpio);
+   list_del(pin-list);
+   kfree(pin);
+   }
+   }
+}
+
 /**
  * Balance enable_count of each GPIO and actual GPIO pin control.
  * GPIO is enabled in case of initial use. (enable_count is 0)
@@ -3590,8 +3603,7 @@ unset_supplies:
 scrub:
if (rdev-supply)
_regulator_put(rdev-supply);
-   if (rdev-ena_gpio)
-   gpio_free(rdev-ena_gpio);
+   regulator_ena_gpio_free(rdev);
kfree(rdev-constraints);
 wash:
device_unregister(rdev-dev);
@@ -3626,8 +3638,7 @@ void regulator_unregister(struct regulator_dev *rdev)
unset_regulator_supplies(rdev);
list_del(rdev-list);
kfree(rdev-constraints);
-   if (rdev-ena_gpio)
-   gpio_free(rdev-ena_gpio);
+   regulator_ena_gpio_free(rdev);
device_unregister(rdev-dev);
mutex_unlock(regulator_list_mutex);
 }
-- 
1.7.9.5


Best Regards,
Milo


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/