extcon: gpio: queue work only if debounce is NZ
PATCH 1/1 extcon: gpio: queue work only if debounce is NZ
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.
--- drivers/extcon/extcon-gpio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/extcon/extcon-gpio.c +5 -1
@@ -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 ; }
Signature · 1 line
2.1.4
Quoted 15 lines · Venkat Reddy Talla
Use
queue_delayed_workonly 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 <[email protected]>--- drivers/extcon/extcon-gpio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/extcon/extcon-gpio.c +0
-0
drivers/extcon/extcon-gpio.c static irqreturn_t gpio_irq_handler(int irq, void *dev_id) · line 64
Quoted 10 lines
drivers/extcon/extcon-gpio.c +5
-1@@ -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
Quoted 7 lines
drivers/extcon/extcon-gpio.c +0
-0return IRQ_HANDLED ; }Signature · 1 line
2.1.4