Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: tsc2007 - convert to GPIO descriptors

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>
Link: https://lore.kernel.org/r/20210314210951.645783-1-andy.shevchenko@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Andy Shevchenko and committed by
Dmitry Torokhov
cee451c9 ea16ef96

+11 -8
+3 -1
drivers/input/touchscreen/tsc2007.h
··· 19 19 #ifndef _TSC2007_H 20 20 #define _TSC2007_H 21 21 22 + struct gpio_desc; 23 + 22 24 #define TSC2007_MEASURE_TEMP0 (0x0 << 4) 23 25 #define TSC2007_MEASURE_AUX (0x2 << 4) 24 26 #define TSC2007_MEASURE_TEMP1 (0x4 << 4) ··· 71 69 int fuzzy; 72 70 int fuzzz; 73 71 74 - unsigned int gpio; 72 + struct gpio_desc *gpiod; 75 73 int irq; 76 74 77 75 wait_queue_head_t wait;
+8 -7
drivers/input/touchscreen/tsc2007_core.c
··· 19 19 20 20 #include <linux/module.h> 21 21 #include <linux/slab.h> 22 + #include <linux/gpio/consumer.h> 22 23 #include <linux/input.h> 23 24 #include <linux/interrupt.h> 24 25 #include <linux/i2c.h> 25 26 #include <linux/of_device.h> 26 - #include <linux/of_gpio.h> 27 27 #include <linux/platform_data/tsc2007.h> 28 28 #include "tsc2007.h" 29 29 ··· 226 226 struct i2c_client *client = to_i2c_client(dev); 227 227 struct tsc2007 *ts = i2c_get_clientdata(client); 228 228 229 - return !gpio_get_value(ts->gpio); 229 + return gpiod_get_value(ts->gpiod); 230 230 } 231 231 232 232 static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts) ··· 266 266 return -EINVAL; 267 267 } 268 268 269 - ts->gpio = of_get_gpio(np, 0); 270 - if (gpio_is_valid(ts->gpio)) 269 + ts->gpiod = devm_gpiod_get_optional(&client->dev, NULL, GPIOD_IN); 270 + if (IS_ERR(ts->gpiod)) 271 + return PTR_ERR(ts->gpiod); 272 + 273 + if (ts->gpiod) 271 274 ts->get_pendown_state = tsc2007_get_pendown_state_gpio; 272 275 else 273 - dev_warn(&client->dev, 274 - "GPIO not specified in DT (of_get_gpio returned %d)\n", 275 - ts->gpio); 276 + dev_warn(&client->dev, "Pen down GPIO not specified in DT\n"); 276 277 277 278 return 0; 278 279 }