From b9300805fefb8ea001f1627a3813fdd13bfeee2c Mon Sep 17 00:00:00 2001 From: "Mike J. Chen" Date: Thu, 14 Oct 2010 18:04:03 -0700 Subject: [PATCH] input: misc: gpio; make wake irq conditional, and disable on remove paths Add a board file option to gpio_input devices to make calling enable_irq_wake conditional. Also disable the wake irq when removing the device. Change-Id: If933b9d3a751d89fa95ae3b7f739dfe70fcb23c8 Signed-off-by: Mike J. Chen --- drivers/input/misc/gpio_input.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/input/misc/gpio_input.c b/drivers/input/misc/gpio_input.c index 98d204f..904bd68 100644 --- a/drivers/input/misc/gpio_input.c +++ b/drivers/input/misc/gpio_input.c @@ -227,13 +227,25 @@ static int gpio_event_input_request_irqs(struct gpio_input_state *ds) ds->info->keymap[i].gpio, irq); goto err_request_irq_failed; } - enable_irq_wake(irq); + if (ds->info->info.no_suspend) { + err = enable_irq_wake(irq); + if (err) { + pr_err("gpio_event_input_request_irqs: " + "enable_irq_wake failed for input %d, " + "irq %d\n", + ds->info->keymap[i].gpio, irq); + goto err_enable_irq_wake_failed; + } + } } return 0; for (i = ds->info->keymap_size - 1; i >= 0; i--) { - free_irq(gpio_to_irq(ds->info->keymap[i].gpio), - &ds->key_state[i]); + irq = gpio_to_irq(ds->info->keymap[i].gpio); + if (ds->info->info.no_suspend) + disable_irq_wake(irq); +err_enable_irq_wake_failed: + free_irq(irq, &ds->key_state[i]); err_request_irq_failed: err_gpio_get_irq_num_failed: ; @@ -341,8 +353,10 @@ int gpio_event_input_func(struct gpio_event_input_devs *input_devs, hrtimer_cancel(&ds->timer); if (ds->use_irq) { for (i = di->keymap_size - 1; i >= 0; i--) { - free_irq(gpio_to_irq(di->keymap[i].gpio), - &ds->key_state[i]); + int irq = gpio_to_irq(di->keymap[i].gpio); + if (ds->info->info.no_suspend) + disable_irq_wake(irq); + free_irq(irq, &ds->key_state[i]); } } spin_unlock_irqrestore(&ds->irq_lock, irqflags); -- 2.7.4