]> git.ipfire.org Git - thirdparty/linux.git/commit
mlxsw: core_thermal: Use the .should_bind() thermal zone callback
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 19 Aug 2024 16:24:37 +0000 (18:24 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 22 Aug 2024 15:43:14 +0000 (17:43 +0200)
commit6d9149e75b810a08226fbe5e2b4e63036641bcc1
tree7cd73b74455ff6c61bd11bfc11221d24bfa6f52c
parent13b6b63d6becb62ede986f35b14c873ac935e2e3
mlxsw: core_thermal: Use the .should_bind() thermal zone callback

Make the mlxsw core_thermal driver use the .should_bind() thermal zone
callback to provide the thermal core with the information on whether or
not to bind the given cooling device to the given trip point in the
given thermal zone.  If it returns 'true', the thermal core will bind
the cooling device to the trip and the corresponding unbinding will be
taken care of automatically by the core on the removal of the involved
thermal zone or cooling device.

It replaces the .bind() and .unbind() thermal zone callbacks (in 3
places) which assumed the same trip points ordering in the driver
and in the thermal core (that may not be true any more in the
future).  The .bind() callbacks used loops over trip point indices
to call thermal_zone_bind_cooling_device() for the same cdev (once
it had been verified) and all of the trip points, but they passed
different 'upper' and 'lower' values to it for each trip.

To retain the original functionality, the .should_bind() callbacks
need to use the same 'upper' and 'lower' values that would be used
by the corresponding .bind() callbacks when they are about to return
'true'.  To that end, the 'priv' field of each trip is set during the
thermal zone initialization to point to the corresponding 'state'
object containing the maximum and minimum cooling states of the
cooling device.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/2216931.Icojqenx9y@rjwysocki.net
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c