Commit d19e719d authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: egalax_ts - switch to using gpiod API

This updates the driver to gpiod API, and removes yet another use of
of_get_named_gpio().

Link: https://lore.kernel.org/r/20220920042608.1865560-3-dmitry.torokhov@gmail.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 413a009f
...@@ -14,17 +14,17 @@ ...@@ -14,17 +14,17 @@
- auto idle mode support - auto idle mode support
*/ */
#include <linux/err.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/input.h> #include <linux/input.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/input/mt.h> #include <linux/input/mt.h>
#include <linux/of_gpio.h>
/* /*
* Mouse Mode: some panel may configure the controller to mouse mode, * Mouse Mode: some panel may configure the controller to mouse mode,
...@@ -119,32 +119,26 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id) ...@@ -119,32 +119,26 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
/* wake up controller by an falling edge of interrupt gpio. */ /* wake up controller by an falling edge of interrupt gpio. */
static int egalax_wake_up_device(struct i2c_client *client) static int egalax_wake_up_device(struct i2c_client *client)
{ {
struct device_node *np = client->dev.of_node; struct gpio_desc *gpio;
int gpio;
int ret; int ret;
if (!np) /* wake up controller via an falling edge on IRQ gpio. */
return -ENODEV; gpio = gpiod_get(&client->dev, "wakeup", GPIOD_OUT_HIGH);
ret = PTR_ERR_OR_ZERO(gpio);
gpio = of_get_named_gpio(np, "wakeup-gpios", 0); if (ret) {
if (!gpio_is_valid(gpio)) if (ret != -EPROBE_DEFER)
return -ENODEV; dev_err(&client->dev,
"failed to request wakeup gpio, cannot wake up controller: %d\n",
ret = gpio_request(gpio, "egalax_irq"); ret);
if (ret < 0) {
dev_err(&client->dev,
"request gpio failed, cannot wake up controller: %d\n",
ret);
return ret; return ret;
} }
/* wake up controller via an falling edge on IRQ gpio. */ /* release the line */
gpio_direction_output(gpio, 0); gpiod_set_value_cansleep(gpio, 0);
gpio_set_value(gpio, 1);
/* controller should be waken up, return irq. */ /* controller should be woken up, return irq. */
gpio_direction_input(gpio); gpiod_direction_input(gpio);
gpio_free(gpio); gpiod_put(gpio);
return 0; return 0;
} }
...@@ -185,10 +179,8 @@ static int egalax_ts_probe(struct i2c_client *client, ...@@ -185,10 +179,8 @@ static int egalax_ts_probe(struct i2c_client *client,
/* controller may be in sleep, wake it up. */ /* controller may be in sleep, wake it up. */
error = egalax_wake_up_device(client); error = egalax_wake_up_device(client);
if (error) { if (error)
dev_err(&client->dev, "Failed to wake up the controller\n");
return error; return error;
}
error = egalax_firmware_version(client); error = egalax_firmware_version(client);
if (error < 0) { if (error < 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment