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

Input: eeti_ts: pass gpio value instead of IRQ

The EETI touchscreen asserts its IRQ line as soon as it has data in its
internal buffers. The line is automatically deasserted once all data has
been read via I2C. Hence, the driver has to monitor the GPIO line and
cannot simply rely on the interrupt handler reception.

In the current implementation of the driver, irq_to_gpio() is used to
determine the GPIO number from the i2c_client's IRQ value.

As irq_to_gpio() is not available on all platforms, this patch changes
this and makes the driver ignore the passed in IRQ. Instead, a GPIO is
added to the platform_data struct and gpio_to_irq is used to derive the
IRQ from that GPIO. If this fails, bail out. The driver is only able to
work in environments where the touchscreen GPIO can be mapped to an
IRQ.

Without this patch, building raumfeld_defconfig results in:

drivers/input/touchscreen/eeti_ts.c: In function 'eeti_ts_irq_active':
drivers/input/touchscreen/eeti_ts.c:65:2: error: implicit declaration of function 'irq_to_gpio' [-Werror=implicit-function-declaration]

Signed-off-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: stable@vger.kernel.org (v3.2+)
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Sven Neumann <s.neumann@raumfeld.com>
Cc: linux-input@vger.kernel.org
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>

+15 -9
+1 -1
arch/arm/mach-pxa/raumfeld.c
··· 953 953 954 954 static struct eeti_ts_platform_data eeti_ts_pdata = { 955 955 .irq_active_high = 1, 956 + .irq_gpio = GPIO_TOUCH_IRQ, 956 957 }; 957 958 958 959 static struct i2c_board_info raumfeld_controller_i2c_board_info __initdata = { 959 960 .type = "eeti_ts", 960 961 .addr = 0x0a, 961 - .irq = PXA_GPIO_TO_IRQ(GPIO_TOUCH_IRQ), 962 962 .platform_data = &eeti_ts_pdata, 963 963 }; 964 964
+13 -8
drivers/input/touchscreen/eeti_ts.c
··· 48 48 struct input_dev *input; 49 49 struct work_struct work; 50 50 struct mutex mutex; 51 - int irq, irq_active_high; 51 + int irq_gpio, irq, irq_active_high; 52 52 }; 53 53 54 54 #define EETI_TS_BITDEPTH (11) ··· 62 62 63 63 static inline int eeti_ts_irq_active(struct eeti_ts_priv *priv) 64 64 { 65 - return gpio_get_value(irq_to_gpio(priv->irq)) == priv->irq_active_high; 65 + return gpio_get_value(priv->irq_gpio) == priv->irq_active_high; 66 66 } 67 67 68 68 static void eeti_ts_read(struct work_struct *work) ··· 157 157 static int __devinit eeti_ts_probe(struct i2c_client *client, 158 158 const struct i2c_device_id *idp) 159 159 { 160 - struct eeti_ts_platform_data *pdata; 160 + struct eeti_ts_platform_data *pdata = client->dev.platform_data; 161 161 struct eeti_ts_priv *priv; 162 162 struct input_dev *input; 163 163 unsigned int irq_flags; ··· 199 199 200 200 priv->client = client; 201 201 priv->input = input; 202 - priv->irq = client->irq; 202 + priv->irq_gpio = pdata->irq_gpio; 203 + priv->irq = gpio_to_irq(pdata->irq_gpio); 203 204 204 - pdata = client->dev.platform_data; 205 + err = gpio_request_one(pdata->irq_gpio, GPIOF_IN, client->name); 206 + if (err < 0) 207 + goto err1; 205 208 206 209 if (pdata) 207 210 priv->irq_active_high = pdata->irq_active_high; ··· 218 215 219 216 err = input_register_device(input); 220 217 if (err) 221 - goto err1; 218 + goto err2; 222 219 223 220 err = request_irq(priv->irq, eeti_ts_isr, irq_flags, 224 221 client->name, priv); 225 222 if (err) { 226 223 dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); 227 - goto err2; 224 + goto err3; 228 225 } 229 226 230 227 /* ··· 236 233 device_init_wakeup(&client->dev, 0); 237 234 return 0; 238 235 239 - err2: 236 + err3: 240 237 input_unregister_device(input); 241 238 input = NULL; /* so we dont try to free it below */ 239 + err2: 240 + gpio_free(pdata->irq_gpio); 242 241 err1: 243 242 input_free_device(input); 244 243 kfree(priv);
+1
include/linux/input/eeti_ts.h
··· 2 2 #define LINUX_INPUT_EETI_TS_H 3 3 4 4 struct eeti_ts_platform_data { 5 + int irq_gpio; 5 6 unsigned int irq_active_high; 6 7 }; 7 8