Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 190584
b: refs/heads/master
c: 7fbef0d
h: refs/heads/master
v: v3
  • Loading branch information
Daniel Mack authored and Dmitry Torokhov committed Apr 20, 2010
1 parent bebc5b4 commit 1c72ef8
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5f57d67da87332a9a1ba8fa7a33bf0680e1c76e7
refs/heads/master: 7fbef0d1e278a0a8c803a4d2b1e2bd5740bffa52
56 changes: 46 additions & 10 deletions trunk/drivers/input/touchscreen/eeti_ts.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,25 @@ static irqreturn_t eeti_ts_isr(int irq, void *dev_id)
return IRQ_HANDLED;
}

static int eeti_ts_open(struct input_dev *dev)
static void eeti_ts_start(struct eeti_ts_priv *priv)
{
struct eeti_ts_priv *priv = input_get_drvdata(dev);

enable_irq(priv->irq);

/* Read the events once to arm the IRQ */
eeti_ts_read(&priv->work);
}

static void eeti_ts_stop(struct eeti_ts_priv *priv)
{
disable_irq(priv->irq);
cancel_work_sync(&priv->work);
}

static int eeti_ts_open(struct input_dev *dev)
{
struct eeti_ts_priv *priv = input_get_drvdata(dev);

eeti_ts_start(priv);

return 0;
}
Expand All @@ -139,8 +150,7 @@ static void eeti_ts_close(struct input_dev *dev)
{
struct eeti_ts_priv *priv = input_get_drvdata(dev);

disable_irq(priv->irq);
cancel_work_sync(&priv->work);
eeti_ts_stop(priv);
}

static int __devinit eeti_ts_probe(struct i2c_client *client,
Expand All @@ -152,10 +162,12 @@ static int __devinit eeti_ts_probe(struct i2c_client *client,
unsigned int irq_flags;
int err = -ENOMEM;

/* In contrast to what's described in the datasheet, there seems
/*
* In contrast to what's described in the datasheet, there seems
* to be no way of probing the presence of that device using I2C
* commands. So we need to blindly believe it is there, and wait
* for interrupts to occur. */
* for interrupts to occur.
*/

priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) {
Expand Down Expand Up @@ -211,9 +223,11 @@ static int __devinit eeti_ts_probe(struct i2c_client *client,
goto err2;
}

/* Disable the irq for now. It will be enabled once the input device
* is opened. */
disable_irq(priv->irq);
/*
* Disable the device for now. It will be enabled once the
* input device is opened.
*/
eeti_ts_stop(priv);

device_init_wakeup(&client->dev, 0);
return 0;
Expand All @@ -234,6 +248,12 @@ static int __devexit eeti_ts_remove(struct i2c_client *client)
struct eeti_ts_priv *priv = i2c_get_clientdata(client);

free_irq(priv->irq, priv);
/*
* eeti_ts_stop() leaves IRQ disabled. We need to re-enable it
* so that device still works if we reload the driver.
*/
enable_irq(priv->irq);

input_unregister_device(priv->input);
i2c_set_clientdata(client, NULL);
kfree(priv);
Expand All @@ -245,6 +265,14 @@ static int __devexit eeti_ts_remove(struct i2c_client *client)
static int eeti_ts_suspend(struct i2c_client *client, pm_message_t mesg)
{
struct eeti_ts_priv *priv = i2c_get_clientdata(client);
struct input_dev *input_dev = priv->input;

mutex_lock(&input_dev->mutex);

if (input_dev->users)
eeti_ts_stop(priv);

mutex_unlock(&input_dev->mutex);

if (device_may_wakeup(&client->dev))
enable_irq_wake(priv->irq);
Expand All @@ -255,10 +283,18 @@ static int eeti_ts_suspend(struct i2c_client *client, pm_message_t mesg)
static int eeti_ts_resume(struct i2c_client *client)
{
struct eeti_ts_priv *priv = i2c_get_clientdata(client);
struct input_dev *input_dev = priv->input;

if (device_may_wakeup(&client->dev))
disable_irq_wake(priv->irq);

mutex_lock(&input_dev->mutex);

if (input_dev->users)
eeti_ts_start(priv);

mutex_unlock(&input_dev->mutex);

return 0;
}
#else
Expand Down

0 comments on commit 1c72ef8

Please sign in to comment.