Skip to content

Commit 26ea851

Browse files
krzkpH5
authored andcommitted
of: Add of_phandle_args_equal() helper
Add a helper comparing two "struct of_phandle_args" to avoid reinventing the wheel. Reviewed-by: Philipp Zabel <[email protected]> Acked-by: Rob Herring <[email protected]> Signed-off-by: Krzysztof Kozlowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Philipp Zabel <[email protected]>
1 parent a6166a4 commit 26ea851

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

include/linux/of.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,22 @@ static inline int of_parse_phandle_with_optional_args(const struct device_node *
10651065
0, index, out_args);
10661066
}
10671067

1068+
/**
1069+
* of_phandle_args_equal() - Compare two of_phandle_args
1070+
* @a1: First of_phandle_args to compare
1071+
* @a2: Second of_phandle_args to compare
1072+
*
1073+
* Return: True if a1 and a2 are the same (same node pointer, same phandle
1074+
* args), false otherwise.
1075+
*/
1076+
static inline bool of_phandle_args_equal(const struct of_phandle_args *a1,
1077+
const struct of_phandle_args *a2)
1078+
{
1079+
return a1->np == a2->np &&
1080+
a1->args_count == a2->args_count &&
1081+
!memcmp(a1->args, a2->args, sizeof(a1->args[0]) * a1->args_count);
1082+
}
1083+
10681084
/**
10691085
* of_property_count_u8_elems - Count the number of u8 elements in a property
10701086
*

0 commit comments

Comments
 (0)