2014-04-15 15:38:31

by Guenter Roeck

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Guenter Roeck <[email protected]>
---
drivers/of/base.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index f72d19b..6d4ee22 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -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


2014-04-15 20:23:50

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH] of: Clean up of_update_property

On Tue, Apr 15, 2014 at 10:38 AM, Guenter Roeck <[email protected]> wrote:
> 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.
>
> Signed-off-by: Guenter Roeck <[email protected]>

Applied. Thanks.

Rob

> ---
> drivers/of/base.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index f72d19b..6d4ee22 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -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
>

2014-04-22 14:39:58

by Grant Likely

[permalink] [raw]
Subject: Re: [PATCH] of: Clean up of_update_property

On Tue, 15 Apr 2014 08:38:17 -0700, Guenter Roeck <[email protected]> wrote:
> 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.
>
> Signed-off-by: Guenter Roeck <[email protected]>
> ---
> drivers/of/base.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index f72d19b..6d4ee22 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -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);

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.