aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen/eeti_ts.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/touchscreen/eeti_ts.c')
-rw-r--r--drivers/input/touchscreen/eeti_ts.c57
1 files changed, 47 insertions, 10 deletions
diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c
index 9029bd3f34e5..75f8b73010fa 100644
--- a/drivers/input/touchscreen/eeti_ts.c
+++ b/drivers/input/touchscreen/eeti_ts.c
@@ -33,6 +33,7 @@
33#include <linux/timer.h> 33#include <linux/timer.h>
34#include <linux/gpio.h> 34#include <linux/gpio.h>
35#include <linux/input/eeti_ts.h> 35#include <linux/input/eeti_ts.h>
36#include <linux/slab.h>
36 37
37static int flip_x; 38static int flip_x;
38module_param(flip_x, bool, 0644); 39module_param(flip_x, bool, 0644);
@@ -123,14 +124,25 @@ static irqreturn_t eeti_ts_isr(int irq, void *dev_id)
123 return IRQ_HANDLED; 124 return IRQ_HANDLED;
124} 125}
125 126
126static int eeti_ts_open(struct input_dev *dev) 127static void eeti_ts_start(struct eeti_ts_priv *priv)
127{ 128{
128 struct eeti_ts_priv *priv = input_get_drvdata(dev);
129
130 enable_irq(priv->irq); 129 enable_irq(priv->irq);
131 130
132 /* Read the events once to arm the IRQ */ 131 /* Read the events once to arm the IRQ */
133 eeti_ts_read(&priv->work); 132 eeti_ts_read(&priv->work);
133}
134
135static void eeti_ts_stop(struct eeti_ts_priv *priv)
136{
137 disable_irq(priv->irq);
138 cancel_work_sync(&priv->work);
139}
140
141static int eeti_ts_open(struct input_dev *dev)
142{
143 struct eeti_ts_priv *priv = input_get_drvdata(dev);
144
145 eeti_ts_start(priv);
134 146
135 return 0; 147 return 0;
136} 148}
@@ -139,8 +151,7 @@ static void eeti_ts_close(struct input_dev *dev)
139{ 151{
140 struct eeti_ts_priv *priv = input_get_drvdata(dev); 152 struct eeti_ts_priv *priv = input_get_drvdata(dev);
141 153
142 disable_irq(priv->irq); 154 eeti_ts_stop(priv);
143 cancel_work_sync(&priv->work);
144} 155}
145 156
146static int __devinit eeti_ts_probe(struct i2c_client *client, 157static int __devinit eeti_ts_probe(struct i2c_client *client,
@@ -152,10 +163,12 @@ static int __devinit eeti_ts_probe(struct i2c_client *client,
152 unsigned int irq_flags; 163 unsigned int irq_flags;
153 int err = -ENOMEM; 164 int err = -ENOMEM;
154 165
155 /* In contrast to what's described in the datasheet, there seems 166 /*
167 * In contrast to what's described in the datasheet, there seems
156 * to be no way of probing the presence of that device using I2C 168 * to be no way of probing the presence of that device using I2C
157 * commands. So we need to blindly believe it is there, and wait 169 * commands. So we need to blindly believe it is there, and wait
158 * for interrupts to occur. */ 170 * for interrupts to occur.
171 */
159 172
160 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 173 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
161 if (!priv) { 174 if (!priv) {
@@ -211,9 +224,11 @@ static int __devinit eeti_ts_probe(struct i2c_client *client,
211 goto err2; 224 goto err2;
212 } 225 }
213 226
214 /* Disable the irq for now. It will be enabled once the input device 227 /*
215 * is opened. */ 228 * Disable the device for now. It will be enabled once the
216 disable_irq(priv->irq); 229 * input device is opened.
230 */
231 eeti_ts_stop(priv);
217 232
218 device_init_wakeup(&client->dev, 0); 233 device_init_wakeup(&client->dev, 0);
219 return 0; 234 return 0;
@@ -234,6 +249,12 @@ static int __devexit eeti_ts_remove(struct i2c_client *client)
234 struct eeti_ts_priv *priv = i2c_get_clientdata(client); 249 struct eeti_ts_priv *priv = i2c_get_clientdata(client);
235 250
236 free_irq(priv->irq, priv); 251 free_irq(priv->irq, priv);
252 /*
253 * eeti_ts_stop() leaves IRQ disabled. We need to re-enable it
254 * so that device still works if we reload the driver.
255 */
256 enable_irq(priv->irq);
257
237 input_unregister_device(priv->input); 258 input_unregister_device(priv->input);
238 i2c_set_clientdata(client, NULL); 259 i2c_set_clientdata(client, NULL);
239 kfree(priv); 260 kfree(priv);
@@ -245,6 +266,14 @@ static int __devexit eeti_ts_remove(struct i2c_client *client)
245static int eeti_ts_suspend(struct i2c_client *client, pm_message_t mesg) 266static int eeti_ts_suspend(struct i2c_client *client, pm_message_t mesg)
246{ 267{
247 struct eeti_ts_priv *priv = i2c_get_clientdata(client); 268 struct eeti_ts_priv *priv = i2c_get_clientdata(client);
269 struct input_dev *input_dev = priv->input;
270
271 mutex_lock(&input_dev->mutex);
272
273 if (input_dev->users)
274 eeti_ts_stop(priv);
275
276 mutex_unlock(&input_dev->mutex);
248 277
249 if (device_may_wakeup(&client->dev)) 278 if (device_may_wakeup(&client->dev))
250 enable_irq_wake(priv->irq); 279 enable_irq_wake(priv->irq);
@@ -255,10 +284,18 @@ static int eeti_ts_suspend(struct i2c_client *client, pm_message_t mesg)
255static int eeti_ts_resume(struct i2c_client *client) 284static int eeti_ts_resume(struct i2c_client *client)
256{ 285{
257 struct eeti_ts_priv *priv = i2c_get_clientdata(client); 286 struct eeti_ts_priv *priv = i2c_get_clientdata(client);
287 struct input_dev *input_dev = priv->input;
258 288
259 if (device_may_wakeup(&client->dev)) 289 if (device_may_wakeup(&client->dev))
260 disable_irq_wake(priv->irq); 290 disable_irq_wake(priv->irq);
261 291
292 mutex_lock(&input_dev->mutex);
293
294 if (input_dev->users)
295 eeti_ts_start(priv);
296
297 mutex_unlock(&input_dev->mutex);
298
262 return 0; 299 return 0;
263} 300}
264#else 301#else