From 8168344c4aecaa170882dbf50c5af4afa1d75c2c Mon Sep 17 00:00:00 2001 From: Weixin Zhou Date: Mon, 22 Feb 2021 10:53:07 +0800 Subject: [PATCH] input: touchscreen: gt1x: Avoid suspend/resume is invoked imbalanced Signed-off-by: Weixin Zhou Change-Id: I26733edacd48c6de11704e15998559e202935e11 --- drivers/input/touchscreen/gt1x/gt1x.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/gt1x/gt1x.c b/drivers/input/touchscreen/gt1x/gt1x.c index 7242c7eb9264..f65ca3b916e4 100644 --- a/drivers/input/touchscreen/gt1x/gt1x.c +++ b/drivers/input/touchscreen/gt1x/gt1x.c @@ -635,6 +635,7 @@ static int gt1x_ts_remove(struct i2c_client *client) #if defined(CONFIG_FB) /* frame buffer notifier block control the suspend/resume procedure */ static struct notifier_block gt1x_fb_notifier; +static int tp_status; static int gtp_fb_notifier_callback(struct notifier_block *noti, unsigned long event, void *data) { @@ -646,26 +647,32 @@ static int gtp_fb_notifier_callback(struct notifier_block *noti, unsigned long e #error Need add FB_EARLY_EVENT_BLANK to fbmem.c #endif - if (ev_data && ev_data->data && event == FB_EARLY_EVENT_BLANK) { + if (ev_data && ev_data->data && event == FB_EARLY_EVENT_BLANK + && tp_status != FB_BLANK_UNBLANK) { blank = ev_data->data; if (*blank == FB_BLANK_UNBLANK) { + tp_status = *blank; GTP_DEBUG("Resume by fb notifier."); gt1x_resume(); } } #else - if (ev_data && ev_data->data && event == FB_EVENT_BLANK) { + if (ev_data && ev_data->data && event == FB_EVENT_BLANK + && tp_status != FB_BLANK_UNBLANK) { blank = ev_data->data; if (*blank == FB_BLANK_UNBLANK) { + tp_status = *blank; GTP_DEBUG("Resume by fb notifier."); gt1x_resume(); } } #endif - if (ev_data && ev_data->data && event == FB_EVENT_BLANK) { + if (ev_data && ev_data->data && event == FB_EVENT_BLANK + && tp_status == FB_BLANK_UNBLANK) { blank = ev_data->data; if (*blank == FB_BLANK_POWERDOWN) { + tp_status = *blank; GTP_DEBUG("Suspend by fb notifier."); gt1x_suspend(); } @@ -723,6 +730,7 @@ static const struct dev_pm_ops gt1x_ts_pm_ops = { static int gt1x_register_powermanger(void) { #if defined(CONFIG_FB) + tp_status = FB_BLANK_UNBLANK; gt1x_fb_notifier.notifier_call = gtp_fb_notifier_callback; fb_register_client(>1x_fb_notifier);