@@ -32,6 +32,7 @@
struct gpio_keys_button_data {
int last_state;
int count;
+ int threshold;
int can_sleep;
};
@@ -69,15 +70,13 @@ static void gpio_keys_polled_poll(struct input_polled_dev *dev)
struct gpio_keys_polled_dev *bdev = dev->private;
struct gpio_keys_platform_data *pdata = bdev->pdata;
struct input_dev *input = dev->input;
- int i, threshold;
+ int i;
for (i = 0; i < bdev->pdata->nbuttons; i++) {
struct gpio_keys_button *button = &pdata->buttons[i];
struct gpio_keys_button_data *bdata = &bdev->data[i];
- threshold = DIV_ROUND_UP(button->debounce_interval,
- pdata->poll_interval);
- if (bdata->count < threshold)
+ if (bdata->count < bdata->threshold)
bdata->count++;
else
gpio_keys_polled_check_state(input, button, bdata);
@@ -151,6 +150,7 @@ static int __devinit gpio_keys_polled_probe(struct platform_device *pdev)
for (i = 0; i < pdata->nbuttons; i++) {
struct gpio_keys_button *button = &pdata->buttons[i];
+ struct gpio_keys_button_data *bdata = &bdev->data[i];
unsigned int gpio = button->gpio;
unsigned int type = button->type ?: EV_KEY;
@@ -176,8 +176,10 @@ static int __devinit gpio_keys_polled_probe(struct platform_device *pdev)
goto err_free_gpio;
}
- bdev->data[i].can_sleep = gpio_cansleep(gpio);
- bdev->data[i].last_state = -1;
+ bdata->can_sleep = gpio_cansleep(gpio);
+ bdata->last_state = -1;
+ bdata->threshold = DIV_ROUND_UP(button->debounce_interval,
+ pdata->poll_interval);
input_set_capability(input, type, button->code);
}