linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] Introduce a managed function for gpio_request_array
@ 2014-07-06 17:46 Himangi Saraogi
  2014-07-06 17:47 ` [PATCH 1/5] gpiolib: devres: Introduce the function devm_request_gpio_array Himangi Saraogi
                   ` (5 more replies)
  0 siblings, 6 replies; 17+ messages in thread
From: Himangi Saraogi @ 2014-07-06 17:46 UTC (permalink / raw)
  To: linux-arm-kernel

This patchset intoduces a new managed interface devm_gpio_request_array,
adds it in the documentation and its declaration in the gpio.h include
file. Some cases of gpio_request_array are changed to
devm_gpio_request_array.

Himangi Saraogi (5):
  gpiolib: devres: Introduce the function devm_request_gpio_array
  ASoC: wm1250-ev1: Use devm_gpio_request_array
  ASoC: pxa: Use devm_gpio_request_array
  ASoC: pxa: e800_wm9712: Introduce the use of devm_gpio_request_array
  ASoC: pxa/hx4700: Introduce the use of devm_gpio_request_array

 Documentation/driver-model/devres.txt |  1 +
 drivers/gpio/devres.c                 | 21 +++++++++++++++++++++
 include/linux/gpio.h                  |  2 ++
 sound/soc/codecs/wm1250-ev1.c         | 24 +++++-------------------
 sound/soc/pxa/e740_wm9705.c           |  9 +++------
 sound/soc/pxa/e800_wm9712.c           |  9 +++------
 sound/soc/pxa/hx4700.c                | 12 +++---------
 7 files changed, 38 insertions(+), 40 deletions(-)

-- 
1.9.1

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

* [PATCH 1/5] gpiolib: devres: Introduce the function devm_request_gpio_array
  2014-07-06 17:46 [PATCH 0/5] Introduce a managed function for gpio_request_array Himangi Saraogi
@ 2014-07-06 17:47 ` Himangi Saraogi
  2014-07-09 11:18   ` Rob Jones
  2014-07-06 17:48 ` [PATCH 2/5] ASoC: wm1250-ev1: Use devm_gpio_request_array Himangi Saraogi
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Himangi Saraogi @ 2014-07-06 17:47 UTC (permalink / raw)
  To: linux-arm-kernel

This patch introduces the function devm_request_gpio_array that
allocates multiple GPIOs in a single call in a managed manner. The
function is also included in the documentation and a declaration is
added in include/linux/gpio.h.

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
---
 Documentation/driver-model/devres.txt |  1 +
 drivers/gpio/devres.c                 | 21 +++++++++++++++++++++
 include/linux/gpio.h                  |  2 ++
 3 files changed, 24 insertions(+)

diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index 9e2098e..756f6cf 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -337,6 +337,7 @@ GPIO
   devm_gpiod_put()
   devm_gpio_request()
   devm_gpio_request_one()
+  devm_gpio_request_array()
   devm_gpio_free()
 
 SND
diff --git a/drivers/gpio/devres.c b/drivers/gpio/devres.c
index 65978cf..adae7fa 100644
--- a/drivers/gpio/devres.c
+++ b/drivers/gpio/devres.c
@@ -229,6 +229,27 @@ int devm_gpio_request_one(struct device *dev, unsigned gpio,
 EXPORT_SYMBOL(devm_gpio_request_one);
 
 /**
+ *	devm_gpio_request_array - request multiple GPIOs in a single call
+ *	@dev:   device to request for
+ *	@array:	array of the 'struct gpio'
+ *	@num:	how many GPIOs in the array
+ */
+int devm_gpio_request_array(struct device *dev, const struct gpio *array,
+			    size_t num)
+{
+	int i, err;
+
+	for (i = 0; i < num; i++, array++) {
+		err = devm_gpio_request_one(dev, array->gpio, array->flags,
+					    array->label);
+		if (err)
+			return err;
+	}
+	return 0;
+}
+EXPORT_SYMBOL_GPL(devm_gpio_request_array);
+
+/**
  *      devm_gpio_free - free a GPIO
  *      @dev: device to free GPIO for
  *      @gpio: GPIO to free
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 85aa5d0..c85f243 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -84,6 +84,8 @@ struct device;
 int devm_gpio_request(struct device *dev, unsigned gpio, const char *label);
 int devm_gpio_request_one(struct device *dev, unsigned gpio,
 			  unsigned long flags, const char *label);
+int devm_gpio_request_array(struct device *dev, const struct gpio *array,
+			    size_t num);
 void devm_gpio_free(struct device *dev, unsigned int gpio);
 
 #else /* ! CONFIG_GPIOLIB */
-- 
1.9.1

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

* [PATCH 2/5] ASoC: wm1250-ev1: Use devm_gpio_request_array
  2014-07-06 17:46 [PATCH 0/5] Introduce a managed function for gpio_request_array Himangi Saraogi
  2014-07-06 17:47 ` [PATCH 1/5] gpiolib: devres: Introduce the function devm_request_gpio_array Himangi Saraogi
@ 2014-07-06 17:48 ` Himangi Saraogi
  2014-07-06 17:49 ` [PATCH 3/5] ASoC: pxa: " Himangi Saraogi
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 17+ messages in thread
From: Himangi Saraogi @ 2014-07-06 17:48 UTC (permalink / raw)
  To: linux-arm-kernel

