All of lore.kernel.org
 help / color / mirror / Atom feed
* why use 'raw_spin_lock_irqsave'  inf function 'of_find_node_with_property'
@ 2012-03-29 10:01 Huang Changming-R66093
  2012-03-29 15:48 ` Tabi Timur-B04825
  0 siblings, 1 reply; 2+ messages in thread
From: Huang Changming-R66093 @ 2012-03-29 10:01 UTC (permalink / raw)
  To: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 480 bytes --]

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


[-- Attachment #2: Type: text/html, Size: 2660 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: why use 'raw_spin_lock_irqsave' inf function 'of_find_node_with_property'
  2012-03-29 10:01 why use 'raw_spin_lock_irqsave' inf function 'of_find_node_with_property' Huang Changming-R66093
@ 2012-03-29 15:48 ` Tabi Timur-B04825
  0 siblings, 0 replies; 2+ messages in thread
From: Tabi Timur-B04825 @ 2012-03-29 15:48 UTC (permalink / raw)
  To: Huang Changming-R66093; +Cc: linuxppc-dev

On Thu, Mar 29, 2012 at 5:01 AM, Huang Changming-R66093
<r66093@freescale.com> 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=

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-03-29 15:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-29 10:01 why use 'raw_spin_lock_irqsave' inf function 'of_find_node_with_property' Huang Changming-R66093
2012-03-29 15:48 ` Tabi Timur-B04825

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.