• Rafael J. Wysocki's avatar
    thermal: core: Store zone ops in struct thermal_zone_device · 698a1eb1
    Rafael J. Wysocki authored
    The current code requires thermal zone creators to pass pointers to
    writable ops structures to thermal_zone_device_register_with_trips()
    which needs to modify the target struct thermal_zone_device_ops object
    if the "critical" operation in it is NULL.
    
    Moreover, the callers of thermal_zone_device_register_with_trips() are
    required to hold on to the struct thermal_zone_device_ops object passed
    to it until the given thermal zone is unregistered.
    
    Both of these requirements are quite inconvenient, so modify struct
    thermal_zone_device to contain struct thermal_zone_device_ops as field and
    make thermal_zone_device_register_with_trips() copy the contents of the
    struct thermal_zone_device_ops passed to it via a pointer (which can be
    const now) to that field.
    
    Also adjust the code using thermal zone ops accordingly and modify
    thermal_of_zone_register() to use a local ops variable during
    thermal zone registration so ops do not need to be freed in
    thermal_of_zone_unregister() any more.
    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>
    698a1eb1
thermal_of.c 14.8 KB