summaryrefslogtreecommitdiffstats
path: root/drivers/base/swnode.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2021-03-29 17:12:04 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-04-05 13:18:22 +0200
commit73c9342656fa610c2358ea7b867187104647f497 (patch)
tree2bfce98c12949e9096a1c5d97e074e18cf0c1ab8 /drivers/base/swnode.c
parentsoftware node: Introduce software_node_alloc()/software_node_free() (diff)
downloadlinux-73c9342656fa610c2358ea7b867187104647f497.tar.xz
linux-73c9342656fa610c2358ea7b867187104647f497.zip
software node: Deduplicate code in fwnode_create_software_node()
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>
Diffstat (limited to 'drivers/base/swnode.c')
-rw-r--r--drivers/base/swnode.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
index 6906a0a7cf47..082e0b07e5c3 100644
--- a/drivers/base/swnode.c
+++ b/drivers/base/swnode.c
@@ -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))