[Bugfix][ZK-84] Fix got wrong node when suspend/resume node not given (ex. 113 pull high after wake up)

Only Configure: No
Affected branch: MR3.0-Merge-v2.0
Affected module: lynq_suspend in kernel
Is it affected on both ZXIC and MTK: only MTK
Self-test: Yes
Doc Update: No

Change-Id: Ibd9b696077c86355be0d087dcee280dd27e28798
diff --git a/src/kernel/linux/v4.19/drivers/misc/mediatek/lpm/modules/platform/mt6880/suspend/lynq_suspend.c b/src/kernel/linux/v4.19/drivers/misc/mediatek/lpm/modules/platform/mt6880/suspend/lynq_suspend.c
index a18793e..06d8fc8 100644
--- a/src/kernel/linux/v4.19/drivers/misc/mediatek/lpm/modules/platform/mt6880/suspend/lynq_suspend.c
+++ b/src/kernel/linux/v4.19/drivers/misc/mediatek/lpm/modules/platform/mt6880/suspend/lynq_suspend.c
@@ -62,6 +62,18 @@
 	act->post_mdelay_time = -1;
 }
 
+static inline void dump_one_node(struct gpio_action_node * node)
+{
+	struct gpio_action * act = NULL;
+	if (node == NULL)
+		return;
+	printk("condition module name [%s], num %d, need_action %d\n", node->valid_absence_of_module, node->gpio_num, node->need_action);
+	act = &node->actions[ACT_SUSPEND];
+	printk("suspend action: mode %d, dir %d, value %d, predelay %d, post delay %d\n", act->gpio_mode, act->gpio_dir, act->gpio_value, act->pre_mdelay_time, act->post_mdelay_time);
+	act = &node->actions[ACT_RESUME];
+	printk("resume acttion: mode %d, dir %d, value %d, predelay %d, post delay %d\n", act->gpio_mode, act->gpio_dir, act->gpio_value, act->pre_mdelay_time, act->post_mdelay_time);
+}
+
 static inline struct gpio_action_node * __inner_alloc_gpio_action_node(void)
 {
 	int i;
@@ -306,17 +318,21 @@
 
 	printk("to find act_suspend\n");
 	gpio_next_node = of_find_node_by_name(gpio_node, "suspend");
-	if (gpio_next_node == NULL)
+	if (gpio_next_node == NULL || of_get_parent(gpio_next_node) != gpio_node)
 		printk("no act_suspend node found\n");
 	else
+	{
 		printk("find act_suspend\n");
-	read_one_action(gpio_next_node, &action_node->actions[ACT_SUSPEND]);
+		read_one_action(gpio_next_node, &action_node->actions[ACT_SUSPEND]);
+	}
 	gpio_next_node = of_find_node_by_name(gpio_node, "resume");
-	if (gpio_next_node == NULL)
+	if (gpio_next_node == NULL || of_get_parent(gpio_next_node) != gpio_node)
 		printk("no act_resume node found\n");
 	else
+	{
 		printk("find act_resume\n");
-	read_one_action(gpio_next_node, &action_node->actions[ACT_RESUME]);
+		read_one_action(gpio_next_node, &action_node->actions[ACT_RESUME]);
+	}
 
 	return 0;
 }
@@ -356,7 +372,11 @@
             break;
         }
 		lpm_gpio_list[i] = __inner_alloc_gpio_action_node();
+		printk("dump before read\n");
+		dump_one_node(lpm_gpio_list[i]);
 		read_one_node(gpio_next_node, lpm_gpio_list[i]);
+		printk("dump after read\n");
+		dump_one_node(lpm_gpio_list[i]);
 		printk("read one node finish\n");
     }