]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
of: replace strcmp_suffix() with strends()
authorBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Wed, 17 Dec 2025 13:43:08 +0000 (14:43 +0100)
committerRob Herring (Arm) <robh@kernel.org>
Wed, 4 Feb 2026 02:58:09 +0000 (20:58 -0600)
string.h now provides strends() which fulfills the same role as the
locally implemented strcmp_suffix(). Use it in of/property.c.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Link: https://patch.msgid.link/20251217134308.33839-1-bartosz.golaszewski@oss.qualcomm.com
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
drivers/of/property.c

index 4e3524227720a596b0f12976f83357851e9b94f3..ce5ada040d7e52032d90686d2c3db6cf50af760f 100644 (file)
@@ -1294,17 +1294,6 @@ static struct device_node *parse_##fname(struct device_node *np,   \
        return parse_prop_cells(np, prop_name, index, name, cells);       \
 }
 
-static int strcmp_suffix(const char *str, const char *suffix)
-{
-       unsigned int len, suffix_len;
-
-       len = strlen(str);
-       suffix_len = strlen(suffix);
-       if (len <= suffix_len)
-               return -1;
-       return strcmp(str + len - suffix_len, suffix);
-}
-
 /**
  * parse_suffix_prop_cells - Suffix property parsing function for suppliers
  *
@@ -1331,7 +1320,7 @@ static struct device_node *parse_suffix_prop_cells(struct device_node *np,
 {
        struct of_phandle_args sup_args;
 
-       if (strcmp_suffix(prop_name, suffix))
+       if (!strends(prop_name, suffix))
                return NULL;
 
        if (of_parse_phandle_with_args(np, prop_name, cells_name, index,
@@ -1416,7 +1405,7 @@ DEFINE_SUFFIX_PROP(gpio, "-gpio", "#gpio-cells")
 static struct device_node *parse_gpios(struct device_node *np,
                                       const char *prop_name, int index)
 {
-       if (!strcmp_suffix(prop_name, ",nr-gpios"))
+       if (strends(prop_name, ",nr-gpios"))
                return NULL;
 
        return parse_suffix_prop_cells(np, prop_name, index, "-gpios",