On Thu, Feb 8, 2024 at 9:22 AM Stanislaw Gruszka <stanislaw.gruszka@xxxxxxxxxxxxxxx> wrote: > > On Mon, Feb 05, 2024 at 10:14:31PM +0100, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx> > > > > The current code requires thermal zone creators to pass a pointer to a > > writable trips table to thermal_zone_device_register_with_trips() and > > that trips table is then used by the thermal core going forward. > > > > Consequently, the callers of thermal_zone_device_register_with_trips() > > are required to hold on to the trips table passed to it until the given > > thermal zone is unregistered, at which point the trips table can be > > freed, but at the same time they are not allowed to access the cells in > > that table directly. This is both error prone and confusing. > > > > To address it, turn the trips table pointer in struct thermal_zone_device > > into a flex array (counted by its num_trips field), allocate it during > > thermal zone device allocation and copy the contents of the trips table > > supplied by the zone creator (which can be const now) into it. > > > > This allows the callers of thermal_zone_device_register_with_trips() to > > drop their trip tables right after the zone registration. > > > > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx> > Reviewed-by: Stanislaw Gruszka <stanislaw.gruszka@xxxxxxxxxxxxxxx> Thanks a lot for all of the reviews, much appreciated, especially regarding the Intel drivers changes. Unfortunately, this patch series, and the first half of it in particular, is somewhat premature, because a couple of thermal drivers do unexpected things to their trip point tables and they need to be modified to stop accessing the trip tables directly before the core can start using internal copies of them. I'm going to save the tags for the future, however.