From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: linux-input@vger.kernel.org
Subject: Re: [PATCH v2 1/2] Input: tsc2007 - convert to GPIO descriptors
Date: Mon, 8 Mar 2021 14:27:45 -0800 [thread overview]
Message-ID: <YEak4dbMINWNf2rr@google.com> (raw)
In-Reply-To: <20210308215508.399362-1-andy.shevchenko@gmail.com>
On Mon, Mar 08, 2021 at 11:55:07PM +0200, Andy Shevchenko wrote:
> This converts the driver to use GPIO descriptors.
>
> Note that it now uses logical polarity and thus nagation has been dropped.
>
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> ---
> v2: dropped negation (Dmitry)
> drivers/input/touchscreen/tsc2007.h | 4 +++-
> drivers/input/touchscreen/tsc2007_core.c | 17 ++++++++---------
> 2 files changed, 11 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/input/touchscreen/tsc2007.h b/drivers/input/touchscreen/tsc2007.h
> index 91c60bf6dcaf..69b08dd6c8df 100644
> --- a/drivers/input/touchscreen/tsc2007.h
> +++ b/drivers/input/touchscreen/tsc2007.h
> @@ -19,6 +19,8 @@
> #ifndef _TSC2007_H
> #define _TSC2007_H
>
> +struct gpio_desc;
> +
> #define TSC2007_MEASURE_TEMP0 (0x0 << 4)
> #define TSC2007_MEASURE_AUX (0x2 << 4)
> #define TSC2007_MEASURE_TEMP1 (0x4 << 4)
> @@ -69,7 +71,7 @@ struct tsc2007 {
> int fuzzy;
> int fuzzz;
>
> - unsigned int gpio;
> + struct gpio_desc *gpiod;
> int irq;
>
> wait_queue_head_t wait;
> diff --git a/drivers/input/touchscreen/tsc2007_core.c b/drivers/input/touchscreen/tsc2007_core.c
> index 3b80abfc1eca..eecd10effb56 100644
> --- a/drivers/input/touchscreen/tsc2007_core.c
> +++ b/drivers/input/touchscreen/tsc2007_core.c
> @@ -19,11 +19,11 @@
>
> #include <linux/module.h>
> #include <linux/slab.h>
> +#include <linux/gpio/consumer.h>
> #include <linux/input.h>
> #include <linux/interrupt.h>
> #include <linux/i2c.h>
> #include <linux/of_device.h>
> -#include <linux/of_gpio.h>
> #include <linux/platform_data/tsc2007.h>
> #include "tsc2007.h"
>
> @@ -226,11 +226,12 @@ static int tsc2007_get_pendown_state_gpio(struct device *dev)
> struct i2c_client *client = to_i2c_client(dev);
> struct tsc2007 *ts = i2c_get_clientdata(client);
>
> - return !gpio_get_value(ts->gpio);
> + return gpiod_get_value(ts->gpiod);
> }
>
> static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts)
> {
> + struct device *dev = &client->dev;
> struct device_node *np = client->dev.of_node;
> u32 val32;
> u64 val64;
> @@ -266,13 +267,11 @@ static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts)
> return -EINVAL;
> }
>
> - ts->gpio = of_get_gpio(np, 0);
> - if (gpio_is_valid(ts->gpio))
> - ts->get_pendown_state = tsc2007_get_pendown_state_gpio;
> - else
> - dev_warn(&client->dev,
> - "GPIO not specified in DT (of_get_gpio returned %d)\n",
> - ts->gpio);
> + ts->gpiod = devm_gpiod_get_optional(dev, NULL, GPIOD_IN);
> + if (IS_ERR(ts->gpiod))
> + return PTR_ERR(ts->gpiod);
> +
> + ts->get_pendown_state = tsc2007_get_pendown_state_gpio;
OK, I know what my concern was here. You are now assigning
ts->get_pendown_state unconditionally, and with ts->gpiod being NULL it
will always return false, whereas the old code would skip setting
ts->get_pendown_state when GPIO is not available, and the driver would
assume that on interrupt the pen is actually down.
Thanks.
--
Dmitry
next prev parent reply other threads:[~2021-03-08 22:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-08 21:55 [PATCH v2 1/2] Input: tsc2007 - convert to GPIO descriptors Andy Shevchenko
2021-03-08 21:55 ` [PATCH v2 2/2] Input: tsc2007 - make use of device properties Andy Shevchenko
2021-03-08 22:27 ` Dmitry Torokhov [this message]
2021-03-14 21:11 ` [PATCH v2 1/2] Input: tsc2007 - convert to GPIO descriptors Andy Shevchenko
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=YEak4dbMINWNf2rr@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=andy.shevchenko@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).