From e3dd12f0eacc52ddf5cd4e6651e09daebcb25f0e Mon Sep 17 00:00:00 2001 From: Martin Kepplinger Date: Sat, 9 Feb 2019 08:53:13 -0800 Subject: Input: st1232 - switch to gpiod API Use devm_gpiod_get_optional() and gpiod_set_value_cansleep() instead of the old API. The st1232_ts_power() now passes on the inverted "poweron" value to reflect the correct logical value. Signed-off-by: Martin Kepplinger Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/st1232.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'drivers/input/touchscreen') diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c index 634d6c243845..32819ee6ec4b 100644 --- a/drivers/input/touchscreen/st1232.c +++ b/drivers/input/touchscreen/st1232.c @@ -11,13 +11,12 @@ */ #include -#include +#include #include #include #include #include #include -#include #include #include #include @@ -45,7 +44,7 @@ struct st1232_ts_data { struct i2c_client *client; struct input_dev *input_dev; struct dev_pm_qos_request low_latency_req; - int reset_gpio; + struct gpio_desc *reset_gpio; const struct st_chip_info *chip_info; int read_buf_len; u8 *read_buf; @@ -142,8 +141,8 @@ end: static void st1232_ts_power(struct st1232_ts_data *ts, bool poweron) { - if (gpio_is_valid(ts->reset_gpio)) - gpio_direction_output(ts->reset_gpio, poweron); + if (ts->reset_gpio) + gpiod_set_value_cansleep(ts->reset_gpio, !poweron); } static const struct st_chip_info st1232_chip_info = { @@ -215,15 +214,13 @@ static int st1232_ts_probe(struct i2c_client *client, ts->client = client; ts->input_dev = input_dev; - ts->reset_gpio = of_get_gpio(client->dev.of_node, 0); - if (gpio_is_valid(ts->reset_gpio)) { - error = devm_gpio_request(&client->dev, ts->reset_gpio, NULL); - if (error) { - dev_err(&client->dev, - "Unable to request GPIO pin %d.\n", - ts->reset_gpio); - return error; - } + ts->reset_gpio = devm_gpiod_get_optional(&client->dev, NULL, + GPIOD_OUT_HIGH); + if (IS_ERR(ts->reset_gpio)) { + error = PTR_ERR(ts->reset_gpio); + dev_err(&client->dev, "Unable to request GPIO pin: %d.\n", + error); + return error; } st1232_ts_power(ts, true); -- cgit v1.2.3