On Fri, Oct 4, 2024 at 3:43 PM Rafael J. Wysocki <rafael@xxxxxxxxxx> wrote:
On Fri, Oct 4, 2024 at 3:37 PM Lukasz Luba <lukasz.luba@xxxxxxx> wrote:
On 10/4/24 14:25, Rafael J. Wysocki wrote:
Hi Łukasz,
On Fri, Oct 4, 2024 at 10:01 AM Lukasz Luba <lukasz.luba@xxxxxxx> wrote:
Hi Rafael,
On 10/3/24 13:25, Rafael J. Wysocki wrote:
From: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
I wasn't aware of that helpers in cleanup.h.
Could you help me to understand when this this
'if (_T) put_device((&_T->device)' will be called?
When the pointer variable initialized via the CLASS() macro goes out
of scope (that is, before freeing the memory occupied by the pointer
itself).
OK, so do we still need the old code in
thermal_zone_device_unregister(), which calls
put_device(&tz->device) ?
Yes, we do.
Maybe that code can go away?
That particular one drops the reference acquired by device_register()
and I don't see an alternative clean way to drop it.
The problem there is that local variable tz goes out of scope at the
end of the function (at least formally) and put_device(&tz->device)
needs to be called before the wait_for_completion(&tz->removal) which
definitely needs tz to be still around.