This patch replaces a call to the unmanaged function
gpio_request_array by a call to the managed function
devm_gpio_request_array and removes the calls to gpio_free_array
in wm1250_ev1_pdata, which is called by the probe function. The
function wm1250_ev1_free is no longer needed and is removed.

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
---
 sound/soc/codecs/wm1250-ev1.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/sound/soc/codecs/wm1250-ev1.c b/sound/soc/codecs/wm1250-ev1.c
index 8011f75..44534e6 100644
--- a/sound/soc/codecs/wm1250-ev1.c
+++ b/sound/soc/codecs/wm1250-ev1.c
@@ -176,7 +176,8 @@ static int wm1250_ev1_pdata(struct i2c_client *i2c)
 	wm1250->gpios[WM1250_EV1_GPIO_CLK_SEL0].flags = GPIOF_OUT_INIT_HIGH;
 	wm1250->gpios[WM1250_EV1_GPIO_CLK_SEL1].flags = GPIOF_OUT_INIT_HIGH;
 
-	ret = gpio_request_array(wm1250->gpios, ARRAY_SIZE(wm1250->gpios));
+	ret = devm_gpio_request_array(&i2c->dev, wm1250->gpios,
+				      ARRAY_SIZE(wm1250->gpios));
 	if (ret != 0) {
 		dev_err(&i2c->dev, "Failed to get GPIOs: %d\n", ret);
 		goto err;
@@ -190,14 +191,6 @@ err:
 	return ret;
 }
 
-static void wm1250_ev1_free(struct i2c_client *i2c)
-{
-	struct wm1250_priv *wm1250 = dev_get_drvdata(&i2c->dev);
-
-	if (wm1250)
-		gpio_free_array(wm1250->gpios, ARRAY_SIZE(wm1250->gpios));
-}
-
 static int wm1250_ev1_probe(struct i2c_client *i2c,
 			    const struct i2c_device_id *i2c_id)
 {
@@ -229,7 +222,6 @@ static int wm1250_ev1_probe(struct i2c_client *i2c,
 				     &wm1250_ev1_dai, 1);
 	if (ret != 0) {
 		dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);
-		wm1250_ev1_free(i2c);
 		return ret;
 	}
 
@@ -239,7 +231,6 @@ static int wm1250_ev1_probe(struct i2c_client *i2c,
 static int wm1250_ev1_remove(struct i2c_client *i2c)
 {
 	snd_soc_unregister_codec(&i2c->dev);
-	wm1250_ev1_free(i2c);
 
 	return 0;
 }
-- 
1.9.1

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

* [PATCH 3/5] ASoC: pxa: Use devm_gpio_request_array
  2014-07-06 17:46 [PATCH 0/5] Introduce a managed function for gpio_request_array Himangi Saraogi
  2014-07-06 17:47 ` [PATCH 1/5] gpiolib: devres: Introduce the function devm_request_gpio_array Himangi Saraogi
  2014-07-06 17:48 ` [PATCH 2/5] ASoC: wm1250-ev1: Use devm_gpio_request_array Himangi Saraogi
@ 2014-07-06 17:49 ` Himangi Saraogi
  2014-07-06 17:51 ` [PATCH 4/5] ASoC: pxa: e800_wm9712: Introduce the use of devm_gpio_request_array Himangi Saraogi
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 17+ messages in thread
From: Himangi Saraogi @ 2014-07-06 17:49 UTC (permalink / raw)
  To: linux-arm-kernel

This patch moves data allocated using gpio_request_array to the managed
interface and removes the calls to gpio_free_array in the probe and
remove functions.

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
 sound/soc/pxa/e740_wm9705.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/sound/soc/pxa/e740_wm9705.c b/sound/soc/pxa/e740_wm9705.c
index c29feda..d462dc9 100644
--- a/sound/soc/pxa/e740_wm9705.c
+++ b/sound/soc/pxa/e740_wm9705.c
@@ -149,19 +149,17 @@ static int e740_probe(struct platform_device *pdev)
 	struct snd_soc_card *card = &e740;
 	int ret;
 
-	ret = gpio_request_array(e740_audio_gpios,
-				 ARRAY_SIZE(e740_audio_gpios));
+	ret = devm_gpio_request_array(&pdev->dev, e740_audio_gpios,
+				      ARRAY_SIZE(e740_audio_gpios));
 	if (ret)
 		return ret;
 
 	card->dev = &pdev->dev;
 
 	ret = snd_soc_register_card(card);
-	if (ret) {
+	if (ret)
 		dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
 			ret);
-		gpio_free_array(e740_audio_gpios, ARRAY_SIZE(e740_audio_gpios));
-	}
 	return ret;
 }
 
@@ -169,7 +167,6 @@ static int e740_remove(struct platform_device *pdev)
 {
 	struct snd_soc_card *card = platform_get_drvdata(pdev);
 
-	gpio_free_array(e740_audio_gpios, ARRAY_SIZE(e740_audio_gpios));
 	snd_soc_unregister_card(card);
 	return 0;
 }
-- 
1.9.1

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

