thermal/core: Alloc-copy-free the thermal zone parameters structure
authorDaniel Lezcano <daniel.lezcano@linaro.org>
Tue, 4 Apr 2023 07:51:37 +0000 (09:51 +0200)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Fri, 7 Apr 2023 16:36:28 +0000 (18:36 +0200)
commit3d439b1a2ad36c8b4ea151c8de25309d60d17407
tree5fc9e9468c9bd6190ef32a5c32d6086bf9b3759c
parentac614a9b4c35bf766dec40d73cbbc7f37c1734f7
thermal/core: Alloc-copy-free the thermal zone parameters structure

The caller of the function thermal_zone_device_register_with_trips()
can pass a thermal_zone_params structure parameter.

This one is used by the thermal core code until the thermal zone is
destroyed. That forces the caller, so the driver, to keep the pointer
valid until it unregisters the thermal zone if we want to make the
thermal zone device structure private the core code.

As the thermal zone device structure would be private, the driver can
not access to thermal zone device structure to retrieve the tzp field
after it passed it to register the thermal zone.

So instead of forcing the users of the function to deal with the tzp
structure life cycle, make the usage easier by allocating our own
thermal zone params, copying the parameter content and by freeing at
unregister time. The user can then create the parameters on the stack,
pass it to the registering function and forget about it.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20230404075138.2914680-3-daniel.lezcano@linaro.org
drivers/thermal/thermal_core.c