Input: twl4030-vibra - use cleanup facility for device_node
authorJavier Carrasco <javier.carrasco.cruz@gmail.com>
Sun, 20 Oct 2024 04:07:41 +0000 (21:07 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sun, 20 Oct 2024 04:21:40 +0000 (21:21 -0700)
Use the '__free(device_node)' macro to simplify the code by
automatically freeing the device node.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20241010-input_automate_of_node_put-v1-5-ebc62138fbf8@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/misc/twl4030-vibra.c

index 101548b..5fa7d4a 100644 (file)
@@ -165,15 +165,10 @@ static DEFINE_SIMPLE_DEV_PM_OPS(twl4030_vibra_pm_ops,
 
 static bool twl4030_vibra_check_coexist(struct device_node *parent)
 {
-       struct device_node *node;
+       struct device_node *node __free(device_node) =
+               of_get_child_by_name(parent, "codec");
 
-       node = of_get_child_by_name(parent, "codec");
-       if (node) {
-               of_node_put(node);
-               return true;
-       }
-
-       return false;
+       return node != NULL;
 }
 
 static int twl4030_vibra_probe(struct platform_device *pdev)