* [PATCH 4/5] ASoC: pxa: e800_wm9712: Introduce the use of devm_gpio_request_array
  2014-07-06 17:46 [PATCH 0/5] Introduce a managed function for gpio_request_array Himangi Saraogi
                   ` (2 preceding siblings ...)
  2014-07-06 17:49 ` [PATCH 3/5] ASoC: pxa: " Himangi Saraogi
@ 2014-07-06 17:51 ` Himangi Saraogi
  2014-07-06 17:52 ` [PATCH 5/5] ASoC: pxa/hx4700: " Himangi Saraogi
  2014-07-09 10:14 ` [PATCH 0/5] Introduce a managed function for gpio_request_array Linus Walleij
  5 siblings, 0 replies; 17+ messages in thread
From: Himangi Saraogi @ 2014-07-06 17:51 UTC (permalink / raw)
  To: linux-arm-kernel

This patch moves the resources allocated using gpio_request_array to the
managed interface and removes the calls to gpio_free_array in the probe
and remove functions.

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
 sound/soc/pxa/e800_wm9712.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/sound/soc/pxa/e800_wm9712.c b/sound/soc/pxa/e800_wm9712.c
index 24c2078..dbc3670 100644
--- a/sound/soc/pxa/e800_wm9712.c
+++ b/sound/soc/pxa/e800_wm9712.c
@@ -112,19 +112,17 @@ static int e800_probe(struct platform_device *pdev)
 	struct snd_soc_card *card = &e800;
 	int ret;
 
-	ret = gpio_request_array(e800_audio_gpios,
-				 ARRAY_SIZE(e800_audio_gpios));
+	ret = devm_gpio_request_array(&pdev->dev, e800_audio_gpios,
+				      ARRAY_SIZE(e800_audio_gpios));
 	if (ret)
 		return ret;
 
 	card->dev = &pdev->dev;
 
 	ret = snd_soc_register_card(card);
-	if (ret) {
+	if (ret)
 		dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
 			ret);
-		gpio_free_array(e800_audio_gpios, ARRAY_SIZE(e800_audio_gpios));
-	}
 	return ret;
 }
 
@@ -132,7 +130,6 @@ static int e800_remove(struct platform_device *pdev)
 {
 	struct snd_soc_card *card = platform_get_drvdata(pdev);
 
-	gpio_free_array(e800_audio_gpios, ARRAY_SIZE(e800_audio_gpios));
 	snd_soc_unregister_card(card);
 	return 0;
 }
-- 
1.9.1

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

* [PATCH 5/5] ASoC: pxa/hx4700: Introduce the use of devm_gpio_request_array
  2014-07-06 17:46 [PATCH 0/5] Introduce a managed function for gpio_request_array Himangi Saraogi
                   ` (3 preceding siblings ...)
  2014-07-06 17:51 ` [PATCH 4/5] ASoC: pxa: e800_wm9712: Introduce the use of devm_gpio_request_array Himangi Saraogi
@ 2014-07-06 17:52 ` Himangi Saraogi
  2014-07-09 10:14 ` [PATCH 0/5] Introduce a managed function for gpio_request_array Linus Walleij
  5 siblings, 0 replies; 17+ messages in thread
From: Himangi Saraogi @ 2014-07-06 17:52 UTC (permalink / raw)
  To: linux-arm-kernel

This patch moves the resources allocated using gpio_request_array to the
managed interface and removes the calls to gpio_free_array in the probe
and remove functions.

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
 sound/soc/pxa/hx4700.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/sound/soc/pxa/hx4700.c b/sound/soc/pxa/hx4700.c
index 05559a7..b624526 100644
--- a/sound/soc/pxa/hx4700.c
+++ b/sound/soc/pxa/hx4700.c
@@ -198,18 +198,13 @@ static int hx4700_audio_probe(struct platform_device *pdev)
 	if (!machine_is_h4700())
 		return -ENODEV;
 
-	ret = gpio_request_array(hx4700_audio_gpios,
-				ARRAY_SIZE(hx4700_audio_gpios));
+	ret = devm_gpio_request_array(&pdev->dev, hx4700_audio_gpios,
+				      ARRAY_SIZE(hx4700_audio_gpios));
 	if (ret)
 		return ret;
 
 	snd_soc_card_hx4700.dev = &pdev->dev;
-	ret = snd_soc_register_card(&snd_soc_card_hx4700);
-	if (ret)
-		gpio_free_array(hx4700_audio_gpios,
-				ARRAY_SIZE(hx4700_audio_gpios));
-
-	return ret;
+	return snd_soc_register_card(&snd_soc_card_hx4700);
 }
 
 static int hx4700_audio_remove(struct platform_device *pdev)
@@ -219,7 +214,6 @@ static int hx4700_audio_remove(struct platform_device *pdev)
 	gpio_set_value(GPIO92_HX4700_HP_DRIVER, 0);
 	gpio_set_value(GPIO107_HX4700_SPK_nSD, 0);
 
-	gpio_free_array(hx4700_audio_gpios, ARRAY_SIZE(hx4700_audio_gpios));
 	return 0;
 }
 
-- 
1.9.1

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

* [PATCH 0/5] Introduce a managed function for gpio_request_array
  2014-07-06 17:46 [PATCH 0/5] Introduce a managed function for gpio_request_array Himangi Saraogi
                   ` (4 preceding siblings ...)
  2014-07-06 17:52 ` [PATCH 5/5] ASoC: pxa/hx4700: " Himangi Saraogi
@ 2014-07-09 10:14 ` Linus Walleij
  2014-07-09 12:10   ` Alexandre Courbot
  5 siblings, 1 reply; 17+ messages in thread
From: Linus Walleij @ 2014-07-09 10:14 UTC (permalink / raw)
  To: linux-arm-kernel

On Sun, Jul 6, 2014 at 7:46 PM, Himangi Saraogi <himangi774@gmail.com> wrote:

> This patchset intoduces a new managed interface devm_gpio_request_array,
> adds it in the documentation and its declaration in the gpio.h include
> file. Some cases of gpio_request_array are changed to
> devm_gpio_request_array.
>
> Himangi Saraogi (5):
>   gpiolib: devres: Introduce the function devm_request_gpio_array
>   ASoC: wm1250-ev1: Use devm_gpio_request_array
>   ASoC: pxa: Use devm_gpio_request_array
>   ASoC: pxa: e800_wm9712: Introduce the use of devm_gpio_request_array
>   ASoC: pxa/hx4700: Introduce the use of devm_gpio_request_array

Sorry, we're not encouraging extension of the old gpio* plain API anymore.

The right thing to do is convert users over to using GPIO descriptors
internally, then introduce devm_gpiod_get_array() if that makes some
sense.

Alexandre, what do you say?

Yours,
Linus Walleij

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

* [PATCH 1/5] gpiolib: devres: Introduce the function devm_request_gpio_array
  2014-07-06 17:47 ` [PATCH 1/5] gpiolib: devres: Introduce the function devm_request_gpio_array Himangi Saraogi
