Use of of_parse_phandle()/of_node_put()

Peter Ujfalusi peter.ujfalusi at ti.com
Thu Feb 14 02:52:34 EST 2013


On 02/13/2013 07:04 AM, Kumar, Anil wrote:
> Hi  Peter,
>  
> Just trying to understand.
>  
> In omap-twl4030.c file probe function :-
>  
> dai_node = of_parse_phandle(node, "ti,mcbsp", 0);
>                 if (!dai_node) {
>                         dev_err(&pdev->dev, "McBSP node is not provided\n");
>                         return -EINVAL;
>                 }
>  
> Here  “of_parse_phandle()”  is used to get  “of_device” node pointer.
> of_parse_phandle() suggest to use of_node_put()  on it when done.
>  
> It looks when code request for an “of_device” node, kernel  maintains
> “refcount” for this.
> It check “refcount”  before giving pointer of of_device node and  WARN_ON()
> in case of refcount  > 0 and increase it on success.
>  
> Should this code need to use of_node_put() on the requested “of_device” when done
> so that this can be get  again ?

Hrm, one thing or sure we should not call it of_node_put() while we have the
card loaded since the node is used runtime by the core.

However when we unload the machine driver it might be needed, but not sure
about this. None of the existing machine drivers doing it (tegra, samsung,
omap, etc).
But if it is needed it might be better to be done by the core?

>  
> I am taking reference of Linux-next kernel.
>  
> I'm sorry if this question is very vague or  missing something.
>  
> Thanks,
> Anil
>  
>  
>  
>  
>  
>  


-- 
Péter


More information about the devicetree-discuss mailing list