aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2011-08-25 04:05:46 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2011-08-27 02:25:14 -0400
commitd3654d7ef3adad0083525cfb6fe27be62cb83d0d (patch)
tree7d9370df7516c190b12ba8c3dbe960363d7efbfe /drivers/input/touchscreen
parent377dc5538c43052d2ee9bc89577cb07fe18f2520 (diff)
Input: tsc2007 - add open and close methods
This will ensure that the device delivers input events only when there are users. Tested-by: Thierry Reding <thierry.reding@avionic-design.de> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r--drivers/input/touchscreen/tsc2007.c46
1 files changed, 38 insertions, 8 deletions
diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
index e3aaf50ee8d3..0acca68cc52b 100644
--- a/drivers/input/touchscreen/tsc2007.c
+++ b/drivers/input/touchscreen/tsc2007.c
@@ -237,12 +237,40 @@ static irqreturn_t tsc2007_hard_irq(int irq, void *handle)
237 return IRQ_HANDLED; 237 return IRQ_HANDLED;
238} 238}
239 239
240static void tsc2007_free_irq(struct tsc2007 *ts) 240static void tsc2007_stop(struct tsc2007 *ts)
241{ 241{
242 ts->stopped = true; 242 ts->stopped = true;
243 mb(); 243 mb();
244 wake_up(&ts->wait); 244 wake_up(&ts->wait);
245 free_irq(ts->irq, ts); 245
246 disable_irq(ts->irq);
247}
248
249static int tsc2007_open(struct input_dev *input_dev)
250{
251 struct tsc2007 *ts = input_get_drvdata(input_dev);
252 int err;
253
254 ts->stopped = false;
255 mb();
256
257 enable_irq(ts->irq);
258
259 /* Prepare for touch readings - power down ADC and enable PENIRQ */
260 err = tsc2007_xfer(ts, PWRDOWN);
261 if (err < 0) {
262 tsc2007_stop(ts);
263 return err;
264 }
265
266 return 0;
267}
268
269static void tsc2007_close(struct input_dev *input_dev)
270{
271 struct tsc2007 *ts = input_get_drvdata(input_dev);
272
273 tsc2007_stop(ts);
246} 274}
247 275
248static int __devinit tsc2007_probe(struct i2c_client *client, 276static int __devinit tsc2007_probe(struct i2c_client *client,
@@ -289,6 +317,11 @@ static int __devinit tsc2007_probe(struct i2c_client *client,
289 input_dev->phys = ts->phys; 317 input_dev->phys = ts->phys;
290 input_dev->id.bustype = BUS_I2C; 318 input_dev->id.bustype = BUS_I2C;
291 319
320 input_dev->open = tsc2007_open;
321 input_dev->close = tsc2007_close;
322
323 input_set_drvdata(input_dev, ts);
324
292 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 325 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
293 input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); 326 input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
294 327
@@ -307,10 +340,7 @@ static int __devinit tsc2007_probe(struct i2c_client *client,
307 goto err_free_mem; 340 goto err_free_mem;
308 } 341 }
309 342
310 /* Prepare for touch readings - power down ADC and enable PENIRQ */ 343 tsc2007_stop(ts);
311 err = tsc2007_xfer(ts, PWRDOWN);
312 if (err < 0)
313 goto err_free_irq;
314 344
315 err = input_register_device(input_dev); 345 err = input_register_device(input_dev);
316 if (err) 346 if (err)
@@ -321,7 +351,7 @@ static int __devinit tsc2007_probe(struct i2c_client *client,
321 return 0; 351 return 0;
322 352
323 err_free_irq: 353 err_free_irq:
324 tsc2007_free_irq(ts); 354 free_irq(ts->irq, ts);
325 if (pdata->exit_platform_hw) 355 if (pdata->exit_platform_hw)
326 pdata->exit_platform_hw(); 356 pdata->exit_platform_hw();
327 err_free_mem: 357 err_free_mem:
@@ -335,7 +365,7 @@ static int __devexit tsc2007_remove(struct i2c_client *client)
335 struct tsc2007 *ts = i2c_get_clientdata(client); 365 struct tsc2007 *ts = i2c_get_clientdata(client);
336 struct tsc2007_platform_data *pdata = client->dev.platform_data; 366 struct tsc2007_platform_data *pdata = client->dev.platform_data;
337 367
338 tsc2007_free_irq(ts); 368 free_irq(ts->irq, ts);
339 369
340 if (pdata->exit_platform_hw) 370 if (pdata->exit_platform_hw)
341 pdata->exit_platform_hw(); 371 pdata->exit_platform_hw();