diff options
author | Gary King <gking@nvidia.com> | 2010-08-03 17:56:37 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@nvidia.com> | 2011-11-30 21:41:33 -0800 |
commit | c40141339a7318be90eea355b900b10d8655d99b (patch) | |
tree | a855a8279155d1f2063e4d9cb130428d847623b5 /drivers/input/touchscreen | |
parent | 5803f7a667d9bd235519cdfb40bd5167f2efada9 (diff) |
panjit_touch: add early suspend support to panjit I2C touchscreen
Change-Id: I1adc2bb646269f17480718a7efb3dc14e6325fbc
Signed-off-by: Gary King <gking@nvidia.com>
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r-- | drivers/input/touchscreen/panjit_i2c.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/panjit_i2c.c b/drivers/input/touchscreen/panjit_i2c.c index 16df9313a10f..4fccebc52ea8 100644 --- a/drivers/input/touchscreen/panjit_i2c.c +++ b/drivers/input/touchscreen/panjit_i2c.c @@ -24,6 +24,7 @@ #include <linux/device.h> #include <linux/input.h> #include <linux/delay.h> +#include <linux/earlysuspend.h> #include <linux/i2c.h> #include <linux/i2c/panjit_ts.h> #include <linux/interrupt.h> @@ -38,10 +39,16 @@ #define DRIVER_NAME "panjit_touch" +#ifdef CONFIG_HAS_EARLYSUSPEND +static void pj_early_suspend(struct early_suspend *h); +static void pj_late_resume(struct early_suspend *h); +#endif + struct pj_data { struct input_dev *input_dev; struct i2c_client *client; int gpio_reset; + struct early_suspend early_suspend; }; struct pj_event { @@ -208,6 +215,12 @@ static int pj_probe(struct i2c_client *client, goto fail_irq; } +#ifdef CONFIG_HAS_EARLYSUSPEND + touch->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; + touch->early_suspend.suspend = pj_early_suspend; + touch->early_suspend.resume = pj_late_resume; + register_early_suspend(&touch->early_suspend); +#endif dev_info(&client->dev, "%s: initialized\n", __func__); return 0; @@ -267,6 +280,26 @@ static int pj_resume(struct i2c_client *client) return 0; } +#ifdef CONFIG_HAS_EARLYSUSPEND +static void pj_early_suspend(struct early_suspend *es) +{ + struct pj_data *touch; + touch = container_of(es, struct pj_data, early_suspend); + + if (pj_suspend(touch->client, PMSG_SUSPEND) != 0) + dev_err(&touch->client->dev, "%s: failed\n", __func__); +} + +static void pj_late_resume(struct early_suspend *es) +{ + struct pj_data *touch; + touch = container_of(es, struct pj_data, early_suspend); + + if (pj_resume(touch->client) != 0) + dev_err(&touch->client->dev, "%s: failed\n", __func__); +} +#endif + static int pj_remove(struct i2c_client *client) { struct pj_data *touch = i2c_get_clientdata(client); @@ -274,6 +307,9 @@ static int pj_remove(struct i2c_client *client) if (!touch) return -EINVAL; +#ifdef CONFIG_HAS_EARLYSUSPEND + unregister_early_suspend(&touch->early_suspend); +#endif free_irq(touch->client->irq, touch); if (touch->gpio_reset >= 0) gpio_free(touch->gpio_reset); @@ -291,8 +327,10 @@ static const struct i2c_device_id panjit_ts_id[] = { static struct i2c_driver panjit_driver = { .probe = pj_probe, .remove = pj_remove, +#ifndef CONFIG_HAS_EARLYSUSPEND .suspend = pj_suspend, .resume = pj_resume, +#endif .id_table = panjit_ts_id, .driver = { .name = DRIVER_NAME, |