sbus: Use of_get_child_by_name helper
authorRob Herring <robh@kernel.org>
Wed, 29 Aug 2018 20:03:37 +0000 (15:03 -0500)
committerDavid S. Miller <davem@davemloft.net>
Mon, 8 Oct 2018 05:41:08 +0000 (22:41 -0700)
Use the of_get_child_by_name() helper instead of open coding searching
for the '/options' node. This removes directly accessing the name
pointer as well.

Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/sbus/char/openprom.c

index 7b31f19ade8318594a4745df869ee16ae1f3cabe..050879a2ddef28c7c0156359e3942cf483bdffaa 100644 (file)
@@ -715,22 +715,13 @@ static struct miscdevice openprom_dev = {
 
 static int __init openprom_init(void)
 {
-       struct device_node *dp;
        int err;
 
        err = misc_register(&openprom_dev);
        if (err)
                return err;
 
-       dp = of_find_node_by_path("/");
-       dp = dp->child;
-       while (dp) {
-               if (!strcmp(dp->name, "options"))
-                       break;
-               dp = dp->sibling;
-       }
-       options_node = dp;
-
+       options_node = of_get_child_by_name(of_find_node_by_path("/"), "options");
        if (!options_node) {
                misc_deregister(&openprom_dev);
                return -EIO;