From patchwork Tue Nov 30 18:44:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabor Juhos X-Patchwork-Id: 367861 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAUIiTJO029886 for ; Tue, 30 Nov 2010 18:44:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755198Ab0K3So3 (ORCPT ); Tue, 30 Nov 2010 13:44:29 -0500 Received: from phoenix3.szarvasnet.hu ([87.101.127.16]:37530 "EHLO phoenix3.szarvasnet.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755490Ab0K3So2 (ORCPT ); Tue, 30 Nov 2010 13:44:28 -0500 Received: from mail.szarvas.hu (localhost [127.0.0.1]) by phoenix3.szarvasnet.hu (Postfix) with SMTP id 5267C4DC013; Tue, 30 Nov 2010 19:44:27 +0100 (CET) Received: from localhost.localdomain (catvpool-576570d8.szarvasnet.hu [87.101.112.216]) by phoenix3.szarvasnet.hu (Postfix) with ESMTPA id D7C2F270001; Tue, 30 Nov 2010 19:44:26 +0100 (CET) From: Gabor Juhos To: Dmitry Torokhov Cc: Ben Gardiner , linux-input@vger.kernel.org, Ralf Baechle , Kevin Hilman , nsekhar@ti.com Subject: [PATCH 5/8] input: gpio_keys_polled: precompute threshold value in the probe routine Date: Tue, 30 Nov 2010 19:44:20 +0100 Message-Id: <1291142663-1011-6-git-send-email-juhosg@openwrt.org> X-Mailer: git-send-email 1.7.2.1 In-Reply-To: <4CF541ED.80905@openwrt.org> References: <4CF541ED.80905@openwrt.org> X-VBMS: A11DC2126E7 | phoenix3 | 127.0.0.1 | | | Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 30 Nov 2010 18:44:31 +0000 (UTC) diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c index c9e0d1c..5af0be9 100644 --- a/drivers/input/keyboard/gpio_keys_polled.c +++ b/drivers/input/keyboard/gpio_keys_polled.c @@ -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); }