input: gpio-keys - use spin_lock()
Subsystems (2)
PATCH 1/1 input: gpio-keys - use spin_lock()
Use the spin_lock() and spin_unlock() instead of spin_lock_irqsave() and spin_unlock_restore()
Signed-off-by Lizhe <[email protected]>
--- drivers/input/keyboard/gpio_keys.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/input/keyboard/gpio_keys.c +2 -3
@@ -468,11 +468,10 @@ static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id) {struct gpio_button_data *bdata = dev_id;struct input_dev *input = bdata->input; -unsigned long flags;BUG_ON (irq != bdata->irq); -spin_lock_irqsave (&bdata->lock, flags); +spin_lock (&bdata->lock);if (!bdata->key_pressed) {if (bdata->button->wakeup)
@@ -495,7 +494,7 @@ static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id)ms_to_ktime (bdata->release_delay), HRTIMER_MODE_REL_HARD); out: -spin_unlock_irqrestore (&bdata->lock, flags); +spin_unlock (&bdata->lock);return IRQ_HANDLED ; }
Signature · 1 line
2.25.1
Hi Lizhe,
Thanks for your patch!
Quoted 2 lines · Lizhe
Use the
spin_lock()andspin_unlock()instead ofspin_lock_irqsave()andspin_unlock_restore()
Please explain why...
Quoted 18 lines
Signed-off-by Lizhe <[email protected]>drivers/input/keyboard/gpio_keys.c +1
-2@@ -468,11 +468,10 @@ static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id) {struct gpio_button_data *bdata = dev_id;struct input_dev *input = bdata->input; -unsigned long flags;BUG_ON (irq != bdata->irq); -spin_lock_irqsave (&bdata->lock, flags); +spin_lock (&bdata->lock);if (!bdata->key_pressed) {if (bdata->button->wakeup)
drivers/input/keyboard/gpio_keys.c static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id) · line 499
Quoted 7 lines
drivers/input/keyboard/gpio_keys.c +1
-1@@ -495,7 +494,7 @@ static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id)ms_to_ktime (bdata->release_delay), HRTIMER_MODE_REL_HARD); out: -spin_unlock_irqrestore (&bdata->lock, flags); +spin_unlock (&bdata->lock);return IRQ_HANDLED ; }
Are you sure this is safe, given the interrupt is requested with devm_request_any_context_irq(), and thus the handler may be registered using either request_irq() or request_threaded_irq()?
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds