All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gabor Juhos <juhosg@openwrt.org>
To: Ben Gardiner <bengardiner@nanometrics.ca>
Cc: Ralf Baechle <ralf@linux-mips.org>,
	linux-mips@linux-mips.org, kaloz@openwrt.org,
	"Luis R. Rodriguez" <lrodriguez@atheros.com>,
	Cliff Holden <Cliff.Holden@atheros.com>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Mike Frysinger <vapier@gentoo.org>,
	linux-input@vger.kernel.org
Subject: Re: [PATCH 09/18] input: add input driver for polled GPIO buttons
Date: Wed, 24 Nov 2010 19:54:59 +0100	[thread overview]
Message-ID: <4CED5F83.6070301@openwrt.org> (raw)
In-Reply-To: <AANLkTikQ=oen3jmz=BfY7y=s6Qo7R8DQ1-79puby-Snt@mail.gmail.com>

Hi Ben,

> <...>
> I've tested this driver with the da850-evm pushbuttons and switches
> connected to i2c gpio expanders. It works well. The changes to the
> patch series were straightforward: .config, "gpio-keys" ->
> "gpio-buttons", struct gpio_key -> struct gpio_button etc.
> 
> I do have some comments about this patch. But the new driver is
> functional as-is.
> 
> Tested-by: Ben Gardiner <bengardiner@nanometrics.ca>

Thanks!

>><...>
> 
> Since the new gpio_buttons.c driver presents the same input event
> device as the gpio_keys.c driver, I think it should also be a
> drivers/input/keys device.

Makes sense.

> 
>>  [...]
>> diff --git a/drivers/input/misc/gpio_buttons.c b/drivers/input/misc/gpio_buttons.c
> 
> When I was converting the da850-evm platform code to use the new
> driver I felt that the changes did not indicate a switch to a polled
> driver as seems to be the intent with the introduction of a separate
> driver. All that was different in the platform code was 'button' where
> there use to be 'key' and button does not itself convey the knowledge
> that it is a polled input device.
> 
> I know names of drivers can be contentions but I will propose
> regardless that this driver be called gpio-polled-keys /
> gpio_polled_keys.c

I agree, this would be more informative.

>> <...>
>> +       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)
>> +                       bdata->count++;
>> +               else
>> +                       gpio_buttons_check_state(input, button, bdata);
> 
> I think that a count-theshold can still be performed here, but using
> the debounce_interval and polling_interval field specified in the
> gpio_button and gpio_buttons_platform_data structures, respectively,
> to calculate a threshold value.

Good idea. We don't even have to compute a threshold value, we can use the
debounce_interval and poll_interval fields directly. I mean something similar to
this:

<...>
	if (bdata->interval < button->debounce_interval)
		bdata->interval += pdata->poll_interval;
	else
		gpio_buttons_check_state(input, button, bdata);
<...>

