From patchwork Wed Nov 24 21:01:35 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Gardiner X-Patchwork-Id: 354301 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 oAOL1iUS023014 for ; Wed, 24 Nov 2010 21:01:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756586Ab0KXVBo (ORCPT ); Wed, 24 Nov 2010 16:01:44 -0500 Received: from na3sys009aog113.obsmtp.com ([74.125.149.209]:34995 "HELO na3sys009aog113.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1756333Ab0KXVBo (ORCPT ); Wed, 24 Nov 2010 16:01:44 -0500 Received: from source ([209.85.213.49]) by na3sys009aob113.postini.com ([74.125.148.12]) with SMTP ID DSNKTO19N3CKEA5hCrRfKmxMxoM1gPkp+6/+@postini.com; Wed, 24 Nov 2010 13:01:44 PST Received: by mail-yw0-f49.google.com with SMTP id 7so110886ywf.8 for ; Wed, 24 Nov 2010 13:01:43 -0800 (PST) Received: by 10.151.11.2 with SMTP id o2mr1647911ybi.387.1290632503736; Wed, 24 Nov 2010 13:01:43 -0800 (PST) Received: from localhost.localdomain ([206.191.47.130]) by mx.google.com with ESMTPS id v8sm65841yba.14.2010.11.24.13.01.42 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 24 Nov 2010 13:01:43 -0800 (PST) From: Ben Gardiner To: Gabor Juhos Cc: linux-input@vger.kernel.org Subject: [PATCH WIP 1/6] fixup gpio_buttons: use the same debounce_interval member found in gpio_key to obtain a threshold count based on polling interval Date: Wed, 24 Nov 2010 16:01:35 -0500 Message-Id: <08372c879762c2b1c2accd013318ffb6765f806c.1290631852.git.bengardiner@nanometrics.ca> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: <1290524800-21419-10-git-send-email-juhosg@openwrt.org> 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]); Wed, 24 Nov 2010 21:01:48 +0000 (UTC) diff --git a/drivers/input/misc/gpio_buttons.c b/drivers/input/misc/gpio_buttons.c index 51288a3..f42906c 100644 --- a/drivers/input/misc/gpio_buttons.c +++ b/drivers/input/misc/gpio_buttons.c @@ -68,13 +68,16 @@ static void gpio_buttons_poll(struct input_polled_dev *dev) struct gpio_buttons_dev *bdev = dev->private; struct gpio_buttons_platform_data *pdata = bdev->pdata; struct input_dev *input = dev->input; - int i; + int i, threshold; for (i = 0; i < bdev->pdata->nbuttons; i++) { struct gpio_button *button = &pdata->buttons[i]; struct gpio_button_data *bdata = &bdev->data[i]; - if (bdata->count < button->threshold) + threshold = round_up(button->debounce_interval, + pdata->poll_interval) / + pdata->poll_interval; + if (bdata->count < threshold) bdata->count++; else gpio_buttons_check_state(input, button, bdata); diff --git a/include/linux/gpio_buttons.h b/include/linux/gpio_buttons.h index f85b993..c016f07 100644 --- a/include/linux/gpio_buttons.h +++ b/include/linux/gpio_buttons.h @@ -21,7 +21,7 @@ struct gpio_button { char *desc; /* button description */ int type; /* input event type (EV_KEY, EV_SW) */ int code; /* input event code (KEY_*, SW_*) */ - int threshold; /* count threshold */ + int debounce_interval; /* debounce ticks interval in msecs */ }; struct gpio_buttons_platform_data {