powerpc/powermac: Use of_property_match_string() in pmac_has_backlight_type()
authorMarkus Elfring <elfring@users.sourceforge.net>
Fri, 11 Oct 2024 16:10:06 +0000 (18:10 +0200)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 14 Nov 2024 11:52:43 +0000 (22:52 +1100)
Replace an of_get_property() call by of_property_match_string()
so that this function implementation can be simplified.

Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/linuxppc-dev/d9bdc1b6-ea7e-47aa-80aa-02ae649abf72@csgroup.eu/
Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/linuxppc-dev/87cyk97ufp.fsf@mail.lhotse/
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://patch.msgid.link/ede25e03-7a14-4787-ae1b-4fc9290add5a@web.de
arch/powerpc/platforms/powermac/backlight.c

index 12bc013..7974137 100644 (file)
@@ -57,18 +57,10 @@ struct backlight_device *pmac_backlight;
 int pmac_has_backlight_type(const char *type)
 {
        struct device_node* bk_node = of_find_node_by_name(NULL, "backlight");
+       int i = of_property_match_string(bk_node, "backlight-control", type);
 
-       if (bk_node) {
-               const char *prop = of_get_property(bk_node,
-                               "backlight-control", NULL);
-               if (prop && strncmp(prop, type, strlen(type)) == 0) {
-                       of_node_put(bk_node);
-                       return 1;
-               }
-               of_node_put(bk_node);
-       }
-
-       return 0;
+       of_node_put(bk_node);
+       return i >= 0;
 }
 
 static void pmac_backlight_key_worker(struct work_struct *work)