@ 2014-07-09 11:18   ` Rob Jones
  2014-07-09 11:52     ` Julia Lawall
  2014-07-10  9:21     ` Linus Walleij
  0 siblings, 2 replies; 17+ messages in thread
From: Rob Jones @ 2014-07-09 11:18 UTC (permalink / raw)
  To: linux-arm-kernel

Please note that I submitted a patch on 02/07/14 to create this
function which was acked by Linus Walleij on 05/07/14.

Great minds think alike, and all that.

However, I think that the version I submitted better replicates the
original (non devm) functionality, see below.

I didn't, however, add it to the documentation. +1 on that.

On 06/07/14 18:47, Himangi Saraogi wrote:
> This patch introduces the function devm_request_gpio_array that
> allocates multiple GPIOs in a single call in a managed manner. The
> function is also included in the documentation and a declaration is
> added in include/linux/gpio.h.
>
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> ---
>   Documentation/driver-model/devres.txt |  1 +
>   drivers/gpio/devres.c                 | 21 +++++++++++++++++++++
>   include/linux/gpio.h                  |  2 ++
>   3 files changed, 24 insertions(+)
>
> diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
> index 9e2098e..756f6cf 100644
> --- a/Documentation/driver-model/devres.txt
> +++ b/Documentation/driver-model/devres.txt
> @@ -337,6 +337,7 @@ GPIO
>     devm_gpiod_put()
>     devm_gpio_request()
>     devm_gpio_request_one()
> +  devm_gpio_request_array()
>     devm_gpio_free()
>
>   SND
> diff --git a/drivers/gpio/devres.c b/drivers/gpio/devres.c
> index 65978cf..adae7fa 100644
> --- a/drivers/gpio/devres.c
> +++ b/drivers/gpio/devres.c
> @@ -229,6 +229,27 @@ int devm_gpio_request_one(struct device *dev, unsigned gpio,
>   EXPORT_SYMBOL(devm_gpio_request_one);
>
>   /**
> + *	devm_gpio_request_array - request multiple GPIOs in a single call
> + *	@dev:   device to request for
> + *	@array:	array of the 'struct gpio'
> + *	@num:	how many GPIOs in the array
> + */
> +int devm_gpio_request_array(struct device *dev, const struct gpio *array,
> +			    size_t num)
> +{
> +	int i, err;
> +
> +	for (i = 0; i < num; i++, array++) {
> +		err = devm_gpio_request_one(dev, array->gpio, array->flags,
> +					    array->label);
> +		if (err)
> +			return err;

The failure path in the version I submitted frees up any already
allocated gpios on the first failure.

> +	}
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(devm_gpio_request_array);
> +
> +/**
>    *      devm_gpio_free - free a GPIO
>    *      @dev: device to free GPIO for
>    *      @gpio: GPIO to free
> diff --git a/include/linux/gpio.h b/include/linux/gpio.h
> index 85aa5d0..c85f243 100644
> --- a/include/linux/gpio.h
> +++ b/include/linux/gpio.h
> @@ -84,6 +84,8 @@ struct device;
>   int devm_gpio_request(struct device *dev, unsigned gpio, const char *label);
>   int devm_gpio_request_one(struct device *dev, unsigned gpio,
>   			  unsigned long flags, const char *label);
> +int devm_gpio_request_array(struct device *dev, const struct gpio *array,
> +			    size_t num);
>   void devm_gpio_free(struct device *dev, unsigned int gpio);
>
>   #else /* ! CONFIG_GPIOLIB */
>

-- 
Rob Jones
Codethink Ltd
mailto:rob.jones at codethink.co.uk
tel:+44 161 236 5575

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

* [PATCH 1/5] gpiolib: devres: Introduce the function devm_request_gpio_array
  2014-07-09 11:18   ` Rob Jones
