summaryrefslogtreecommitdiff
path: root/dtc.h
diff options
context:
space:
mode:
authorIlya Lipnitskiy <ilya.lipnitskiy@gmail.com>2021-05-03 20:59:42 -0700
committerDavid Gibson <david@gibson.dropbear.id.au>2021-05-04 14:45:20 +1000
commit09c6a6e88718de6b2ef646a015187605caa5789f (patch)
tree9be8e7b98c0655c150c2f85177598ddde854e0f1 /dtc.h
parent9bb9b8d0b4a03d119162221cbdfd91354653d902 (diff)
downloaddevice-tree-compiler-09c6a6e88718de6b2ef646a015187605caa5789f.tar.gz
dtc.h: add strends for suffix matching
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@gmail.com> Message-Id: <20210504035944.8453-3-ilya.lipnitskiy@gmail.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'dtc.h')
-rw-r--r--dtc.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/dtc.h b/dtc.h
index d3e82fb..6296361 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))