why use 'raw_spin_lock_irqsave' inf function 'of_find_node_with_property'

2 messages, 2 authors, 2012-03-29 · open the first message on its own page

why use 'raw_spin_lock_irqsave' inf function 'of_find_node_with_property'

From: Huang Changming-R66093 <hidden>
Date: 2012-03-29 10:01:32

Hi, all
In function "of_find_node_with_property", why use "raw_spin_lock_irqsave" to disable preemption and disable interrupt?
If enable them, what impact will be observed?
This function just finds the node from the DTS file, it can't be interrupted or preempted?

I have done one test: remove "raw_spin_lock_irqsave" and "raw_spin_unlock_irqrestore" from this function,
It seems there is no any bad result, the Linux kernel still work well.

Best Regards
Jerry Huang

Re: why use 'raw_spin_lock_irqsave' inf function 'of_find_node_with_property'

From: Tabi Timur-B04825 <hidden>
Date: 2012-03-29 15:48:46

On Thu, Mar 29, 2012 at 5:01 AM, Huang Changming-R66093
[off-list ref] wrote:
Hi, all

In function =93of_find_node_with_property=94, why use =93raw_spin_lock_ir=
qsave=94 to
disable preemption and disable interrupt?
Where do you see raw_spin_lock_irqsave?

struct device_node *of_find_node_with_property(struct device_node *from,
	const char *prop_name)
{
	struct device_node *np;
	struct property *pp;

	read_lock(&devtree_lock);
	np =3D from ? from->allnext : allnodes;
	for (; np; np =3D np->allnext) {
		for (pp =3D np->properties; pp !=3D 0; pp =3D pp->next) {
			if (of_prop_cmp(pp->name, prop_name) =3D=3D 0) {
				of_node_get(np);
				goto out;
			}
		}
	}
out:
	of_node_put(from);
	read_unlock(&devtree_lock);
	return np;
}

We need a lock so that we don't parse the tree while it's being
modified.  That would cause the for-loop to fail in strange ways.

--=20
Timur Tabi
Linux kernel developer at Freescale=
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help