From: Dmitry Torokhov <dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: "Rafael J. Wysocki" <rjw-LthD3rsA81gm4RdzfppkhA@public.gmane.org>
Cc: Linux Kernel Mailing List
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Greg Kroah-Hartman
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
Mika Westerberg
<mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
ACPI Devel Maling List
<linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Aaron Lu <aaron.lu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Linus Walleij
<linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Alexandre Courbot
<gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Bryan Wu <cooloney-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Grant Likely
<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
Darren Hart <dvhart-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
Subject: Re: [PATCH 09/12] input: gpio_keys_polled - Add support for GPIO descriptors
Date: Tue, 7 Oct 2014 10:29:47 -0700 [thread overview]
Message-ID: <20141007172947.GH16469@dtor-ws> (raw)
In-Reply-To: <1740633.d3tSWZ2Q0u-sKB8Sp2ER+y1GS7QM15AGw@public.gmane.org>
On Tue, Oct 07, 2014 at 02:16:47AM +0200, Rafael J. Wysocki wrote:
> From: Aaron Lu <aaron.lu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>
> GPIO descriptors are the preferred way over legacy GPIO numbers
> nowadays. Convert the driver to use GPIO descriptors internally but
> still allow passing legacy GPIO numbers from platform data to support
> existing platforms.
>
> Signed-off-by: Aaron Lu <aaron.lu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Mika Westerberg <mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> Acked-by: Alexandre Courbot <acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> Reviewed-by: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Acked-by: Dmitry Torokhov <dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
> drivers/input/keyboard/gpio_keys_polled.c | 39 +++++++++++++++++++++----------
> include/linux/gpio_keys.h | 3 +++
> 2 files changed, 30 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c
> index 432d363..b7a514c 100644
> --- a/drivers/input/keyboard/gpio_keys_polled.c
> +++ b/drivers/input/keyboard/gpio_keys_polled.c
> @@ -23,6 +23,7 @@
> #include <linux/ioport.h>
> #include <linux/platform_device.h>
> #include <linux/gpio.h>
> +#include <linux/gpio/consumer.h>
> #include <linux/gpio_keys.h>
> #include <linux/of.h>
> #include <linux/of_platform.h>
> @@ -51,15 +52,14 @@ static void gpio_keys_polled_check_state(struct input_dev *input,
> int state;
>
> if (bdata->can_sleep)
> - state = !!gpio_get_value_cansleep(button->gpio);
> + state = !!gpiod_get_value_cansleep(button->gpiod);
> else
> - state = !!gpio_get_value(button->gpio);
> + state = !!gpiod_get_value(button->gpiod);
>
> if (state != bdata->last_state) {
> unsigned int type = button->type ?: EV_KEY;
>
> - input_event(input, type, button->code,
> - !!(state ^ button->active_low));
> + input_event(input, type, button->code, state);
> input_sync(input);
> bdata->count = 0;
> bdata->last_state = state;
> @@ -259,7 +259,6 @@ static int 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;
>
> if (button->wakeup) {
> @@ -267,15 +266,31 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
> return -EINVAL;
> }
>
> - error = devm_gpio_request_one(&pdev->dev, gpio, GPIOF_IN,
> - button->desc ? : DRV_NAME);
> - if (error) {
> - dev_err(dev, "unable to claim gpio %u, err=%d\n",
> - gpio, error);
> - return error;
> + /*
> + * Legacy GPIO number so request the GPIO here and
> + * convert it to descriptor.
> + */
> + if (!button->gpiod && gpio_is_valid(button->gpio)) {
> + unsigned flags = 0;
> +
> + if (button->active_low)
> + flags |= GPIOF_ACTIVE_LOW;
> +
> + error = devm_gpio_request_one(&pdev->dev, button->gpio,
> + flags, button->desc ? : DRV_NAME);
> + if (error) {
> + dev_err(dev, "unable to claim gpio %u, err=%d\n",
> + button->gpio, error);
> + return error;
> + }
> +
> + button->gpiod = gpio_to_desc(button->gpio);
> }
>
> - bdata->can_sleep = gpio_cansleep(gpio);
> + if (IS_ERR(button->gpiod))
> + return PTR_ERR(button->gpiod);
> +
> + bdata->can_sleep = gpiod_cansleep(button->gpiod);
> bdata->last_state = -1;
> bdata->threshold = DIV_ROUND_UP(button->debounce_interval,
> pdata->poll_interval);
> diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h
> index 8b62246..ee2d8c6 100644
> --- a/include/linux/gpio_keys.h
> +++ b/include/linux/gpio_keys.h
> @@ -2,6 +2,7 @@
> #define _GPIO_KEYS_H
>
> struct device;
> +struct gpio_desc;
>
> /**
> * struct gpio_keys_button - configuration parameters
> @@ -17,6 +18,7 @@ struct device;
> * disable button via sysfs
> * @value: axis value for %EV_ABS
> * @irq: Irq number in case of interrupt keys
> + * @gpiod: GPIO descriptor
> */
> struct gpio_keys_button {
> unsigned int code;
> @@ -29,6 +31,7 @@ struct gpio_keys_button {
> bool can_disable;
> int value;
> unsigned int irq;
> + struct gpio_desc *gpiod;
> };
>
> /**
> --
> 1.9.3
>
>
--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-10-07 17:29 UTC|newest]
Thread overview: 104+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-07 0:10 [PATCH v4 00/13] Add ACPI _DSD and unified device properties support Rafael J. Wysocki
2014-10-07 0:12 ` [PATCH 01/13] ACPI: Add support for device specific properties Rafael J. Wysocki
2014-10-13 12:47 ` Grant Likely
2014-10-07 0:12 ` [PATCH 02/13] Driver core: Unified device properties interface for platform firmware Rafael J. Wysocki
2014-10-07 0:13 ` [PATCH 03/13] ACPI: Allow drivers to match using Device Tree compatible property Rafael J. Wysocki
2014-10-14 13:38 ` Grant Likely
2014-10-07 0:14 ` [PATCH 04/13] ACPI: Document ACPI device specific properties Rafael J. Wysocki
2014-10-13 12:41 ` Grant Likely
2014-10-14 9:42 ` Mika Westerberg
2014-10-07 0:14 ` [PATCH 05/13] misc: at25: Make use of device property API Rafael J. Wysocki
2014-10-07 9:10 ` Geert Uytterhoeven
2014-10-07 9:32 ` Mika Westerberg
2014-10-07 0:15 ` [PATCH 06/13] gpio / ACPI: Add support for _DSD device properties Rafael J. Wysocki
2014-10-14 13:44 ` Grant Likely
2014-10-15 8:46 ` Mika Westerberg
2014-10-07 0:15 ` [PATCH 07/13] gpio: sch: Consolidate core and resume banks Rafael J. Wysocki
2014-10-07 0:16 ` [PATCH 08/13] leds: leds-gpio: Add support for GPIO descriptors Rafael J. Wysocki
[not found] ` <2660541.BycO7TFnA2-sKB8Sp2ER+y1GS7QM15AGw@public.gmane.org>
2014-10-07 0:16 ` [PATCH 09/12] input: gpio_keys_polled - " Rafael J. Wysocki
[not found] ` <1740633.d3tSWZ2Q0u-sKB8Sp2ER+y1GS7QM15AGw@public.gmane.org>
2014-10-07 17:29 ` Dmitry Torokhov [this message]
2014-10-07 0:17 ` [PATCH 10/13] Driver core: Child node properties for devices Rafael J. Wysocki
2014-10-07 0:18 ` [PATCH 11/13] gpio: Support for unified device properties interface Rafael J. Wysocki
2014-10-07 10:22 ` Alexandre Courbot
2014-10-07 10:40 ` Mika Westerberg
2014-10-07 10:52 ` Alexandre Courbot
2014-10-08 0:09 ` Rafael J. Wysocki
2014-10-08 2:55 ` Alexandre Courbot
2014-10-08 14:01 ` Rafael J. Wysocki
2014-10-07 0:18 ` [PATCH 12/13] leds: leds-gpio: Make use of device property API Rafael J. Wysocki
2014-10-08 14:04 ` Rafael J. Wysocki
[not found] ` <2960802.kPr8UT7PvT-sKB8Sp2ER+y1GS7QM15AGw@public.gmane.org>
2014-10-08 17:47 ` Bryan Wu
2014-10-08 22:02 ` Rafael J. Wysocki
2014-10-07 0:19 ` [PATCH 13/13] input: gpio_keys_polled - " Rafael J. Wysocki
2014-10-07 17:30 ` Dmitry Torokhov
2014-10-07 0:39 ` [PATCH v4 00/13] Add ACPI _DSD and unified device properties support Rafael J. Wysocki
2014-10-07 2:28 ` Greg Kroah-Hartman
2014-10-15 13:04 ` David Woodhouse
2014-10-15 13:15 ` Mark Rutland
2014-10-15 13:28 ` David Woodhouse
2014-10-15 13:42 ` Mark Rutland
2014-10-15 14:08 ` David Woodhouse
2014-10-15 14:46 ` Darren Hart
2014-10-15 15:11 ` David Woodhouse
2014-10-15 15:17 ` Mark Rutland
2014-10-15 15:43 ` Darren Hart
2014-10-16 10:05 ` Rafael J. Wysocki
2014-10-16 14:55 ` David Woodhouse
2014-10-18 8:37 ` Grant Likely
2014-10-18 8:39 ` Grant Likely
2014-10-18 8:35 ` Grant Likely
2014-10-21 21:50 ` [PATCH v4 00/13] Add ACPI _DSD and unified device properties? support Darren Hart
2015-01-14 18:42 ` [PATCH v4 00/13] Add ACPI _DSD and unified device properties support David Woodhouse
2015-01-15 9:12 ` Rafael J. Wysocki
2014-10-17 12:01 ` [PATCH v5 00/12] " Rafael J. Wysocki
2014-10-17 12:03 ` [PATCH v5 01/12] ACPI: Add support for device specific properties Rafael J. Wysocki
2014-10-17 12:04 ` [PATCH v5 02/12] Driver core: Unified device properties interface for platform firmware Rafael J. Wysocki
2014-10-20 0:07 ` [Update][PATCH " Rafael J. Wysocki
2014-10-17 12:05 ` [PATCH v5 03/12] ACPI: Allow drivers to match using Device Tree compatible property Rafael J. Wysocki
2014-10-20 14:05 ` Grant Likely
2014-10-20 22:19 ` Rafael J. Wysocki
2014-10-17 12:07 ` [PATCH v5 04/12] misc: at25: Make use of device property API Rafael J. Wysocki
2014-10-17 12:09 ` [PATCH v5 05/12] gpio / ACPI: Add support for _DSD device properties Rafael J. Wysocki
2014-10-17 12:10 ` [PATCH v5 06/12] gpio: sch: Consolidate core and resume banks Rafael J. Wysocki
2014-10-17 12:11 ` [PATCH v5 07/12] leds: leds-gpio: Add support for GPIO descriptors Rafael J. Wysocki
2014-10-28 15:26 ` Linus Walleij
2014-10-28 21:56 ` Rafael J. Wysocki
2014-10-29 8:53 ` Mika Westerberg
2014-10-30 15:40 ` Linus Walleij
2014-10-30 16:15 ` Mika Westerberg
2014-10-31 9:41 ` Linus Walleij
2014-10-31 9:55 ` Mika Westerberg
2014-10-30 15:34 ` Linus Walleij
2014-10-17 12:12 ` [PATCH v5 08/12] input: gpio_keys_polled - " Rafael J. Wysocki
2014-10-17 12:14 ` [PATCH v5 09/12] Driver core: Unified interface for firmware node properties Rafael J. Wysocki
2014-10-18 9:35 ` Arnd Bergmann
2014-10-19 23:30 ` Rafael J. Wysocki
2014-10-20 14:14 ` Arnd Bergmann
2014-10-18 14:55 ` Grant Likely
2014-10-19 23:46 ` Rafael J. Wysocki
[not found] ` <7821406.D7i8JfDpzX-sKB8Sp2ER+y1GS7QM15AGw@public.gmane.org>
2014-10-20 14:18 ` Grant Likely
2014-10-20 22:14 ` Rafael J. Wysocki
2014-10-20 14:19 ` Arnd Bergmann
2014-10-20 14:55 ` Grant Likely
2014-10-20 22:22 ` Rafael J. Wysocki
2014-10-19 22:14 ` Greg Kroah-Hartman
2014-10-19 23:31 ` Rafael J. Wysocki
2014-10-20 0:15 ` [Update][PATCH " Rafael J. Wysocki
2014-10-17 12:16 ` [PATCH v5 10/12] gpio: Support for unified device properties interface Rafael J. Wysocki
2014-10-17 18:09 ` Arnd Bergmann
2014-10-18 9:47 ` Arnd Bergmann
2014-10-19 23:58 ` Rafael J. Wysocki
2014-10-20 14:22 ` Arnd Bergmann
2014-10-20 6:12 ` Alexandre Courbot
2014-10-20 14:26 ` Arnd Bergmann
2014-10-17 12:17 ` [PATCH v5 11/12] leds: leds-gpio: Make use of device property API Rafael J. Wysocki
2014-10-17 12:18 ` [PATCH v5 12/12] input: gpio_keys_polled - " Rafael J. Wysocki
2014-10-17 12:22 ` [PATCH v5 00/12] Add ACPI _DSD and unified device properties support Rafael J. Wysocki
2014-10-17 15:40 ` Greg Kroah-Hartman
2014-10-17 19:23 ` Darren Hart
2014-10-17 21:49 ` Rafael J. Wysocki
2014-10-19 22:14 ` Greg Kroah-Hartman
2014-10-17 18:04 ` Arnd Bergmann
2014-10-17 22:50 ` Rafael J. Wysocki
2014-10-18 8:49 ` Grant Likely
2014-10-19 23:32 ` Rafael J. Wysocki
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=20141007172947.GH16469@dtor-ws \
--to=dmitry.torokhov-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=aaron.lu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=arnd-r2nGTMty4D4@public.gmane.org \
--cc=cooloney-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=dvhart-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=rjw-LthD3rsA81gm4RdzfppkhA@public.gmane.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).