Skip to contentSkip to conversation

device property: Drop redundant NULL checks

PATCH In review Andy Shevchenko 3 participants 3 messages Oct 26, 2021

Subsystems (3)
lore
Share & tools
lore

Andy Shevchenko

author reviewer
#0 lore raw

PATCH 1/1 device property: Drop redundant NULL checks

In cases when functions are called via fwnode operations, we already know that this is software node we are dealing with, hence no need to check if it's NULL, it can't be,

---
 drivers/base/swnode.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/base/swnode.c +0 -6
index c46f6a8e14d2..4debcea4fb12 100644
@@ -413,9 +413,6 @@ software_node_get_name(const struct fwnode_handle *fwnode)
 {
 	const struct swnode *swnode = to_swnode(fwnode);
 
-	if (!swnode)
-		return "(null)";
-
 	return kobject_name(&swnode->kobj);
 }
 
@@ -507,9 +504,6 @@ software_node_get_reference_args(const struct fwnode_handle *fwnode,
 	int error;
 	int i;
 
-	if (!swnode)
-		return -ENOENT;
-
 	prop = property_entry_get(swnode->node->properties, propname);
 	if (!prop)
 		return -ENOENT;
Signature · 1 line
2.33.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Andy Shevchenko

In cases when functions are called via fwnode operations, we already know that this is software node we are dealing with, hence no need to check if it's NULL, it can't be,

or please let me know if I need to pick this up.

Quoted 31 lines
---
 drivers/base/swnode.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/base/swnode.c +0 -7
index c46f6a8e14d2..4debcea4fb12 100644
@@ -413,9 +413,6 @@ software_node_get_name(const struct fwnode_handle *fwnode)
 {
        const struct swnode *swnode = to_swnode(fwnode);
 
-       if (!swnode)
-               return "(null)";
-
        return kobject_name(&swnode->kobj);
 }
 
@@ -507,9 +504,6 @@ software_node_get_reference_args(const struct fwnode_handle *fwnode,
        int error;
        int i;
 
-       if (!swnode)
-               return -ENOENT;
-
        prop = property_entry_get(swnode->node->properties, propname);
        if (!prop)
                return -ENOENT;
--

2.33.0

#2 lore raw
Quoted 7 lines · Rafael J. Wysocki
Quoted 5 lines · Andy Shevchenko

In cases when functions are called via fwnode operations, we already know that this is software node we are dealing with, hence no need to check if it's NULL, it can't be,

Quoted 6 lines
Quoted 2 lines

or please let me know if I need to pick this up.

I can take it, thanks!

greg k-h