Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 18319
b: refs/heads/master
c: 088186d
h: refs/heads/master
i:
  18317: 4bee818
  18315: 8fca2ba
  18311: 6450e04
  18303: 8e33995
v: v3
  • Loading branch information
Dave C Boutcher authored and Paul Mackerras committed Jan 13, 2006
1 parent 64eb144 commit e6a1e3c
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 898b5395e915210f41223caa30312994d64cba1d
refs/heads/master: 088186ded490ced80758200cf8f906ed741df306
90 changes: 88 additions & 2 deletions trunk/arch/powerpc/kernel/prom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,11 @@ static void of_node_release(struct kref *kref)
kfree(prop->value);
kfree(prop);
prop = next;

if (!prop) {
prop = node->deadprops;
node->deadprops = NULL;
}
}
kfree(node->intrs);
kfree(node->full_name);
Expand Down Expand Up @@ -1783,13 +1788,16 @@ unsigned char *get_property(struct device_node *np, const char *name,
{
struct property *pp;

read_lock(&devtree_lock);
for (pp = np->properties; pp != 0; pp = pp->next)
if (strcmp(pp->name, name) == 0) {
if (lenp != 0)
*lenp = pp->length;
return pp->value;
break;
}
return NULL;
read_unlock(&devtree_lock);

return pp ? pp->value : NULL;
}
EXPORT_SYMBOL(get_property);

Expand Down Expand Up @@ -1823,4 +1831,82 @@ int prom_add_property(struct device_node* np, struct property* prop)
return 0;
}

/*
* Remove a property from a node. Note that we don't actually
* remove it, since we have given out who-knows-how-many pointers
* to the data using get-property. Instead we just move the property
* to the "dead properties" list, so it won't be found any more.
*/
int prom_remove_property(struct device_node *np, struct property *prop)
{
struct property **next;
int found = 0;

write_lock(&devtree_lock);
next = &np->properties;
while (*next) {
if (*next == prop) {
/* found the node */
*next = prop->next;
prop->next = np->deadprops;
np->deadprops = prop;
found = 1;
break;
}
next = &(*next)->next;
}
write_unlock(&devtree_lock);

if (!found)
return -ENODEV;

#ifdef CONFIG_PROC_DEVICETREE
/* try to remove the proc node as well */
if (np->pde)
proc_device_tree_remove_prop(np->pde, prop);
#endif /* CONFIG_PROC_DEVICETREE */

return 0;
}

/*
* Update a property in a node. Note that we don't actually
* remove it, since we have given out who-knows-how-many pointers
* to the data using get-property. Instead we just move the property
* to the "dead properties" list, and add the new property to the
* property list
*/
int prom_update_property(struct device_node *np,
struct property *newprop,
struct property *oldprop)
{
struct property **next;
int found = 0;

write_lock(&devtree_lock);
next = &np->properties;
while (*next) {
if (*next == oldprop) {
/* found the node */
newprop->next = oldprop->next;
*next = newprop;
oldprop->next = np->deadprops;
np->deadprops = oldprop;
found = 1;
break;
}
next = &(*next)->next;
}
write_unlock(&devtree_lock);

if (!found)
return -ENODEV;

#ifdef CONFIG_PROC_DEVICETREE
/* try to add to proc as well if it was initialized */
if (np->pde)
proc_device_tree_update_prop(np->pde, newprop, oldprop);
#endif /* CONFIG_PROC_DEVICETREE */

return 0;
}
5 changes: 5 additions & 0 deletions trunk/include/asm-powerpc/prom.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ struct device_node {
char *full_name;

struct property *properties;
struct property *deadprops; /* removed properties */
struct device_node *parent;
struct device_node *child;
struct device_node *sibling;
Expand Down Expand Up @@ -164,6 +165,10 @@ extern int prom_n_size_cells(struct device_node* np);
extern int prom_n_intr_cells(struct device_node* np);
extern void prom_get_irq_senses(unsigned char *senses, int off, int max);
extern int prom_add_property(struct device_node* np, struct property* prop);
extern int prom_remove_property(struct device_node *np, struct property *prop);
extern int prom_update_property(struct device_node *np,
struct property *newprop,
struct property *oldprop);

#ifdef CONFIG_PPC32
/*
Expand Down

0 comments on commit e6a1e3c

Please sign in to comment.