• Rafael J. Wysocki's avatar
    thermal: core: Store zone trips table in struct thermal_zone_device · 9b0a6275
    Rafael J. Wysocki authored
    The current code expects 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 expected to access 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, which
    will allow the callers of thermal_zone_device_register_with_trips() to
    drop their trip tables right after the zone registration.
    
    This requires the imx thermal driver to be adjusted to store the new
    temperature in its internal trips table in imx_set_trip_temp(), because
    it will be separate from the core's trips table now and it has to be
    explicitly kept in sync with the latter.
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    Reviewed-by: default avatarStanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
    Reviewed-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
    9b0a6275
imx_thermal.c 24.2 KB