input: touchscreen: fix kernel crash in fb_notifier_callback function
[firefly-linux-kernel-4.4.55.git] / drivers / input / touchscreen / tp_suspend.h
index bf23e868e7703b5911407508528f8e7db0c494a5..b900ee530a2a82db04741efd0ac83115908251bd 100644 (file)
@@ -25,7 +25,7 @@ static inline int fb_notifier_callback(struct notifier_block *self,
 {
        struct tp_device *tp;
        struct fb_event *event = data;
-       int blank_mode = *((int *)event->data);
+       int blank_mode;
        int ret = 0;
 
        tp = container_of(self, struct tp_device, fb_notif);
@@ -34,24 +34,23 @@ static inline int fb_notifier_callback(struct notifier_block *self,
 
        mutex_lock(&tp->ops_lock);
 
-       if (action == FB_EARLY_EVENT_BLANK) {
-               switch (blank_mode) {
-               case FB_BLANK_UNBLANK:
-                       break;
-               default:
+       switch (action) {
+       case FB_EARLY_EVENT_BLANK:
+               blank_mode = *((int *)event->data);
+               if (blank_mode != FB_BLANK_UNBLANK)
                        ret = tp->tp_suspend(tp);
-                       break;
-               }
-       }
-       else if (action == FB_EVENT_BLANK) {
-               switch (blank_mode) {
-               case FB_BLANK_UNBLANK:
+               break;
+
+       case FB_EVENT_BLANK:
+               blank_mode = *((int *)event->data);
+               if (blank_mode == FB_BLANK_UNBLANK)
                        tp->tp_resume(tp);
-                       break;
-               default:
-                       break;
-               }
+               break;
+
+       default:
+               break;
        }
+
        mutex_unlock(&tp->ops_lock);
 
        if (ret < 0)