diff options
author | Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> | 2024-01-29 14:52:11 +0300 |
---|---|---|
committer | Philipp Zabel <p.zabel@pengutronix.de> | 2024-02-21 13:53:24 +0300 |
commit | 26ea8511c849f9fea325bcdbd8b41ea031a53afe (patch) | |
tree | 84feaebbb955f40c9c4b2f721e13f783cea2cd63 /include/linux/of.h | |
parent | a6166a4da5e46a01e6ad5b0bb079d77ac653f594 (diff) | |
download | linux-26ea8511c849f9fea325bcdbd8b41ea031a53afe.tar.xz |
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 <p.zabel@pengutronix.de>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240129115216.96479-2-krzysztof.kozlowski@linaro.org
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Diffstat (limited to 'include/linux/of.h')
-rw-r--r-- | include/linux/of.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/linux/of.h b/include/linux/of.h index 6a9ddf20e79a..85bcc05b278d 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -1066,6 +1066,22 @@ static inline int of_parse_phandle_with_optional_args(const struct device_node * } /** + * of_phandle_args_equal() - Compare two of_phandle_args + * @a1: First of_phandle_args to compare + * @a2: Second of_phandle_args to compare + * + * Return: True if a1 and a2 are the same (same node pointer, same phandle + * args), false otherwise. + */ +static inline bool of_phandle_args_equal(const struct of_phandle_args *a1, + const struct of_phandle_args *a2) +{ + return a1->np == a2->np && + a1->args_count == a2->args_count && + !memcmp(a1->args, a2->args, sizeof(a1->args[0]) * a1->args_count); +} + +/** * of_property_count_u8_elems - Count the number of u8 elements in a property * * @np: device node from which the property value is to be read. |