All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] extcon: gpio: Request gpio pin before modifying its state
@ 2013-11-22 17:26 Guenter Roeck
  2013-11-26  7:55 ` Chanwoo Choi
  0 siblings, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2013-11-22 17:26 UTC (permalink / raw)
  To: linux-kernel; +Cc: MyungJoo Ham, Chanwoo Choi, Guenter Roeck

Commit 338de0ca (extcon: gpio: Use gpio driver/chip debounce if supported)
introduced a call to gpio_set_debounce() before actually requesting the
respective gpio pin from the gpio subsystem.

The gpio subsystem expects that a gpio pin was requested before modifying its
state. Not doing so results in a warning from gpiolib, and the gpio pin is
auto-requested. This in turn causes the subsequent devm_gpio_request_one()
to fail. So devm_gpio_request_one() must be called prior to calling
gpio_set_debounce().

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/extcon/extcon-gpio.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c
index 7e0dff5..4736a9c 100644
--- a/drivers/extcon/extcon-gpio.c
+++ b/drivers/extcon/extcon-gpio.c
@@ -105,6 +105,12 @@ static int gpio_extcon_probe(struct platform_device *pdev)
 	extcon_data->state_off = pdata->state_off;
 	if (pdata->state_on && pdata->state_off)
 		extcon_data->edev.print_state = extcon_gpio_print_state;
+
+	ret = devm_gpio_request_one(&pdev->dev, extcon_data->gpio, GPIOF_DIR_IN,
+				    pdev->name);
+	if (ret < 0)
+		return ret;
+
 	if (pdata->debounce) {
 		ret = gpio_set_debounce(extcon_data->gpio,
 					pdata->debounce * 1000);
@@ -117,11 +123,6 @@ static int gpio_extcon_probe(struct platform_device *pdev)
 	if (ret < 0)
 		return ret;
 
-	ret = devm_gpio_request_one(&pdev->dev, extcon_data->gpio, GPIOF_DIR_IN,
-				    pdev->name);
-	if (ret < 0)
-		goto err;
-
 	INIT_DELAYED_WORK(&extcon_data->work, gpio_extcon_work);
 
 	extcon_data->irq = gpio_to_irq(extcon_data->gpio);
-- 
1.7.9.7


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

* Re: [PATCH] extcon: gpio: Request gpio pin before modifying its state
@ 2013-11-25  2:37 MyungJoo Ham
  0 siblings, 0 replies; 5+ messages in thread
From: MyungJoo Ham @ 2013-11-25  2:37 UTC (permalink / raw)
  To: Guenter Roeck, linux-kernel@vger.kernel.org; +Cc: 최찬우

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=euc-kr, Size: 1986 bytes --]

> Commit 338de0ca (extcon: gpio: Use gpio driver/chip debounce if supported)
> introduced a call to gpio_set_debounce() before actually requesting the
> respective gpio pin from the gpio subsystem.
> 
> The gpio subsystem expects that a gpio pin was requested before modifying its
> state. Not doing so results in a warning from gpiolib, and the gpio pin is
> auto-requested. This in turn causes the subsequent devm_gpio_request_one()
> to fail. So devm_gpio_request_one() must be called prior to calling
> gpio_set_debounce().
> 
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>

Thank you.


Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>

> ---
>  drivers/extcon/extcon-gpio.c |   11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c
> index 7e0dff5..4736a9c 100644
> --- a/drivers/extcon/extcon-gpio.c
> +++ b/drivers/extcon/extcon-gpio.c
> @@ -105,6 +105,12 @@ static int gpio_extcon_probe(struct platform_device *pdev)
>  	extcon_data->state_off = pdata->state_off;
>  	if (pdata->state_on && pdata->state_off)
>  		extcon_data->edev.print_state = extcon_gpio_print_state;
> +
> +	ret = devm_gpio_request_one(&pdev->dev, extcon_data->gpio, GPIOF_DIR_IN,
> +				    pdev->name);
> +	if (ret < 0)
> +		return ret;
> +
>  	if (pdata->debounce) {
>  		ret = gpio_set_debounce(extcon_data->gpio,
>  					pdata->debounce * 1000);
> @@ -117,11 +123,6 @@ static int gpio_extcon_probe(struct platform_device *pdev)
>  	if (ret < 0)
>  		return ret;
>  
> -	ret = devm_gpio_request_one(&pdev->dev, extcon_data->gpio, GPIOF_DIR_IN,
> -				    pdev->name);
> -	if (ret < 0)
> -		goto err;
> -
>  	INIT_DELAYED_WORK(&extcon_data->work, gpio_extcon_work);
>  
>  	extcon_data->irq = gpio_to_irq(extcon_data->gpio);
> -- 
> 1.7.9.7
> 
> 
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* Re: [PATCH] extcon: gpio: Request gpio pin before modifying its state
  2013-11-22 17:26 [PATCH] extcon: gpio: Request gpio pin before modifying its state Guenter Roeck
@ 2013-11-26  7:55 ` Chanwoo Choi
  2013-11-26 12:07   ` Guenter Roeck
  0 siblings, 1 reply; 5+ messages in thread
From: Chanwoo Choi @ 2013-11-26  7:55 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: linux-kernel, MyungJoo Ham

Hi Guenter,

On 11/23/2013 02:26 AM, Guenter Roeck wrote:
> Commit 338de0ca (extcon: gpio: Use gpio driver/chip debounce if supported)
> introduced a call to gpio_set_debounce() before actually requesting the
> respective gpio pin from the gpio subsystem.
> 
> The gpio subsystem expects that a gpio pin was requested before modifying its
> state. Not doing so results in a warning from gpiolib, and the gpio pin is
> auto-requested. This in turn causes the subsequent devm_gpio_request_one()
> to fail. So devm_gpio_request_one() must be called prior to calling
> gpio_set_debounce().
> 
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  drivers/extcon/extcon-gpio.c |   11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 

Applid it on extcon-next branch.

Thanks,
Chanwoo Choi


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

* Re: [PATCH] extcon: gpio: Request gpio pin before modifying its state
  2013-11-26  7:55 ` Chanwoo Choi
