On Tue, Mar 16, 2021 at 2:11 AM Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx> wrote: > > Hi Andy, > > On Sun, Mar 14, 2021 at 11:09:50PM +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@xxxxxxxxx> > > --- > > v3: left ->get_pendown_state() assignment conditionally (Dmitry) > > drivers/input/touchscreen/tsc2007.h | 4 +++- > > drivers/input/touchscreen/tsc2007_core.c | 12 ++++++++---- > > 2 files changed, 11 insertions(+), 5 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..e4ab5962ddd4 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,8 +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->gpiod = devm_gpiod_get_optional(dev, NULL, GPIOD_IN); > > + if (IS_ERR(ts->gpiod)) > > + return PTR_ERR(ts->gpiod); > > + > > + if (ts->gpiod) > > ts->get_pendown_state = tsc2007_get_pendown_state_gpio; > > else > > dev_warn(&client->dev, > > This does not really compile as the warning still refers to the legacy > gpio number. Oops, sorry, I was under the impression that I have compiled it, but I realized that I have checked only ld-version.sh bugfix (I have non-English locale and builds of v5.12-rcX were failing, out of curiosity it's tracked here: https://bugzilla.kernel.org/show_bug.cgi?id=212105). > I fixed it up locally and applied, thank you. Thanks! -- With Best Regards, Andy Shevchenko