devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Question] refcount of DT node
@ 2016-04-14  7:47 Masahiro Yamada
  2016-04-14  8:48 ` Russell King - ARM Linux
       [not found] ` <CAK7LNATFUW2KXUpFas6C_SJ0C7Qb1DWU0njLg-FCYciK2U6Oag-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 2 replies; 10+ messages in thread
From: Masahiro Yamada @ 2016-04-14  7:47 UTC (permalink / raw)
  To: devicetree
  Cc: Linux Kernel Mailing List, linux-arm-kernel, Rob Herring,
	Arnd Bergmann, Frank Rowand

Hi experts.

My understanding of refcount of DT node is poor.
Please help me understand it correctly.

Sorry if I am asking stupid questions.


[1] Does this reference count exist for Overlay?
    Is a node freed when its refcount becomes zero?


[2] When of_node_put() should be called,
     or should not be called?


Shouldn't of_node_put() be called
when we are still referencing to any of its properties?

For example,  cpu_read_enable_method()
in arch/arm64/kernel/cpu_ops.c
returns a pointer to the property value
instead of creating a copy of it.

In this case, of_node_put() should not be called
because we are still referencing the DT property
(in other words, referencing to the DT node indirectly).

Am I right?


[3] Is the following code correct?

   np = of_find_compatible_node(NULL, NULL,"foo-node");
   of_node_put(np);
   ret = of_address_to_resource(np, 0, &res);
   if (ret) {
            pr_err("failed to get resource\n");
            return ret;
   }

Actually I wrote the code above, and it was applied.

But, the node is still referenced while of_address_to_resource() is being run.

So the correct code should be as follows?

   np = of_find_compatible_node(NULL, NULL,"foo-node");
   ret = of_address_to_resource(np, 0, &res);
   of_node_put(np);
   if (ret) {
            pr_err("failed to get resource\n");
            return ret;
   }



-- 
Best Regards
Masahiro Yamada

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

end of thread, other threads:[~2016-04-16 15:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-14  7:47 [Question] refcount of DT node Masahiro Yamada
2016-04-14  8:48 ` Russell King - ARM Linux
     [not found]   ` <20160414084849.GT19428-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2016-04-14  9:59     ` Mark Rutland
2016-04-14 10:02       ` Pantelis Antoniou
     [not found]         ` <06E9E2D3-4627-4970-ABBB-34B5ED620709-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-04-14 16:10           ` Frank Rowand
2016-04-14 17:02           ` Rob Herring
2016-04-14 18:38       ` Russell King - ARM Linux
2016-04-16 15:02         ` Masahiro Yamada
     [not found] ` <CAK7LNATFUW2KXUpFas6C_SJ0C7Qb1DWU0njLg-FCYciK2U6Oag-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-04-14 10:10   ` Mark Rutland
2016-04-14 10:40     ` Pantelis Antoniou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).