forked from mirrors/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>
This commit is contained in:
		
							parent
							
								
									4e5220cb8e
								
							
						
					
					
						commit
						83b41248ed
					
				
					 1 changed files with 19 additions and 28 deletions
				
			
		| 
						 | 
					@ -7,15 +7,13 @@
 | 
				
			||||||
 * Some cleanups by Alan Cox <alan@linux.intel.com>
 | 
					 * Some cleanups by Alan Cox <alan@linux.intel.com>
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <linux/module.h>
 | 
					 | 
				
			||||||
#include <linux/kernel.h>
 | 
					 | 
				
			||||||
#include <linux/input.h>
 | 
					 | 
				
			||||||
#include <linux/slab.h>
 | 
					 | 
				
			||||||
#include <linux/interrupt.h>
 | 
					 | 
				
			||||||
#include <linux/io.h>
 | 
					 | 
				
			||||||
#include <linux/i2c.h>
 | 
					#include <linux/i2c.h>
 | 
				
			||||||
#include <linux/gpio.h>
 | 
					#include <linux/input.h>
 | 
				
			||||||
#include <linux/input/cy8ctmg110_pdata.h>
 | 
					#include <linux/interrupt.h>
 | 
				
			||||||
 | 
					#include <linux/gpio/consumer.h>
 | 
				
			||||||
 | 
					#include <linux/kernel.h>
 | 
				
			||||||
 | 
					#include <linux/module.h>
 | 
				
			||||||
 | 
					#include <linux/slab.h>
 | 
				
			||||||
#include <asm/byteorder.h>
 | 
					#include <asm/byteorder.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CY8CTMG110_DRIVER_NAME      "cy8ctmg110"
 | 
					#define CY8CTMG110_DRIVER_NAME      "cy8ctmg110"
 | 
				
			||||||
| 
						 | 
					@ -46,17 +44,18 @@ struct cy8ctmg110 {
 | 
				
			||||||
	struct input_dev *input;
 | 
						struct input_dev *input;
 | 
				
			||||||
	char phys[32];
 | 
						char phys[32];
 | 
				
			||||||
	struct i2c_client *client;
 | 
						struct i2c_client *client;
 | 
				
			||||||
	int reset_pin;
 | 
						struct gpio_desc *reset_gpio;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * cy8ctmg110_power is the routine that is called when touch hardware
 | 
					 * cy8ctmg110_power is the routine that is called when touch hardware
 | 
				
			||||||
 * will powered off or on.
 | 
					 * is being powered off or on. When powering on this routine de-asserts
 | 
				
			||||||
 | 
					 * the RESET line, when powering off reset line is asserted.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static void cy8ctmg110_power(struct cy8ctmg110 *ts, bool poweron)
 | 
					static void cy8ctmg110_power(struct cy8ctmg110 *ts, bool poweron)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (ts->reset_pin)
 | 
						if (ts->reset_gpio)
 | 
				
			||||||
		gpio_direction_output(ts->reset_pin, 1 - poweron);
 | 
							gpiod_set_value_cansleep(ts->reset_gpio, !poweron);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int cy8ctmg110_write_regs(struct cy8ctmg110 *tsc, unsigned char reg,
 | 
					static int cy8ctmg110_write_regs(struct cy8ctmg110 *tsc, unsigned char reg,
 | 
				
			||||||
| 
						 | 
					@ -172,17 +171,10 @@ static void cy8ctmg110_shut_off(void *_ts)
 | 
				
			||||||
static int cy8ctmg110_probe(struct i2c_client *client,
 | 
					static int cy8ctmg110_probe(struct i2c_client *client,
 | 
				
			||||||
					const struct i2c_device_id *id)
 | 
										const struct i2c_device_id *id)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const struct cy8ctmg110_pdata *pdata = dev_get_platdata(&client->dev);
 | 
					 | 
				
			||||||
	struct cy8ctmg110 *ts;
 | 
						struct cy8ctmg110 *ts;
 | 
				
			||||||
	struct input_dev *input_dev;
 | 
						struct input_dev *input_dev;
 | 
				
			||||||
	int err;
 | 
						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,
 | 
						if (!i2c_check_functionality(client->adapter,
 | 
				
			||||||
					I2C_FUNC_SMBUS_READ_WORD_DATA))
 | 
										I2C_FUNC_SMBUS_READ_WORD_DATA))
 | 
				
			||||||
		return -EIO;
 | 
							return -EIO;
 | 
				
			||||||
| 
						 | 
					@ -197,7 +189,6 @@ static int cy8ctmg110_probe(struct i2c_client *client,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ts->client = client;
 | 
						ts->client = client;
 | 
				
			||||||
	ts->input = input_dev;
 | 
						ts->input = input_dev;
 | 
				
			||||||
	ts->reset_pin = pdata->reset_pin;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	snprintf(ts->phys, sizeof(ts->phys),
 | 
						snprintf(ts->phys, sizeof(ts->phys),
 | 
				
			||||||
		 "%s/input0", dev_name(&client->dev));
 | 
							 "%s/input0", dev_name(&client->dev));
 | 
				
			||||||
| 
						 | 
					@ -212,15 +203,15 @@ static int cy8ctmg110_probe(struct i2c_client *client,
 | 
				
			||||||
	input_set_abs_params(input_dev, ABS_Y,
 | 
						input_set_abs_params(input_dev, ABS_Y,
 | 
				
			||||||
			CY8CTMG110_Y_MIN, CY8CTMG110_Y_MAX, 4, 0);
 | 
								CY8CTMG110_Y_MIN, CY8CTMG110_Y_MAX, 4, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (ts->reset_pin) {
 | 
						/* Request and assert reset line */
 | 
				
			||||||
		err = devm_gpio_request(&client->dev, ts->reset_pin, NULL);
 | 
						ts->reset_gpio = devm_gpiod_get_optional(&client->dev, NULL,
 | 
				
			||||||
		if (err) {
 | 
											 GPIOD_OUT_HIGH);
 | 
				
			||||||
 | 
						if (IS_ERR(ts->reset_gpio)) {
 | 
				
			||||||
 | 
							err = PTR_ERR(ts->reset_gpio);
 | 
				
			||||||
		dev_err(&client->dev,
 | 
							dev_err(&client->dev,
 | 
				
			||||||
				"Unable to request GPIO pin %d.\n",
 | 
								"Unable to request reset GPIO: %d\n", err);
 | 
				
			||||||
				ts->reset_pin);
 | 
					 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cy8ctmg110_power(ts, true);
 | 
						cy8ctmg110_power(ts, true);
 | 
				
			||||||
	cy8ctmg110_set_sleepmode(ts, false);
 | 
						cy8ctmg110_set_sleepmode(ts, false);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue