diff options
author | Grant Likely <grant.likely@linaro.org> | 2014-03-04 03:07:17 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@linaro.org> | 2014-03-04 03:20:42 -0500 |
commit | a3dbeb5b45af5b6113385db89fce2a8279278e8b (patch) | |
tree | 22d93e9d606fbee393796cc18b9659d817f704a1 /drivers/of/base.c | |
parent | f4d4ffc03efc864645b990e1d579bbe1b8e358a4 (diff) |
Revert "of: fix of_update_property()"
This reverts commit 02ed594e7113644c06ae3a89bc9215d839510efc.
The change is completely broken. It attempt to get the previous item in
a linked list by grabbing the address of a stack variable. Outright
wrong.
Signed-off-by: Grant Likely <grant.likely@linaro.org>
Diffstat (limited to 'drivers/of/base.c')
-rw-r--r-- | drivers/of/base.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index 239e3da9e728..a63e77694d0f 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
@@ -1597,7 +1597,7 @@ int of_update_property(struct device_node *np, struct property *newprop) | |||
1597 | { | 1597 | { |
1598 | struct property **next, *oldprop; | 1598 | struct property **next, *oldprop; |
1599 | unsigned long flags; | 1599 | unsigned long flags; |
1600 | int rc = 0; | 1600 | int rc, found = 0; |
1601 | 1601 | ||
1602 | rc = of_property_notify(OF_RECONFIG_UPDATE_PROPERTY, np, newprop); | 1602 | rc = of_property_notify(OF_RECONFIG_UPDATE_PROPERTY, np, newprop); |
1603 | if (rc) | 1603 | if (rc) |
@@ -1606,28 +1606,36 @@ int of_update_property(struct device_node *np, struct property *newprop) | |||
1606 | if (!newprop->name) | 1606 | if (!newprop->name) |
1607 | return -EINVAL; | 1607 | return -EINVAL; |
1608 | 1608 | ||
1609 | oldprop = of_find_property(np, newprop->name, NULL); | ||
1610 | if (!oldprop) | ||
1611 | return of_add_property(np, newprop); | ||
1612 | |||
1609 | raw_spin_lock_irqsave(&devtree_lock, flags); | 1613 | raw_spin_lock_irqsave(&devtree_lock, flags); |
1610 | oldprop = __of_find_property(np, newprop->name, NULL); | 1614 | next = &np->properties; |
1611 | if (!oldprop) { | 1615 | while (*next) { |
1612 | /* add the node */ | 1616 | if (*next == oldprop) { |
1613 | rc = __of_add_property(np, newprop); | 1617 | /* found the node */ |
1614 | } else { | 1618 | newprop->next = oldprop->next; |
1615 | /* replace the node */ | 1619 | *next = newprop; |
1616 | next = &oldprop; | 1620 | oldprop->next = np->deadprops; |
1617 | newprop->next = oldprop->next; | 1621 | np->deadprops = oldprop; |
1618 | *next = newprop; | 1622 | found = 1; |
1619 | oldprop->next = np->deadprops; | 1623 | break; |
1620 | np->deadprops = oldprop; | 1624 | } |
1625 | next = &(*next)->next; | ||
1621 | } | 1626 | } |
1622 | raw_spin_unlock_irqrestore(&devtree_lock, flags); | 1627 | raw_spin_unlock_irqrestore(&devtree_lock, flags); |
1623 | 1628 | ||
1629 | if (!found) | ||
1630 | return -ENODEV; | ||
1631 | |||
1624 | #ifdef CONFIG_PROC_DEVICETREE | 1632 | #ifdef CONFIG_PROC_DEVICETREE |
1625 | /* try to add to proc as well if it was initialized */ | 1633 | /* try to add to proc as well if it was initialized */ |
1626 | if (!rc && np->pde) | 1634 | if (!rc && np->pde) |
1627 | proc_device_tree_update_prop(np->pde, newprop, oldprop); | 1635 | proc_device_tree_update_prop(np->pde, newprop, oldprop); |
1628 | #endif /* CONFIG_PROC_DEVICETREE */ | 1636 | #endif /* CONFIG_PROC_DEVICETREE */ |
1629 | 1637 | ||
1630 | return rc; | 1638 | return 0; |
1631 | } | 1639 | } |
1632 | 1640 | ||
1633 | #if defined(CONFIG_OF_DYNAMIC) | 1641 | #if defined(CONFIG_OF_DYNAMIC) |