@ 2014-07-09 11:52     ` Julia Lawall
  2014-07-09 12:48       ` Rob Jones
  2014-07-10  9:21     ` Linus Walleij
  1 sibling, 1 reply; 17+ messages in thread
From: Julia Lawall @ 2014-07-09 11:52 UTC (permalink / raw)
  To: linux-arm-kernel



On Wed, 9 Jul 2014, Rob Jones wrote:

> Please note that I submitted a patch on 02/07/14 to create this
> function which was acked by Linus Walleij on 05/07/14.
>
> Great minds think alike, and all that.
>
> However, I think that the version I submitted better replicates the
> original (non devm) functionality, see below.
>
> I didn't, however, add it to the documentation. +1 on that.
>
> On 06/07/14 18:47, Himangi Saraogi wrote:
> > This patch introduces the function devm_request_gpio_array that
> > allocates multiple GPIOs in a single call in a managed manner. The
> > function is also included in the documentation and a declaration is
> > added in include/linux/gpio.h.
> >
> > Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> > ---
> >   Documentation/driver-model/devres.txt |  1 +
> >   drivers/gpio/devres.c                 | 21 +++++++++++++++++++++
> >   include/linux/gpio.h                  |  2 ++
> >   3 files changed, 24 insertions(+)
> >
> > diff --git a/Documentation/driver-model/devres.txt
> > b/Documentation/driver-model/devres.txt
> > index 9e2098e..756f6cf 100644
> > --- a/Documentation/driver-model/devres.txt
> > +++ b/Documentation/driver-model/devres.txt
> > @@ -337,6 +337,7 @@ GPIO
> >     devm_gpiod_put()
> >     devm_gpio_request()
> >     devm_gpio_request_one()
> > +  devm_gpio_request_array()
> >     devm_gpio_free()
> >
> >   SND
> > diff --git a/drivers/gpio/devres.c b/drivers/gpio/devres.c
> > index 65978cf..adae7fa 100644
> > --- a/drivers/gpio/devres.c
> > +++ b/drivers/gpio/devres.c
> > @@ -229,6 +229,27 @@ int devm_gpio_request_one(struct device *dev, unsigned
> > gpio,
> >   EXPORT_SYMBOL(devm_gpio_request_one);
> >
> >   /**
> > + *	devm_gpio_request_array - request multiple GPIOs in a single call
> > + *	@dev:   device to request for
> > + *	@array:	array of the 'struct gpio'
> > + *	@num:	how many GPIOs in the array
> > + */
> > +int devm_gpio_request_array(struct device *dev, const struct gpio *array,
> > +			    size_t num)
> > +{
> > +	int i, err;
> > +
> > +	for (i = 0; i < num; i++, array++) {
> > +		err = devm_gpio_request_one(dev, array->gpio, array->flags,
> > +					    array->label);
> > +		if (err)
> > +			return err;
>
> The failure path in the version I submitted frees up any already
> allocated gpios on the first failure.

Himangi first proposed doing that, but I thought it was not really in the
spirit of devm functions, which is to leave that implicit.  No strong
opinion on the matter, though.

julia


>
> > +	}
> > +	return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(devm_gpio_request_array);
> > +
> > +/**
> >    *      devm_gpio_free - free a GPIO
> >    *      @dev: device to free GPIO for
> >    *      @gpio: GPIO to free
> > diff --git a/include/linux/gpio.h b/include/linux/gpio.h
> > index 85aa5d0..c85f243 100644
> > --- a/include/linux/gpio.h
> > +++ b/include/linux/gpio.h
> > @@ -84,6 +84,8 @@ struct device;
> >   int devm_gpio_request(struct device *dev, unsigned gpio, const char
> > *label);
> >   int devm_gpio_request_one(struct device *dev, unsigned gpio,
> >   			  unsigned long flags, const char *label);
> > +int devm_gpio_request_array(struct device *dev, const struct gpio *array,
> > +			    size_t num);
> >   void devm_gpio_free(struct device *dev, unsigned int gpio);
> >
> >   #else /* ! CONFIG_GPIOLIB */
> >
>
> --
> Rob Jones
> Codethink Ltd
> mailto:rob.jones at codethink.co.uk
> tel:+44 161 236 5575
>

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

* [PATCH 0/5] Introduce a managed function for gpio_request_array
  2014-07-09 10:14 ` [PATCH 0/5] Introduce a managed function for gpio_request_array Linus Walleij
