[PATCH 2/3] of: early exit of_match_node if no better matches are possible
Ahmad Fatoum
a.fatoum at pengutronix.de
Tue Dec 5 03:36:17 PST 2023
The maximum score that can be returned by of_device_is_compatible is
OF_DEVICE_COMPATIBLE_MAX_SCORE. Once that score is returned, there is no
point in continuing with the string comparisons, so just early exit.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
drivers/of/base.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 8a42fcee1d40..b22959dabebf 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -717,6 +717,9 @@ const struct of_device_id *of_match_node(const struct of_device_id *matches,
if (score > best_score) {
best_match = matches;
best_score = score;
+
+ if (score == OF_DEVICE_COMPATIBLE_MAX_SCORE)
+ break;
}
}
--
2.39.2
More information about the barebox
mailing list