linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: linux-input@vger.kernel.org
Subject: Re: [PATCH v1 1/2] Input: tsc2007 - convert to GPIO descriptors
Date: Sun, 7 Mar 2021 14:57:38 -0800	[thread overview]
Message-ID: <YEVaYiA9Faylr9il@google.com> (raw)
In-Reply-To: <20210307220549.354263-1-andy.shevchenko@gmail.com>

Hi Andy,

On Mon, Mar 08, 2021 at 12:05:48AM +0200, Andy Shevchenko wrote:
> @@ -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);

This is not correct. gpio_get_value() is raw polarity vs
gpiod_get_value() using logical active/inactive, and tsc2007 GPIO lines
are active low. The negation must be dropped after switching to GPIOD
API.

>  }
>  
>  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);

GPIO is definitely not optional in DT case, at least in the way the
driver written right now.

> +	if (IS_ERR(ts->gpiod))
> +		return PTR_ERR(ts->gpiod);
> +
> +	ts->get_pendown_state = tsc2007_get_pendown_state_gpio;
>  
>  	return 0;
>  }
> -- 
> 2.30.1
> 

Thanks.

-- 
Dmitry

  parent reply	other threads:[~2021-03-07 22:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-07 22:05 [PATCH v1 1/2] Input: tsc2007 - convert to GPIO descriptors Andy Shevchenko
2021-03-07 22:05 ` [PATCH v1 2/2] Input: tsc2007 - make use of device properties Andy Shevchenko
2021-03-07 22:57 ` Dmitry Torokhov [this message]
2021-03-08  9:10   ` [PATCH v1 1/2] Input: tsc2007 - convert to GPIO descriptors Andy Shevchenko
2021-03-08 19:29     ` Dmitry Torokhov
2021-03-08 21:04       ` Andy Shevchenko
2021-03-08 21:12         ` Dmitry Torokhov

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=YEVaYiA9Faylr9il@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).