linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Keith Mok <ek9852@gmail.com>
Cc: dmitry.torokhov@gmail.com, dtor@mail.ru,
	linux-input@vger.kernel.org, Jiri Slaby <jirislaby@gmail.com>
Subject: Re: [PATCH] input: add debouncing for generic gpio input device gpio_key.c
Date: Mon, 3 Mar 2008 14:28:57 -0800	[thread overview]
Message-ID: <20080303142857.5f177f1c.akpm@linux-foundation.org> (raw)
In-Reply-To: <47C10987.9020804@gmail.com>

On Sun, 24 Feb 2008 14:07:03 +0800
Keith Mok <ek9852@gmail.com> wrote:

> This patch add debouncing support for the generic gpio input device, since debouncing is most likely to happen.
> 
> Comments welcome.
> 
> Signed-off-by: Keith Mok <ek9852@gmail.com>
> ---
> Keith Mok
> 
> 
> diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
> index 6a9ca4b..79b460e 100644
> --- a/drivers/input/keyboard/gpio_keys.c
> +++ b/drivers/input/keyboard/gpio_keys.c
> @@ -26,26 +26,36 @@
>  
>  #include <asm/gpio.h>
>  
> +static void do_gpio_keys_tasklet(unsigned long);
> +static void do_gpio_keys_timer(unsigned long);
> +
> +static struct timer_list gpio_keys_timer;

DEFINE_TIMER() could be used here.  Then we can remove the runtime
setup_timer().

> +DECLARE_TASKLET_DISABLED(gpio_keys_tasklet, do_gpio_keys_tasklet, 0);
> +static spinlock_t suspend_lock;

Please use DEFINE_SPINLOCK(), then remove the runtime spin_lock_init().

> +static void do_gpio_keys_tasklet(unsigned long data)
> +{
> +	int pressed;
> +	int i;
> +	struct platform_device *pdev = (struct platform_device*)data;
> +	struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
> +	struct input_dev *input = platform_get_drvdata(pdev);
> +
> +	/* check for any changes */
> +	pressed = 0;
> +	for (i = 0; i < pdata->nbuttons; i++) {
> +		struct gpio_keys_button *button = &pdata->buttons[i];
> +		int gpio = button->gpio;
> +
> +		unsigned int type = button->type ?: EV_KEY;
> +		int state = (gpio_get_value(gpio) ? 1 : 0) ^ button->active_low;
> +
> +		input_event(input, type, button->code, !!state);
> +		pressed |= !!state;
> +		input_sync(input);
> +	}
> +	if(pressed) {

Please always pass patches through scripts/checkpatch.pl.



      reply	other threads:[~2008-03-03 22:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-24  6:07 [PATCH] input: add debouncing for generic gpio input device gpio_key.c Keith Mok
2008-03-03 22:28 ` Andrew Morton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080303142857.5f177f1c.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=dtor@mail.ru \
    --cc=ek9852@gmail.com \
    --cc=jirislaby@gmail.com \
    --cc=linux-input@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).