public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] extcon: gpio: queue work only if debounce is NZ
@ 2016-03-08 11:45 Venkat Reddy Talla
  2016-03-08 14:51 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Venkat Reddy Talla @ 2016-03-08 11:45 UTC (permalink / raw)
  To: MyungJoo Ham, Chanwoo Choi
  Cc: linux-kernel, Laxman Dewangan, Venkat Reddy Talla

Use queue_delayed_work only when debounce time is
required to read gpio state properly, read the gpio
state and set the extcon cable state in IRQ handler
context if gpio settling time is not needed.

Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com>
---
 drivers/extcon/extcon-gpio.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c
index 279ff8f..1beb086 100644
--- a/drivers/extcon/extcon-gpio.c
+++ b/drivers/extcon/extcon-gpio.c
@@ -56,8 +56,12 @@ static irqreturn_t gpio_irq_handler(int irq, void *dev_id)
 {
 	struct gpio_extcon_data *data = dev_id;
 
-	queue_delayed_work(system_power_efficient_wq, &data->work,
+	if (data->debounce_jiffies)
+		queue_delayed_work(system_power_efficient_wq, &data->work,
 			      data->debounce_jiffies);
+	else
+		gpio_extcon_work(&data->work.work);
+
 	return IRQ_HANDLED;
 }
 
-- 
2.1.4

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

* Re: [PATCH 1/1] extcon: gpio: queue work only if debounce is NZ
  2016-03-08 11:45 [PATCH 1/1] extcon: gpio: queue work only if debounce is NZ Venkat Reddy Talla
@ 2016-03-08 14:51 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2016-03-08 14:51 UTC (permalink / raw)
  To: Venkat Reddy Talla
  Cc: MyungJoo Ham, Chanwoo Choi, linux-kernel, Laxman Dewangan

On Tue, Mar 08, 2016 at 05:15:53PM +0530, Venkat Reddy Talla wrote:
> Use queue_delayed_work only when debounce time is
> required to read gpio state properly, read the gpio
> state and set the extcon cable state in IRQ handler
> context if gpio settling time is not needed.
> 
> Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com>
> ---
>  drivers/extcon/extcon-gpio.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c
> index 279ff8f..1beb086 100644
> --- a/drivers/extcon/extcon-gpio.c
> +++ b/drivers/extcon/extcon-gpio.c
> @@ -56,8 +56,12 @@ static irqreturn_t gpio_irq_handler(int irq, void *dev_id)
>  {
>  	struct gpio_extcon_data *data = dev_id;
>  
> -	queue_delayed_work(system_power_efficient_wq, &data->work,
> +	if (data->debounce_jiffies)
> +		queue_delayed_work(system_power_efficient_wq, &data->work,
>  			      data->debounce_jiffies);
> +	else
> +		gpio_extcon_work(&data->work.work);
> +

The interrupt is requested with devm_request_any_context_irq(), meaning
the handler may run in hard interrupt context. gpio_extcon_work() calls
gpiod_get_value_cansleep(), which may not be a good idea in hard interrupt
context.

Guenter

>  	return IRQ_HANDLED;
>  }
>  
> -- 
> 2.1.4
> 
> 

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

end of thread, other threads:[~2016-03-08 15:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-08 11:45 [PATCH 1/1] extcon: gpio: queue work only if debounce is NZ Venkat Reddy Talla
2016-03-08 14:51 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox