#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>
#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 {
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;
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);
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);
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,