Re: [PATCH 3/4] thermal/core: Allocate the thermal class dynamically

From: Daniel Lezcano

Date: Fri May 08 2026 - 15:23:03 EST


On 5/8/26 20:24, Rafael J. Wysocki wrote:
On Fri, May 8, 2026 at 8:05 PM Daniel Lezcano
<daniel.lezcano@xxxxxxxxxxxxxxxx> wrote:

Use class_create() instead of a statically allocated struct class.

This allows the thermal class to be managed through a dynamically
allocated class object and avoids keeping a static class instance
around.

I changed it the other way around during the last cycle, so is it
really worth changing again?

Yes, I think it is because it does not reintroduce this change:

- thermal_class = kzalloc_obj(*thermal_class);
- if (!thermal_class) {
- result = -ENOMEM;
+ result = class_register(&thermal_class);
+ if (result)
goto unregister_governors;
- }

- thermal_class->name = "thermal";
- thermal_class->dev_release = thermal_release;
-
- result = class_register(thermal_class);
- if (result) {
- kfree(thermal_class);
- thermal_class = NULL;
- goto unregister_governors;
- }

It is replaced by thermal_create("thermal") which allocates and registers the class and we get rid of two global variables. But up to you.