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

Input: tsc2005 - convert to gpiod

The GPIOD API can be used from boardcode, so that the DT check can be
removed. To avoid breaking existing boardcode, _optional() variant has been
chosen. For completely removing the DT check, the regulator has also been
made optional, so that it could be supplied from boardcode.

As a side-effect the patch fixes the after-probe reset GPIO state, so that
the device is not kept in reset state.

Signed-off-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Sebastian Reichel and committed by
Dmitry Torokhov
d257f298 80b46aa6

+20 -31
+20 -31
drivers/input/touchscreen/tsc2005.c
··· 30 30 #include <linux/delay.h> 31 31 #include <linux/pm.h> 32 32 #include <linux/of.h> 33 - #include <linux/of_gpio.h> 34 33 #include <linux/spi/spi.h> 35 34 #include <linux/spi/tsc2005.h> 36 35 #include <linux/regulator/consumer.h> 37 36 #include <linux/regmap.h> 37 + #include <linux/gpio/consumer.h> 38 38 39 39 /* 40 40 * The touchscreen interface operates as follows: ··· 180 180 181 181 struct regulator *vio; 182 182 183 - int reset_gpio; 183 + struct gpio_desc *reset_gpio; 184 184 void (*set_reset)(bool enable); 185 185 }; 186 186 ··· 318 318 319 319 static void tsc2005_set_reset(struct tsc2005 *ts, bool enable) 320 320 { 321 - if (ts->reset_gpio >= 0) 322 - gpio_set_value(ts->reset_gpio, enable); 321 + if (ts->reset_gpio) 322 + gpiod_set_value_cansleep(ts->reset_gpio, enable); 323 323 else if (ts->set_reset) 324 324 ts->set_reset(enable); 325 325 } ··· 611 611 ts->x_plate_ohm = x_plate_ohm; 612 612 ts->esd_timeout = esd_timeout; 613 613 614 - if (np) { 615 - ts->reset_gpio = of_get_named_gpio(np, "reset-gpios", 0); 616 - if (ts->reset_gpio == -EPROBE_DEFER) 617 - return ts->reset_gpio; 618 - if (ts->reset_gpio < 0) { 619 - dev_err(&spi->dev, "error acquiring reset gpio: %d\n", 620 - ts->reset_gpio); 621 - return ts->reset_gpio; 622 - } 623 - 624 - error = devm_gpio_request_one(&spi->dev, ts->reset_gpio, 0, 625 - "reset-gpios"); 626 - if (error) { 627 - dev_err(&spi->dev, "error requesting reset gpio: %d\n", 628 - error); 629 - return error; 630 - } 631 - 632 - ts->vio = devm_regulator_get(&spi->dev, "vio"); 633 - if (IS_ERR(ts->vio)) { 634 - error = PTR_ERR(ts->vio); 635 - dev_err(&spi->dev, "vio regulator missing (%d)", error); 636 - return error; 637 - } 638 - } else { 639 - ts->reset_gpio = -1; 640 - ts->set_reset = pdata->set_reset; 614 + ts->reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset", 615 + GPIOD_OUT_HIGH); 616 + if (IS_ERR(ts->reset_gpio)) { 617 + error = PTR_ERR(ts->reset_gpio); 618 + dev_err(&spi->dev, "error acquiring reset gpio: %d\n", error); 619 + return error; 641 620 } 621 + 622 + ts->vio = devm_regulator_get_optional(&spi->dev, "vio"); 623 + if (IS_ERR(ts->vio)) { 624 + error = PTR_ERR(ts->vio); 625 + dev_err(&spi->dev, "vio regulator missing (%d)", error); 626 + return error; 627 + } 628 + 629 + if (!ts->reset_gpio && pdata) 630 + ts->set_reset = pdata->set_reset; 642 631 643 632 mutex_init(&ts->mutex); 644 633