At 2022-07-04 15:47:01, "Tony Lindgren" <tony@xxxxxxxxxxx> wrote: >* Liang He <windhl@xxxxxxx> [220701 14:22]: >> In omap2_prm_base_init(), for_each_matching_node_and_match() can >> automatically increase and decrease the refcounting. However, a >> new reference is escaped out into 'data->np', so we need to use >> of_node_put() for the old reference and use of_node_get() for the >> new one. >> >> Signed-off-by: Liang He <windhl@xxxxxxx> >> --- >> arch/arm/mach-omap2/prm_common.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c >> index fb2d48cfe756..bed151e3f165 100644 >> --- a/arch/arm/mach-omap2/prm_common.c >> +++ b/arch/arm/mach-omap2/prm_common.c >> @@ -764,7 +764,8 @@ int __init omap2_prm_base_init(void) >> prm_base.pa = res.start + data->offset; >> } >> >> - data->np = np; >> + of_node_put(data->np); >> + data->np = of_node_get(np); >> >> if (data->init) >> data->init(data); > >Hmm so I don't get how this improves things? Don't we enable with >the same refcounting? > >Regards, > >Tony Hi, Tony. Thanks very much for reviewing this patch. I try to explain as following: First, there is an old reference (pointer) pointing to device_node A and stored in data->np. Then, in the for_each_xxx iteration, 'np' is a new reference (pointer) pointing to device_node B. After 'data->np = np' is done, the old reference is destroyed and its refcount should be decreased. Similarly, a new reference to devce_node B is created in 'data->np', so its refcount should be increased. Sorry if my understanding is wrong or if I do not catch your point. Thans again, Liang