OF: base: fix infinite loop in of_find_matching_node_and_match

of_find_matching_node_and_match macro can loop infinitely, because it
does not check for root node of the tree iterated over. This adds a
check for parent pointer of last tested iterator entry, which is
NULL for the root node.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Reported-by: Hiroki Nishimoto <hiroki.nishimoto.if@gmail.com>
OF: base: fix infinite loop in of_find_node_by_name

of_find_node_by_name suffers from infinite looping, because it
does not check for root node of the tree iterated over. This adds a
check for parent pointer of last tested iterator entry, which is
NULL for the root node.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
OF: base: fix infinite loop in of_find_compatible_node

of_find_compatible_node suffers from infinite looping, because it
does not check for root node of the tree iterated over. This adds a
check for parent pointer of last tested iterator entry, which is
NULL for the root node.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
OF: base: fix infinite loop in of_find_node_with_property

of_find_node_with_property suffers from infinite looping, because it
does not check for root node of the tree iterated over. This adds a
check for parent pointer of last tested iterator entry, which is
NULL for the root node. Also set from node to current root_node if
NULL.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
OF: base: fix iterator in of_get_next_available_child

of_get_next_available_child does not iterate but always tries the
same node over and over again. This first prepares the entry and
then uses list_for_each_entry_continue, instead of list_for_each_entry
before.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>