@ 2014-07-09 12:10   ` Alexandre Courbot
  0 siblings, 0 replies; 17+ messages in thread
From: Alexandre Courbot @ 2014-07-09 12:10 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jul 9, 2014 at 7:14 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Sun, Jul 6, 2014 at 7:46 PM, Himangi Saraogi <himangi774@gmail.com> wrote:
>
>> This patchset intoduces a new managed interface devm_gpio_request_array,
>> adds it in the documentation and its declaration in the gpio.h include
>> file. Some cases of gpio_request_array are changed to
>> devm_gpio_request_array.
>>
>> Himangi Saraogi (5):
>>   gpiolib: devres: Introduce the function devm_request_gpio_array
>>   ASoC: wm1250-ev1: Use devm_gpio_request_array
>>   ASoC: pxa: Use devm_gpio_request_array
>>   ASoC: pxa: e800_wm9712: Introduce the use of devm_gpio_request_array
>>   ASoC: pxa/hx4700: Introduce the use of devm_gpio_request_array
>
> Sorry, we're not encouraging extension of the old gpio* plain API anymore.
>
> The right thing to do is convert users over to using GPIO descriptors
> internally, then introduce devm_gpiod_get_array() if that makes some
> sense.
>
> Alexandre, what do you say?

I do agree that we want to discourage people from using the integer
API, and would also prefer to see the consumers converted to gpiod and
proper gpiod functions introduced.

On the other hand with Rob's similar patch which seems to be about to
be merged (https://lkml.org/lkml/2014/7/2/149 ) I guess the pressure
to accept one or the other is quite high. At least, I hope Rob or
Himangi will follow-up with a patch adding similar functionality to
the gpiod API, and will consider converting their consumers to it
(it's for your own good!).

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

* [PATCH 1/5] gpiolib: devres: Introduce the function devm_request_gpio_array
  2014-07-09 11:52     ` Julia Lawall
@ 2014-07-09 12:48       ` Rob Jones
  0 siblings, 0 replies; 17+ messages in thread
From: Rob Jones @ 2014-07-09 12:48 UTC (permalink / raw)
  To: linux-arm-kernel



On 09/07/14 12:52, Julia Lawall wrote:
>
>
> On Wed, 9 Jul 2014, Rob Jones wrote:
>
>> Please note that I submitted a patch on 02/07/14 to create this
>> function which was acked by Linus Walleij on 05/07/14.
>>
>> Great minds think alike, and all that.
>>
>> However, I think that the version I submitted better replicates the
>> original (non devm) functionality, see below.

<snip>

>>> +int devm_gpio_request_array(struct device *dev, const struct gpio *array,
>>> +			    size_t num)
>>> +{
>>> +	int i, err;
>>> +
>>> +	for (i = 0; i < num; i++, array++) {
>>> +		err = devm_gpio_request_one(dev, array->gpio, array->flags,
>>> +					    array->label);
>>> +		if (err)
>>> +			return err;
>>
>> The failure path in the version I submitted frees up any already
>> allocated gpios on the first failure.
>
> Himangi first proposed doing that, but I thought it was not really in the
> spirit of devm functions, which is to leave that implicit.  No strong
> opinion on the matter, though.
>

Interestingly, we came at it from the other direction: I originally
didn't have the unwind in and our internal review guys suggested that
it was in the original function so putting it in would:

1. make this a better analogue of the original
2. help avoid deadlocks
3. allow the driver to retry, perhaps requesting reduced functionality.

> julia
>

<snip>

-- 
Rob Jones
Codethink Ltd
mailto:rob.jones at codethink.co.uk
tel:+44 161 236 5575

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

* [PATCH 1/5] gpiolib: devres: Introduce the function devm_request_gpio_array
  2014-07-09 11:18   ` Rob Jones
  2014-07-09 11:52     ` Julia Lawall
@ 2014-07-10  9:21     ` Linus Walleij
  2014-07-10 11:01       ` Rob Jones
  1 sibling, 1 reply; 17+ messages in thread
From: Linus Walleij @ 2014-07-10  9:21 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jul 9, 2014 at 1:18 PM, Rob Jones <rob.jones@codethink.co.uk> wrote:

> Please note that I submitted a patch on 02/07/14 to create this
> function which was acked by Linus Walleij on 05/07/14.
>
> Great minds think alike, and all that.

My mind certainly isn't any great :-(

My left hand seems to be unaware of what the right hand is doing.

Did I ACK that for merging through some other tree then?

And I guess if Himangi want to submit these ASoC patches, they
will have to go through the same tree as those patches in that case?

And would you consider implementing a gpiod version...?

> However, I think that the version I submitted better replicates the
> original (non devm) functionality, see below.
>
> I didn't, however, add it to the documentation. +1 on that.

Can you include that oneliner in your patch then to reduce
problems?

Yours,
Linus Walleij

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

* [PATCH 1/5] gpiolib: devres: Introduce the function devm_request_gpio_array
  2014-07-10  9:21     ` Linus Walleij
@ 2014-07-10 11:01       ` Rob Jones
  2014-07-11  0:35         ` Javier Martinez Canillas
  0 siblings, 1 reply; 17+ messages in thread
From: Rob Jones @ 2014-07-10 11:01 UTC (permalink / raw)
  To: linux-arm-kernel



On 10/07/14 10:21, Linus Walleij wrote:
> On Wed, Jul 9, 2014 at 1:18 PM, Rob Jones <rob.jones@codethink.co.uk> wrote:
>
>> Please note that I submitted a patch on 02/07/14 to create this
>> function which was acked by Linus Walleij on 05/07/14.
>>
>> Great minds think alike, and all that.
>
> My mind certainly isn't any great :-(
>

