From 12c78422e2baf43180fb28f2a4f2dfd88abf0240 Mon Sep 17 00:00:00 2001 From: Weixin Zhou Date: Wed, 6 Jan 2021 14:44:56 +0800 Subject: [PATCH] driver: input: touchscreen: Make sure that suspend/resume is called only once Signed-off-by: Weixin Zhou Change-Id: I198581c45baf31f62b9ffa6ba6d9ec15cf4c606d --- drivers/input/touchscreen/tp_suspend.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/tp_suspend.h b/drivers/input/touchscreen/tp_suspend.h index c0f1c4f0d088..23a6fc958296 100644 --- a/drivers/input/touchscreen/tp_suspend.h +++ b/drivers/input/touchscreen/tp_suspend.h @@ -19,6 +19,7 @@ struct tp_device{ int(*tp_suspend)(struct tp_device*); int(*tp_resume)(struct tp_device*); struct mutex ops_lock; + int status; }; static inline int fb_notifier_callback(struct notifier_block *self, @@ -38,14 +39,18 @@ static inline int fb_notifier_callback(struct notifier_block *self, switch (action) { case FB_EARLY_EVENT_BLANK: blank_mode = *((int *)event->data); - if (blank_mode != FB_BLANK_UNBLANK) + if (blank_mode != FB_BLANK_UNBLANK && tp->status == FB_BLANK_UNBLANK) { + tp->status = blank_mode; ret = tp->tp_suspend(tp); + } break; case FB_EVENT_BLANK: blank_mode = *((int *)event->data); - if (blank_mode == FB_BLANK_UNBLANK) + if (blank_mode == FB_BLANK_UNBLANK && tp->status != FB_BLANK_UNBLANK) { + tp->status = blank_mode; tp->tp_resume(tp); + } break; default: @@ -68,6 +73,7 @@ static inline int tp_register_fb(struct tp_device *tp) memset(&tp->fb_notif, 0, sizeof(tp->fb_notif)); tp->fb_notif.notifier_call = fb_notifier_callback; mutex_init(&tp->ops_lock); + tp->status = FB_BLANK_UNBLANK; return fb_register_client(&tp->fb_notif); }