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

Input: eeti_ts - switch to gpiod API

gpiod API allows standard way of specifying GPIO polarity and takes it into
account when reading or setting GPIO state. It also allows us to switch to
common way of obtaining GPIO descriptor and away form legacy platform data.

Reviewed-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+16 -32
+9 -5
arch/arm/mach-pxa/raumfeld.c
··· 26 26 #include <linux/smsc911x.h> 27 27 #include <linux/input.h> 28 28 #include <linux/gpio_keys.h> 29 - #include <linux/input/eeti_ts.h> 30 29 #include <linux/leds.h> 31 30 #include <linux/w1-gpio.h> 32 31 #include <linux/sched.h> ··· 964 965 .addr = 0x48, 965 966 }; 966 967 967 - static struct eeti_ts_platform_data eeti_ts_pdata = { 968 - .irq_active_high = 1, 969 - .irq_gpio = GPIO_TOUCH_IRQ, 968 + static struct gpiod_lookup_table raumfeld_controller_gpios_table = { 969 + .dev_id = "0-000a", 970 + .table = { 971 + GPIO_LOOKUP("gpio-pxa", 972 + GPIO_TOUCH_IRQ, "attn", GPIO_ACTIVE_HIGH), 973 + { }, 974 + }, 970 975 }; 971 976 972 977 static const struct resource raumfeld_controller_resources[] = __initconst { ··· 986 983 .addr = 0x0a, 987 984 .resources = raumfeld_controller_resources, 988 985 .num_resources = ARRAY_SIZE(raumfeld_controller_resources), 989 - .platform_data = &eeti_ts_pdata, 990 986 }; 991 987 992 988 static struct platform_device *raumfeld_common_devices[] = { ··· 1076 1074 platform_device_register(&rotary_encoder_device); 1077 1075 1078 1076 spi_register_board_info(ARRAY_AND_SIZE(controller_spi_devices)); 1077 + 1078 + gpiod_add_lookup_table(&raumfeld_controller_gpios_table); 1079 1079 i2c_register_board_info(0, &raumfeld_controller_i2c_board_info, 1); 1080 1080 1081 1081 ret = gpio_request(GPIO_SHUTDOWN_BATT, "battery shutdown");
+7 -17
drivers/input/touchscreen/eeti_ts.c
··· 31 31 #include <linux/interrupt.h> 32 32 #include <linux/i2c.h> 33 33 #include <linux/timer.h> 34 - #include <linux/gpio.h> 35 - #include <linux/input/eeti_ts.h> 34 + #include <linux/gpio/consumer.h> 36 35 #include <linux/slab.h> 37 36 #include <asm/unaligned.h> 38 37 ··· 46 47 struct eeti_ts { 47 48 struct i2c_client *client; 48 49 struct input_dev *input; 49 - int irq_gpio, irq_active_high; 50 + struct gpio_desc *attn_gpio; 50 51 bool running; 51 52 }; 52 53 ··· 58 59 #define REPORT_BIT_AD1 BIT(2) 59 60 #define REPORT_BIT_HAS_PRESSURE BIT(6) 60 61 #define REPORT_RES_BITS(v) (((v) >> 1) + EETI_TS_BITDEPTH) 61 - 62 - static inline int eeti_ts_irq_active(struct eeti_ts *eeti) 63 - { 64 - return gpio_get_value_cansleep(eeti->irq_gpio) == eeti->irq_active_high; 65 - } 66 62 67 63 static void eeti_ts_report_event(struct eeti_ts *eeti, u8 *buf) 68 64 { ··· 109 115 /* Motion packet */ 110 116 eeti_ts_report_event(eeti, buf); 111 117 } 112 - } while (eeti->running && eeti_ts_irq_active(eeti)); 118 + } while (eeti->running && 119 + eeti->attn_gpio && gpiod_get_value_cansleep(eeti->attn_gpio)); 113 120 114 121 return IRQ_HANDLED; 115 122 } ··· 149 154 const struct i2c_device_id *idp) 150 155 { 151 156 struct device *dev = &client->dev; 152 - struct eeti_ts_platform_data *pdata = dev_get_platdata(dev); 153 157 struct eeti_ts *eeti; 154 158 struct input_dev *input; 155 159 int error; ··· 185 191 186 192 eeti->client = client; 187 193 eeti->input = input; 188 - eeti->irq_gpio = pdata->irq_gpio; 189 194 190 - error = devm_gpio_request_one(dev, pdata->irq_gpio, GPIOF_IN, 191 - client->name); 192 - if (error) 193 - return error; 194 - 195 - eeti->irq_active_high = pdata->irq_active_high; 195 + eeti->attn_gpio = devm_gpiod_get_optional(dev, "attn", GPIOD_IN); 196 + if (IS_ERR(eeti->attn_gpio)) 197 + return PTR_ERR(eeti->attn_gpio); 196 198 197 199 i2c_set_clientdata(client, eeti); 198 200 input_set_drvdata(input, eeti);
-10
include/linux/input/eeti_ts.h
··· 1 - #ifndef LINUX_INPUT_EETI_TS_H 2 - #define LINUX_INPUT_EETI_TS_H 3 - 4 - struct eeti_ts_platform_data { 5 - int irq_gpio; 6 - unsigned int irq_active_high; 7 - }; 8 - 9 - #endif /* LINUX_INPUT_EETI_TS_H */ 10 -