I doubt that :-)

> My left hand seems to be unaware of what the right hand is doing.
>
> Did I ACK that for merging through some other tree then?
>

You did: https://lkml.org/lkml/2014/7/4/715

> And I guess if Himangi want to submit these ASoC patches, they
> will have to go through the same tree as those patches in that case?
>

I don't know enough to comment.

> And would you consider implementing a gpiod version...?
>

I will certainly consider it. I'm in the middle of something else right
now but I should be available in a day or two and I'll have a look.

>> However, I think that the version I submitted better replicates the
>> original (non devm) functionality, see below.
>>
>> I didn't, however, add it to the documentation. +1 on that.
>
> Can you include that oneliner in your patch then to reduce
> problems?
>

Certainly, with acknowledgement to Himangi Saraogi. Should I resubmit
the patch series with amendment or should I put it in as a separate
patch? Sorry for the noobie question but I *am* new to the kernel
lists.

> Yours,
> Linus Walleij
>
>

-- 
Rob Jones
Codethink Ltd
mailto:rob.jones at codethink.co.uk
tel:+44 161 236 5575

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

* [PATCH 1/5] gpiolib: devres: Introduce the function devm_request_gpio_array
  2014-07-10 11:01       ` Rob Jones
@ 2014-07-11  0:35         ` Javier Martinez Canillas
  2014-07-11 10:03           ` Rob Jones
  0 siblings, 1 reply; 17+ messages in thread
From: Javier Martinez Canillas @ 2014-07-11  0:35 UTC (permalink / raw)
  To: linux-arm-kernel

Hello Rob,

On Thu, Jul 10, 2014 at 1:01 PM, Rob Jones <rob.jones@codethink.co.uk> wrote:
>
>
> On 10/07/14 10:21, Linus Walleij wrote:
>>
>> On Wed, Jul 9, 2014 at 1:18 PM, Rob Jones <rob.jones@codethink.co.uk>
>> wrote:
>>
>>> Please note that I submitted a patch on 02/07/14 to create this
>>> function which was acked by Linus Walleij on 05/07/14.
>>>
>>> Great minds think alike, and all that.
>>
>>
>> My mind certainly isn't any great :-(
>>
>
> I doubt that :-)
>
>
>> My left hand seems to be unaware of what the right hand is doing.
>>
>> Did I ACK that for merging through some other tree then?
>>
>
> You did: https://lkml.org/lkml/2014/7/4/715
>
>
>> And I guess if Himangi want to submit these ASoC patches, they
>> will have to go through the same tree as those patches in that case?
>>
>
> I don't know enough to comment.
>
>
>> And would you consider implementing a gpiod version...?
>>
>
> I will certainly consider it. I'm in the middle of something else right
> now but I should be available in a day or two and I'll have a look.
>
>

I'm working on a driver for a PMIC which uses a set of GPIO to select
a particular register. Right now I'm getting each GPIO independently
but Linus mentioned [0] the devm_gpio_request_array() patch you
posted.

Now, I'm not using the integer-based GPIO API but the new
descriptor-based one so I was wondering if you are already
implementing a devm_gpiod_get_array() or if you want me to implement
it myself.

Best regards,
Javier

[0]: https://lkml.org/lkml/2014/7/10/166

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

* [PATCH 1/5] gpiolib: devres: Introduce the function devm_request_gpio_array
  2014-07-11  0:35         ` Javier Martinez Canillas
@ 2014-07-11 10:03           ` Rob Jones
  2014-07-11 10:07             ` Javier Martinez Canillas
  0 siblings, 1 reply; 17+ messages in thread
From: Rob Jones @ 2014-07-11 10:03 UTC (permalink / raw)
  To: linux-arm-kernel



On 11/07/14 01:35, Javier Martinez Canillas wrote:
> Hello Rob,
>
> On Thu, Jul 10, 2014 at 1:01 PM, Rob Jones <rob.jones@codethink.co.uk> wrote:

<snip>

>>
>> I will certainly consider it. I'm in the middle of something else right
>> now but I should be available in a day or two and I'll have a look.
>>
>>
>
> I'm working on a driver for a PMIC which uses a set of GPIO to select
> a particular register. Right now I'm getting each GPIO independently
> but Linus mentioned [0] the devm_gpio_request_array() patch you
> posted.
>
> Now, I'm not using the integer-based GPIO API but the new
> descriptor-based one so I was wondering if you are already
> implementing a devm_gpiod_get_array() or if you want me to implement
> it myself.
>

As I said, I'm deep in something else for the next day or two so if you
need it urgently you should probably do it yourself but if you don't
mind waiting until next week, I can have a go.

Your call, let me know.

> Best regards,
> Javier
>
> [0]: https://lkml.org/lkml/2014/7/10/166
> --
> To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

-- 
Rob Jones
Codethink Ltd
mailto:rob.jones at codethink.co.uk
tel:+44 161 236 5575

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

* [PATCH 1/5] gpiolib: devres: Introduce the function devm_request_gpio_array
  2014-07-11 10:03           ` Rob Jones
@ 2014-07-11 10:07             ` Javier Martinez Canillas
  2014-08-14 15:17               ` Rob Jones
  0 siblings, 1 reply; 17+ messages in thread
From: Javier Martinez Canillas @ 2014-07-11 10:07 UTC (permalink / raw)
  To: linux-arm-kernel

Hello Rob,

On Fri, Jul 11, 2014 at 12:03 PM, Rob Jones <rob.jones@codethink.co.uk> wrote:
>
>
> On 11/07/14 01:35, Javier Martinez Canillas wrote:
>>
>> Hello Rob,
>>
>> On Thu, Jul 10, 2014 at 1:01 PM, Rob Jones <rob.jones@codethink.co.uk>
>> wrote:
>
>
> <snip>
>
>
>>>
>>> I will certainly consider it. I'm in the middle of something else right
>>> now but I should be available in a day or two and I'll have a look.
>>>
>>>
>>
>> I'm working on a driver for a PMIC which uses a set of GPIO to select
>> a particular register. Right now I'm getting each GPIO independently
>> but Linus mentioned [0] the devm_gpio_request_array() patch you
>> posted.
>>
>> Now, I'm not using the integer-based GPIO API but the new
>> descriptor-based one so I was wondering if you are already
>> implementing a devm_gpiod_get_array() or if you want me to implement
>> it myself.
>>
>
> As I said, I'm deep in something else for the next day or two so if you
> need it urgently you should probably do it yourself but if you don't
> mind waiting until next week, I can have a go.
>
> Your call, let me know.
>

I'm not in a hurry, just wanted to know if it was on your plate. I'll
wait for your patch then, thanks!

Best regards,
Javier

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

* [PATCH 1/5] gpiolib: devres: Introduce the function devm_request_gpio_array
  2014-07-11 10:07             ` Javier Martinez Canillas
@ 2014-08-14 15:17               ` Rob Jones
  0 siblings, 0 replies; 17+ messages in thread
From: Rob Jones @ 2014-08-14 15:17 UTC (permalink / raw)
  To: linux-arm-kernel

I'm afraid too many other things have been landing on my plate and I
don't think I will be able to get on this for the foreseeable future,
sorry about this.

On 11/07/14 11:07, Javier Martinez Canillas wrote:
> Hello Rob,
>
> On Fri, Jul 11, 2014 at 12:03 PM, Rob Jones <rob.jones@codethink.co.uk> wrote:
>>
>>
>> On 11/07/14 01:35, Javier Martinez Canillas wrote:
>>>
>>> Hello Rob,
>>>
>>> On Thu, Jul 10, 2014 at 1:01 PM, Rob Jones <rob.jones@codethink.co.uk>
>>> wrote:
>>
>>
>> <snip>
>>
>>
>>>>
>>>> I will certainly consider it. I'm in the middle of something else right
>>>> now but I should be available in a day or two and I'll have a look.
>>>>
>>>>
>>>
>>> I'm working on a driver for a PMIC which uses a set of GPIO to select
>>> a particular register. Right now I'm getting each GPIO independently
>>> but Linus mentioned [0] the devm_gpio_request_array() patch you
>>> posted.
>>>
>>> Now, I'm not using the integer-based GPIO API but the new
>>> descriptor-based one so I was wondering if you are already
>>> implementing a devm_gpiod_get_array() or if you want me to implement
>>> it myself.
>>>
>>
>> As I said, I'm deep in something else for the next day or two so if you
>> need it urgently you should probably do it yourself but if you don't
>> mind waiting until next week, I can have a go.
>>
>> Your call, let me know.
>>
>
> I'm not in a hurry, just wanted to know if it was on your plate. I'll
> wait for your patch then, thanks!
>
> Best regards,
> Javier
>
>

-- 
Rob Jones
Codethink Ltd
mailto:rob.jones at codethink.co.uk
tel:+44 161 236 5575

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

end of thread, other threads:[~2014-08-14 15:17 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-06 17:46 [PATCH 0/5] Introduce a managed function for gpio_request_array Himangi Saraogi
2014-07-06 17:47 ` [PATCH 1/5] gpiolib: devres: Introduce the function devm_request_gpio_array Himangi Saraogi
2014-07-09 11:18   ` Rob Jones
2014-07-09 11:52     ` Julia Lawall
2014-07-09 12:48       ` Rob Jones
2014-07-10  9:21     ` Linus Walleij
2014-07-10 11:01       ` Rob Jones
2014-07-11  0:35         ` Javier Martinez Canillas
2014-07-11 10:03           ` Rob Jones
2014-07-11 10:07             ` Javier Martinez Canillas
2014-08-14 15:17               ` Rob Jones
2014-07-06 17:48 ` [PATCH 2/5] ASoC: wm1250-ev1: Use devm_gpio_request_array Himangi Saraogi
2014-07-06 17:49 ` [PATCH 3/5] ASoC: pxa: " Himangi Saraogi
2014-07-06 17:51 ` [PATCH 4/5] ASoC: pxa: e800_wm9712: Introduce the use of devm_gpio_request_array Himangi Saraogi
2014-07-06 17:52 ` [PATCH 5/5] ASoC: pxa/hx4700: " Himangi Saraogi
2014-07-09 10:14 ` [PATCH 0/5] Introduce a managed function for gpio_request_array Linus Walleij
2014-07-09 12:10   ` Alexandre Courbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).