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

Input: cy8ctmg110_ts - switch to using gpiod API

Instead of legacy gpio API let's use newer gpiod API. This also allows us
to get rid of platform data.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210603043726.3793876-7-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+19 -28
+19 -28
drivers/input/touchscreen/cy8ctmg110_ts.c
··· 7 7 * Some cleanups by Alan Cox <alan@linux.intel.com> 8 8 */ 9 9 10 - #include <linux/module.h> 11 - #include <linux/kernel.h> 12 - #include <linux/input.h> 13 - #include <linux/slab.h> 14 - #include <linux/interrupt.h> 15 - #include <linux/io.h> 16 10 #include <linux/i2c.h> 17 - #include <linux/gpio.h> 18 - #include <linux/input/cy8ctmg110_pdata.h> 11 + #include <linux/input.h> 12 + #include <linux/interrupt.h> 13 + #include <linux/gpio/consumer.h> 14 + #include <linux/kernel.h> 15 + #include <linux/module.h> 16 + #include <linux/slab.h> 19 17 #include <asm/byteorder.h> 20 18 21 19 #define CY8CTMG110_DRIVER_NAME "cy8ctmg110" ··· 44 46 struct input_dev *input; 45 47 char phys[32]; 46 48 struct i2c_client *client; 47 - int reset_pin; 49 + struct gpio_desc *reset_gpio; 48 50 }; 49 51 50 52 /* 51 53 * cy8ctmg110_power is the routine that is called when touch hardware 52 - * will powered off or on. 54 + * is being powered off or on. When powering on this routine de-asserts 55 + * the RESET line, when powering off reset line is asserted. 53 56 */ 54 57 static void cy8ctmg110_power(struct cy8ctmg110 *ts, bool poweron) 55 58 { 56 - if (ts->reset_pin) 57 - gpio_direction_output(ts->reset_pin, 1 - poweron); 59 + if (ts->reset_gpio) 60 + gpiod_set_value_cansleep(ts->reset_gpio, !poweron); 58 61 } 59 62 60 63 static int cy8ctmg110_write_regs(struct cy8ctmg110 *tsc, unsigned char reg, ··· 171 172 static int cy8ctmg110_probe(struct i2c_client *client, 172 173 const struct i2c_device_id *id) 173 174 { 174 - const struct cy8ctmg110_pdata *pdata = dev_get_platdata(&client->dev); 175 175 struct cy8ctmg110 *ts; 176 176 struct input_dev *input_dev; 177 177 int err; 178 - 179 - /* No pdata no way forward */ 180 - if (pdata == NULL) { 181 - dev_err(&client->dev, "no pdata\n"); 182 - return -ENODEV; 183 - } 184 178 185 179 if (!i2c_check_functionality(client->adapter, 186 180 I2C_FUNC_SMBUS_READ_WORD_DATA)) ··· 189 197 190 198 ts->client = client; 191 199 ts->input = input_dev; 192 - ts->reset_pin = pdata->reset_pin; 193 200 194 201 snprintf(ts->phys, sizeof(ts->phys), 195 202 "%s/input0", dev_name(&client->dev)); ··· 203 212 input_set_abs_params(input_dev, ABS_Y, 204 213 CY8CTMG110_Y_MIN, CY8CTMG110_Y_MAX, 4, 0); 205 214 206 - if (ts->reset_pin) { 207 - err = devm_gpio_request(&client->dev, ts->reset_pin, NULL); 208 - if (err) { 209 - dev_err(&client->dev, 210 - "Unable to request GPIO pin %d.\n", 211 - ts->reset_pin); 212 - return err; 213 - } 215 + /* Request and assert reset line */ 216 + ts->reset_gpio = devm_gpiod_get_optional(&client->dev, NULL, 217 + GPIOD_OUT_HIGH); 218 + if (IS_ERR(ts->reset_gpio)) { 219 + err = PTR_ERR(ts->reset_gpio); 220 + dev_err(&client->dev, 221 + "Unable to request reset GPIO: %d\n", err); 222 + return err; 214 223 } 215 224 216 225 cy8ctmg110_power(ts, true);