software node: Deduplicate code in fwnode_create_software_node()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 29 Mar 2021 15:12:04 +0000 (18:12 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 5 Apr 2021 11:18:22 +0000 (13:18 +0200)
Deduplicate conditional and assignment in fwnode_create_software_node(),
i.e. parent is checked in two out of three cases and parent software node
is assigned by to_swnode() call.

Reviewed-by: Daniel Scally <djrscally@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210329151207.36619-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/swnode.c

index 6906a0a..082e0b0 100644 (file)
@@ -981,15 +981,14 @@ fwnode_create_software_node(const struct property_entry *properties,
 {
        struct fwnode_handle *fwnode;
        struct software_node *node;
-       struct swnode *p = NULL;
-
-       if (parent) {
-               if (IS_ERR(parent))
-                       return ERR_CAST(parent);
-               if (!is_software_node(parent))
-                       return ERR_PTR(-EINVAL);
-               p = to_swnode(parent);
-       }
+       struct swnode *p;
+
+       if (IS_ERR(parent))
+               return ERR_CAST(parent);
+
+       p = to_swnode(parent);
+       if (parent && !p)
+               return ERR_PTR(-EINVAL);
 
        node = software_node_alloc(properties);
        if (IS_ERR(node))