#include <linux/platform_device.h>
#include <linux/input.h>
#include <linux/gpio_keys.h>
+#include <linux/workqueue.h>
#include <asm/gpio.h>
struct gpio_keys_button *button;
struct input_dev *input;
struct timer_list timer;
+ struct work_struct work;
};
struct gpio_keys_drvdata {
struct gpio_button_data data[0];
};
-static void gpio_keys_report_event(struct gpio_button_data *bdata)
+static void gpio_keys_report_event(struct work_struct *work)
{
+ struct gpio_button_data *bdata =
+ container_of(work, struct gpio_button_data, work);
struct gpio_keys_button *button = bdata->button;
struct input_dev *input = bdata->input;
unsigned int type = button->type ?: EV_KEY;
input_sync(input);
}
-static void gpio_check_button(unsigned long _data)
+static void gpio_keys_timer(unsigned long _data)
{
struct gpio_button_data *data = (struct gpio_button_data *)_data;
- gpio_keys_report_event(data);
+ schedule_work(&data->work);
}
static irqreturn_t gpio_keys_isr(int irq, void *dev_id)
mod_timer(&bdata->timer,
jiffies + msecs_to_jiffies(button->debounce_interval));
else
- gpio_keys_report_event(bdata);
+ schedule_work(&bdata->work);
return IRQ_HANDLED;
}
bdata->input = input;
bdata->button = button;
setup_timer(&bdata->timer,
- gpio_check_button, (unsigned long)bdata);
+ gpio_keys_timer, (unsigned long)bdata);
+ INIT_WORK(&bdata->work, gpio_keys_report_event);
error = gpio_request(button->gpio, button->desc ?: "gpio_keys");
if (error < 0) {
free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]);
if (pdata->buttons[i].debounce_interval)
del_timer_sync(&ddata->data[i].timer);
+ cancel_work_sync(&ddata->data[i].work);
gpio_free(pdata->buttons[i].gpio);
}
free_irq(irq, &ddata->data[i]);
if (pdata->buttons[i].debounce_interval)
del_timer_sync(&ddata->data[i].timer);
+ cancel_work_sync(&ddata->data[i].work);
gpio_free(pdata->buttons[i].gpio);
}