diff options
author | Dong Aisheng <dong.aisheng@linaro.org> | 2012-07-11 01:16:37 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2012-07-11 01:26:51 -0400 |
commit | 475d0094293b51353e342d1198377967dbc48169 (patch) | |
tree | b10a01706dd433b93353600a00491ce62e385ec9 /drivers/of/base.c | |
parent | b416c9a10baae6a177b4f9ee858b8d309542fbef (diff) |
of: Improve prom_update_property() function
prom_update_property() currently fails if the property doesn't
actually exist yet which isn't what we want. Change to add-or-update
instead of update-only, then we can remove a lot duplicated lines.
Suggested-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
Acked-by: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'drivers/of/base.c')
-rw-r--r-- | drivers/of/base.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index eada3f4ef801..bc86ea2af668 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
@@ -1073,7 +1073,8 @@ int prom_remove_property(struct device_node *np, struct property *prop) | |||
1073 | } | 1073 | } |
1074 | 1074 | ||
1075 | /* | 1075 | /* |
1076 | * prom_update_property - Update a property in a node. | 1076 | * prom_update_property - Update a property in a node, if the property does |
1077 | * not exist, add it. | ||
1077 | * | 1078 | * |
1078 | * Note that we don't actually remove it, since we have given out | 1079 | * Note that we don't actually remove it, since we have given out |
1079 | * who-knows-how-many pointers to the data using get-property. | 1080 | * who-knows-how-many pointers to the data using get-property. |
@@ -1081,13 +1082,19 @@ int prom_remove_property(struct device_node *np, struct property *prop) | |||
1081 | * and add the new property to the property list | 1082 | * and add the new property to the property list |
1082 | */ | 1083 | */ |
1083 | int prom_update_property(struct device_node *np, | 1084 | int prom_update_property(struct device_node *np, |
1084 | struct property *newprop, | 1085 | struct property *newprop) |
1085 | struct property *oldprop) | ||
1086 | { | 1086 | { |
1087 | struct property **next; | 1087 | struct property **next, *oldprop; |
1088 | unsigned long flags; | 1088 | unsigned long flags; |
1089 | int found = 0; | 1089 | int found = 0; |
1090 | 1090 | ||
1091 | if (!newprop->name) | ||
1092 | return -EINVAL; | ||
1093 | |||
1094 | oldprop = of_find_property(np, newprop->name, NULL); | ||
1095 | if (!oldprop) | ||
1096 | return prom_add_property(np, newprop); | ||
1097 | |||
1091 | write_lock_irqsave(&devtree_lock, flags); | 1098 | write_lock_irqsave(&devtree_lock, flags); |
1092 | next = &np->properties; | 1099 | next = &np->properties; |
1093 | while (*next) { | 1100 | while (*next) { |