@ 2013-11-26 12:07   ` Guenter Roeck
  2013-11-26 22:41     ` Chanwoo Choi
  0 siblings, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2013-11-26 12:07 UTC (permalink / raw)
  To: Chanwoo Choi; +Cc: linux-kernel, MyungJoo Ham

On 11/25/2013 11:55 PM, Chanwoo Choi wrote:
> Hi Guenter,
>
> On 11/23/2013 02:26 AM, Guenter Roeck wrote:
>> Commit 338de0ca (extcon: gpio: Use gpio driver/chip debounce if supported)
>> introduced a call to gpio_set_debounce() before actually requesting the
>> respective gpio pin from the gpio subsystem.
>>
>> The gpio subsystem expects that a gpio pin was requested before modifying its
>> state. Not doing so results in a warning from gpiolib, and the gpio pin is
>> auto-requested. This in turn causes the subsequent devm_gpio_request_one()
>> to fail. So devm_gpio_request_one() must be called prior to calling
>> gpio_set_debounce().
>>
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>>   drivers/extcon/extcon-gpio.c |   11 ++++++-----
>>   1 file changed, 6 insertions(+), 5 deletions(-)
>>
>
> Applid it on extcon-next branch.
>

As this is a bug fix, I think it would make sense to have this applied to the current
kernel and not wait for 3.14.

Thanks,
Guenter



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

* Re: [PATCH] extcon: gpio: Request gpio pin before modifying its state
  2013-11-26 12:07   ` Guenter Roeck
@ 2013-11-26 22:41     ` Chanwoo Choi
  0 siblings, 0 replies; 5+ messages in thread
From: Chanwoo Choi @ 2013-11-26 22:41 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: linux-kernel, MyungJoo Ham

On 11/26/2013 09:07 PM, Guenter Roeck wrote:
> On 11/25/2013 11:55 PM, Chanwoo Choi wrote:
>> Hi Guenter,
>>
>> On 11/23/2013 02:26 AM, Guenter Roeck wrote:
>>> Commit 338de0ca (extcon: gpio: Use gpio driver/chip debounce if supported)
>>> introduced a call to gpio_set_debounce() before actually requesting the
>>> respective gpio pin from the gpio subsystem.
>>>
>>> The gpio subsystem expects that a gpio pin was requested before modifying its
>>> state. Not doing so results in a warning from gpiolib, and the gpio pin is
>>> auto-requested. This in turn causes the subsequent devm_gpio_request_one()
>>> to fail. So devm_gpio_request_one() must be called prior to calling
>>> gpio_set_debounce().
>>>
>>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>>> ---
>>>   drivers/extcon/extcon-gpio.c |   11 ++++++-----
>>>   1 file changed, 6 insertions(+), 5 deletions(-)
>>>
>>
>> Applid it on extcon-next branch.
>>
> 
> As this is a bug fix, I think it would make sense to have this applied to the current
> kernel and not wait for 3.14.
> 

OK, I move it on extcon-linus branch.

Thanks,
Chanwoo Choi


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

end of thread, other threads:[~2013-11-26 22:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-22 17:26 [PATCH] extcon: gpio: Request gpio pin before modifying its state Guenter Roeck
2013-11-26  7:55 ` Chanwoo Choi
2013-11-26 12:07   ` Guenter Roeck
2013-11-26 22:41     ` Chanwoo Choi
  -- strict thread matches above, loose matches on Subject: below --
2013-11-25  2:37 MyungJoo Ham

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.