From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: linux-input@vger.kernel.org
Cc: Linus Walleij <linus.walleij@linaro.org>, linux-kernel@vger.kernel.org
Subject: [PATCH 7/7] Input: cy8ctmg110_ts - switch to using gpiod API
Date: Wed, 2 Jun 2021 21:37:26 -0700 [thread overview]
Message-ID: <20210603043726.3793876-7-dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <20210603043726.3793876-1-dmitry.torokhov@gmail.com>
Instead of legacy gpio API let's use newer gpiod API. This also allows us
to get rid of platform data.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/touchscreen/cy8ctmg110_ts.c | 41 +++++++++--------------
1 file changed, 15 insertions(+), 26 deletions(-)
diff --git a/drivers/input/touchscreen/cy8ctmg110_ts.c b/drivers/input/touchscreen/cy8ctmg110_ts.c
index 33ccb31cad52..3e2d64fb1620 100644
--- a/drivers/input/touchscreen/cy8ctmg110_ts.c
+++ b/drivers/input/touchscreen/cy8ctmg110_ts.c
@@ -7,15 +7,13 @@
* Some cleanups by Alan Cox <alan@linux.intel.com>
*/
-#include <linux/module.h>
-#include <linux/kernel.h>
+#include <linux/i2c.h>
#include <linux/input.h>
-#include <linux/slab.h>
#include <linux/interrupt.h>
-#include <linux/io.h>
-#include <linux/i2c.h>
-#include <linux/gpio.h>
-#include <linux/input/cy8ctmg110_pdata.h>
+#include <linux/gpio/consumer.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
#include <asm/byteorder.h>
#define CY8CTMG110_DRIVER_NAME "cy8ctmg110"
@@ -46,7 +44,7 @@ struct cy8ctmg110 {
struct input_dev *input;
char phys[32];
struct i2c_client *client;
- int reset_pin;
+ struct gpio_desc *reset_gpio;
};
/*
@@ -55,8 +53,8 @@ struct cy8ctmg110 {
*/
static void cy8ctmg110_power(struct cy8ctmg110 *ts, bool poweron)
{
- if (ts->reset_pin)
- gpio_direction_output(ts->reset_pin, 1 - poweron);
+ if (ts->reset_gpio)
+ gpiod_set_value_cansleep(ts->reset_gpio, !poweron);
}
static int cy8ctmg110_write_regs(struct cy8ctmg110 *tsc, unsigned char reg,
@@ -172,17 +170,10 @@ static void cy8ctmg110_shut_off(void *_ts)
static int cy8ctmg110_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
- const struct cy8ctmg110_pdata *pdata = dev_get_platdata(&client->dev);
struct cy8ctmg110 *ts;
struct input_dev *input_dev;
int err;
- /* No pdata no way forward */
- if (pdata == NULL) {
- dev_err(&client->dev, "no pdata\n");
- return -ENODEV;
- }
-
if (!i2c_check_functionality(client->adapter,
I2C_FUNC_SMBUS_READ_WORD_DATA))
return -EIO;
@@ -197,7 +188,6 @@ static int cy8ctmg110_probe(struct i2c_client *client,
ts->client = client;
ts->input = input_dev;
- ts->reset_pin = pdata->reset_pin;
snprintf(ts->phys, sizeof(ts->phys),
"%s/input0", dev_name(&client->dev));
@@ -212,14 +202,13 @@ static int cy8ctmg110_probe(struct i2c_client *client,
input_set_abs_params(input_dev, ABS_Y,
CY8CTMG110_Y_MIN, CY8CTMG110_Y_MAX, 4, 0);
- if (ts->reset_pin) {
- err = devm_gpio_request(&client->dev, ts->reset_pin, NULL);
- if (err) {
- dev_err(&client->dev,
- "Unable to request GPIO pin %d.\n",
- ts->reset_pin);
- return err;
- }
+ ts->reset_gpio = devm_gpiod_get_optional(&client->dev, NULL,
+ GPIOD_OUT_HIGH);
+ if (IS_ERR(ts->reset_gpio)) {
+ err = PTR_ERR(ts->reset_gpio);
+ dev_err(&client->dev,
+ "Unable to request reset GPIO: %d\n", err);
+ return err;
}
cy8ctmg110_power(ts, true);
--
2.32.0.rc0.204.g9fa02ecfa5-goog
next prev parent reply other threads:[~2021-06-03 4:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-03 4:37 [PATCH 1/7] Input: cy8ctmg110_ts - rely on platform code to supply interrupt Dmitry Torokhov
2021-06-03 4:37 ` [PATCH 2/7] Input: cy8ctmg110_ts - do not hard code interrupt trigger Dmitry Torokhov
2021-06-04 7:31 ` Linus Walleij
2021-06-03 4:37 ` [PATCH 3/7] Input: cy8ctmg110_ts - do not hardcode as wakeup source Dmitry Torokhov
2021-06-04 7:31 ` Linus Walleij
2021-06-03 4:37 ` [PATCH 4/7] Input: cy8ctmg110_ts - let I2C core configure wake interrupt Dmitry Torokhov
2021-06-04 7:32 ` Linus Walleij
2021-06-06 4:10 ` Dmitry Torokhov
2021-06-03 4:37 ` [PATCH 5/7] Input: cy8ctmg110_ts - use endian helpers when converting data on wire Dmitry Torokhov
2021-06-04 7:34 ` Linus Walleij
2021-06-03 4:37 ` [PATCH 6/7] Input: cy8ctmg110_ts - switch to using managed resources Dmitry Torokhov
2021-06-04 7:35 ` Linus Walleij
2021-06-03 4:37 ` Dmitry Torokhov [this message]
2021-06-04 7:38 ` [PATCH 7/7] Input: cy8ctmg110_ts - switch to using gpiod API Linus Walleij
2021-06-06 4:08 ` Dmitry Torokhov
2021-06-04 7:30 ` [PATCH 1/7] Input: cy8ctmg110_ts - rely on platform code to supply interrupt Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210603043726.3793876-7-dmitry.torokhov@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).