> In this way the gpio_button and gpio_keys_button structs are made more
> similar -- differing only in the presence of .wakeup in
> gpio_keys_button but not in gpio_button. Which may make it possible to
> re-use the gpio_keys_button structure.
> 
>> <...>
>> +struct gpio_button {
>> +       int     gpio;           /* GPIO line number */
>> +       int     active_low;
>> +       char    *desc;          /* button description */
>> +       int     type;           /* input event type (EV_KEY, EV_SW) */
>> +       int     code;           /* input event code (KEY_*, SW_*) */
>> +       int     threshold;      /* count threshold */
> 
> Could we instead use the existing struct gpio_keys_button; we could
> transform debounce_interval into a threshold as described above

Sure, we can use that...

> and add an error when a gpio_button_probe() sees a gpio_key with .wakeup ==
> TRUE?

I don't think we should check that, we can simply ignore this field. Maybe we
should add a comment to the .wakeup field to state that the polled driver does
not use that.

> It seems that this structure duplicates alot of the gpio_keys_button
> structure.

Yes, it is almost the same.

>> [...]
>> +struct gpio_buttons_platform_data {
>> +       struct gpio_button *buttons;
>> +       int     nbuttons;               /* number of buttons */
>> +       int     poll_interval;          /* polling interval */
>> +};
> 
> I think the units of poll_interval should be included in the comment.
> i.e. /* polling interval in msecs */

Yes, you are right. Additionally, we should move this structure into
gpio_keys.h, so we can get rid of the gpio_buttons.h file.

Thank you for the valuable comments. I will create a new patch.

Regards,
Gabor

  reply	other threads:[~2010-11-24 18:55 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-23 15:06 [PATCH 00/18] MIPS: initial support for the Atheros AR71XX/AR724X/AR913X SoCs Gabor Juhos
2010-11-23 15:06 ` [PATCH 01/18] MIPS: add initial support for the Atheros AR71XX/AR724X/AR931X SoCs Gabor Juhos
2010-11-23 15:06 ` [PATCH 02/18] MIPS: ath79: add GPIOLIB support Gabor Juhos
2010-11-23 15:06 ` [PATCH 03/18] MIPS: add generic support for multiple machines within a single kernel Gabor Juhos
2010-11-23 18:29   ` Arnaud Lacombe
2010-11-23 18:49     ` Luis R. Rodriguez
2010-11-23 18:51     ` Gabor Juhos
2010-11-23 19:06       ` Felix Fietkau
2010-11-23 19:20         ` David Daney
2010-11-23 22:12           ` Ralf Baechle
2010-11-23 15:06 ` [PATCH 04/18] MIPS: ath79: utilize the MIPS multi-machine support Gabor Juhos
2010-11-23 15:06 ` [PATCH 05/18] MIPS: ath79: add initial support for the Atheros PB44 reference board Gabor Juhos
2010-11-23 15:06 ` [PATCH 06/18] MIPS: ath79: add common GPIO LEDs device Gabor Juhos
2010-11-23 15:06 ` [PATCH 07/18] watchdog: add driver for the Atheros AR71XX/AR724X/AR913X SoCs Gabor Juhos
2010-11-23 15:06 ` [PATCH 08/18] MIPS: ath79: add common watchdog device Gabor Juhos
2010-11-23 15:06 ` [PATCH 09/18] input: add input driver for polled GPIO buttons Gabor Juhos
2010-11-23 19:24   ` Ben Gardiner
2010-11-24 17:24   ` Ben Gardiner
2010-11-24 17:24     ` Ben Gardiner
2010-11-24 18:54     ` Gabor Juhos [this message]
2010-11-24 20:28       ` Ben Gardiner
2010-11-24 21:01   ` [PATCH WIP 0/6] suggested changes to gpio_buttons driver Ben Gardiner
2010-11-24 21:01     ` [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 Ben Gardiner
2010-11-24 21:01     ` [PATCH WIP 2/6] fixup gpio_buttons: use existing gpio_keys_button structure instead of introducing new gpio_button structure Ben Gardiner
2010-11-24 21:01     ` [PATCH WIP 3/6] fixup gpio_buttons: detect and error-out if a button is requested for wakeup Ben Gardiner
2010-11-24 21:01     ` [PATCH WIP 4/6] fixup gpio_buttons: show units of poll_interval platform data member Ben Gardiner
2010-11-24 21:01     ` [PATCH WIP 5/6] fixup gpio_buttons: move gpio_buttons.c to drivers/input/keyboard from drivers/input/misc Ben Gardiner
2010-11-24 21:01     ` [PATCH WIP 6/6] fixup gpio_buttons : rename gpio-buttons / gpio_buttons to gpio-keys-polled / gpio_keys_polled Ben Gardiner
2010-11-30  7:56     ` [PATCH WIP 0/6] suggested changes to gpio_buttons driver Dmitry Torokhov
2010-11-30 10:30       ` Gabor Juhos
2010-11-30 14:29         ` Ben Gardiner
2010-11-30 18:26           ` Gabor Juhos
2010-11-30 18:44             ` [PATCH 0/8] input: gpio_keys_polled fixes Gabor Juhos
2010-11-30 22:16               ` Ben Gardiner
2010-12-05  9:11                 ` Gabor Juhos
2010-12-09  0:06                 ` Dmitry Torokhov
2010-12-09  8:07                   ` Gabor Juhos
2010-12-09 21:36                   ` Ben Gardiner
2010-11-30 18:44             ` [PATCH 1/8] input: gpio_keys_polled: add MODULE_ALIAS Gabor Juhos
2010-11-30 18:44             ` [PATCH 2/8] input: gpio_keys_polled: return -EINVAL if wakeup specified Gabor Juhos
2010-11-30 18:44             ` [PATCH 3/8] input: gpio_keys_polled: avoid possible division by zero Gabor Juhos
2010-11-30 18:44             ` [PATCH 4/8] input: gpio_keys_polled: use DIV_ROUND_UP to compute the threshold value Gabor Juhos
2010-11-30 18:44             ` [PATCH 5/8] input: gpio_keys_polled: precompute threshold value in the probe routine Gabor Juhos
2010-11-30 18:44             ` [PATCH 6/8] input: gpio_keys_polled: use tabs instead of spaces for indentation Gabor Juhos
2010-11-30 18:44             ` [PATCH 7/8] input: gpio_keys_polled: remove a local variable Gabor Juhos
2010-11-30 18:44             ` [PATCH 8/8] input: gpio_keys_polled: fix Kconfig help text Gabor Juhos
2010-12-01 22:53               ` Ferenc Wagner
2010-12-05  9:11                 ` Gabor Juhos
2010-12-05  9:34               ` [PATCH v2 " Gabor Juhos
2010-11-28  8:31   ` [PATCH 09/18] input: add input driver for polled GPIO buttons Dmitry Torokhov
2010-11-23 15:06 ` [PATCH 10/18] MIPS: ath79: add common GPIO buttons device Gabor Juhos
2010-11-23 15:06 ` [PATCH 11/18] spi: add SPI controller driver for the Atheros AR71XX/AR724X/AR913X SoCs Gabor Juhos
2010-11-23 15:06   ` Gabor Juhos
2010-11-23 15:06 ` [PATCH 12/18] MIPS: ath79: add common SPI controller device Gabor Juhos
2010-11-23 15:06 ` [PATCH 13/18] USB: ehci: add workaround for Synopsys HC bug Gabor Juhos
2010-11-23 15:06 ` [PATCH 14/18] USB: ehci: add bus glue for the Atheros AR71XX/AR724X/AR913X SoCs Gabor Juhos
2010-11-23 15:06 ` [PATCH 15/18] USB: ohci: add bus glue for the Atheros AR71XX/AR7240 SoCs Gabor Juhos
2010-11-23 15:06 ` [PATCH 16/18] MIPS: ath79: add common USB Host Controller device Gabor Juhos
2010-11-23 15:06 ` [PATCH 17/18] MIPS: ath79: add initial support for the Atheros AP81 reference board Gabor Juhos
2010-11-23 15:06 ` [PATCH 18/18] MIPS: ath79: add common WMAC device for AR913X based boards Gabor Juhos
2010-11-23 18:16 ` [PATCH 00/18] MIPS: initial support for the Atheros AR71XX/AR724X/AR913X SoCs Arnaud Lacombe
2010-11-23 18:18   ` Arnaud Lacombe

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=4CED5F83.6070301@openwrt.org \
    --to=juhosg@openwrt.org \
    --cc=Cliff.Holden@atheros.com \
    --cc=bengardiner@nanometrics.ca \
    --cc=dmitry.torokhov@gmail.com \
    --cc=kaloz@openwrt.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=lrodriguez@atheros.com \
    --cc=ralf@linux-mips.org \
    --cc=vapier@gentoo.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.