[PATCH] ppc64: SMU partitions & device-tree
Nathan Lynch
ntl at pobox.com
Fri Sep 23 01:29:21 EST 2005
Benjamin Herrenschmidt wrote:
> In order to update the device-tree, I made changes to
> prom_add_property() so that it now updates the proc entries as well
> (and gets some locking too while we are at it). I also removed the
> code in proc_devtree.c that tried to enforce the order of the
> properties & nodes as it really didn't look good and shouldn't be
> necessary.
> -void
> +int
> prom_add_property(struct device_node* np, struct property* prop)
> {
> - struct property **next = &np->properties;
> + struct property **next;
>
> prop->next = NULL;
> - while (*next)
> + write_lock(&devtree_lock);
> + next = &np->properties;
> + while (*next) {
> + if (strcmp(prop->name, (*next)->name) == 0) {
> + /* duplicate ! don't insert it */
> + write_unlock(&devtree_lock);
> + return -1;
> + }
> next = &(*next)->next;
> + }
> *next = prop;
> + write_unlock(&devtree_lock);
> +
> + /* try to add to proc as well if it was initialized */
> + if (np->pde)
> + proc_device_tree_add_prop(np->pde, prop);
> +
> + return 0;
> }
I think this is abusing devtree_lock, which is meant to protect
traversal of the device tree and not the contents of nodes. True,
this serializes prom_add_property itself, and will prevent corruption
of the node's property list. But I think I'd rather the SMU code take
care of this itself, i.e. use its own mutex to serialize the addition
of properties to /smu.
More information about the Linuxppc64-dev
mailing list