Skip to contentSkip to conversation

of: Clean up of_update_property

PATCH Applied Guenter Roeck 3 participants 3 messages Apr 15, 2014 – Apr 22, 2014 Device tree

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 of: Clean up of_update_property

After searching for the old property, bail out with -ENODEV if it was not found.

It is unnecessary to check if oldprop is NULL before removing its binary file; the check was already done before.

---
 drivers/of/base.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/of/base.c +3 -7
index f72d19b..6d4ee22 100644
@@ -1828,17 +1828,13 @@ int of_update_property(struct device_node *np, struct property *newprop)
 		next = &(*next)->next;
 	}
 	raw_spin_unlock_irqrestore(&devtree_lock, flags);
-	if (rc)
-		return rc;
+	if (!found)
+		return -ENODEV;
 
 	/* Update the sysfs attribute */
-	if (oldprop)
-		sysfs_remove_bin_file(&np->kobj, &oldprop->attr);
+	sysfs_remove_bin_file(&np->kobj, &oldprop->attr);
 	__of_add_property_sysfs(np, newprop);
 
-	if (!found)
-		return -ENODEV;
-
 	return 0;
 }
 
Signature · 6 lines
1.7.9.7

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Applied
#1 lore raw
Quoted 7 lines · Guenter Roeck

After searching for the old property, bail out with -ENODEV if it was not found.

It is unnecessary to check if oldprop is NULL before removing its binary file; the check was already done before.

Applied. Thanks.

Rob

Quoted 32 lines
---
 drivers/of/base.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/of/base.c +3 -8
index f72d19b..6d4ee22 100644
@@ -1828,17 +1828,13 @@ int of_update_property(struct device_node *np, struct property *newprop)
                next = &(*next)->next;
        }
        raw_spin_unlock_irqrestore(&devtree_lock, flags);
-       if (rc)
-               return rc;
+       if (!found)
+               return -ENODEV;
 
        /* Update the sysfs attribute */
-       if (oldprop)
-               sysfs_remove_bin_file(&np->kobj, &oldprop->attr);
+       sysfs_remove_bin_file(&np->kobj, &oldprop->attr);
        __of_add_property_sysfs(np, newprop);
 
-       if (!found)
-               return -ENODEV;
-
        return 0;
 }
 
--

1.7.9.7

#2 lore raw
In reply to Guenter Roeck
Quoted 18 lines · Guenter Roeck

After searching for the old property, bail out with -ENODEV if it was not found.

It is unnecessary to check if oldprop is NULL before removing its binary file; the check was already done before.

---
 drivers/of/base.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/of/base.c +0 -0
index f72d19b..6d4ee22 100644
@@ -1828,17 +1828,13 @@ int of_update_property(struct device_node *np, struct property *newprop)
 		next = &(*next)->next;
 	}

drivers/of/base.c int of_update_property(struct device_node *np, struct property *newprop) · line 1835

Quoted 10 lines
drivers/of/base.c +3 -4
 	raw_spin_unlock_irqrestore(&devtree_lock, flags);
-	if (rc)
-		return rc;
+	if (!found)
+		return -ENODEV;
 
 	/* Update the sysfs attribute */
-	if (oldprop)
-		sysfs_remove_bin_file(&np->kobj, &oldprop->attr);
+	sysfs_remove_bin_file(&np->kobj, &oldprop->attr);

Hahaha. The funny think is that I had to put this change right back in when picking up Xiubo's patch. The logic has become slightly different with his fix though, so it doesn't make this patch incorrect.

g.

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html