Logic is similar to strcmp_suffix in <kernel>/drivers/of/property.c with the exception that strends allows string length to equal suffix length. Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@xxxxxxxxx> --- dtc.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dtc.h b/dtc.h index d3e82fb8e3db..62963617c79a 100644 --- a/dtc.h +++ b/dtc.h @@ -86,6 +86,16 @@ static inline uint64_t dtb_ld64(const void *p) #define streq(a, b) (strcmp((a), (b)) == 0) #define strstarts(s, prefix) (strncmp((s), (prefix), strlen(prefix)) == 0) #define strprefixeq(a, n, b) (strlen(b) == (n) && (memcmp(a, b, n) == 0)) +static inline bool strends(const char *str, const char *suffix) +{ + unsigned int len, suffix_len; + + len = strlen(str); + suffix_len = strlen(suffix); + if (len < suffix_len) + return false; + return streq(str + len - suffix_len, suffix); +} #define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) -- 2.31.1