Skip to content

Commit 2dc2f76

Browse files
mellanoxbmcdavem330
authored andcommitted
mlxsw: core: Use different get_trend() callbacks for different thermal zones
The driver registers three different types of thermal zones: For the ASIC itself, for port modules and for gearboxes. Currently, all three types use the same get_trend() callback which does not work correctly for the ASIC thermal zone. The callback assumes that the device data is of type 'struct mlxsw_thermal_module', whereas for the ASIC thermal zone 'struct mlxsw_thermal' is passed as device data. Fix this by using one get_trend() callback for the ASIC thermal zone and another for the other two types. Fixes: 6f73862 ("mlxsw: core: Add the hottest thermal zone detection") Signed-off-by: Vadim Pasternak <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4e2905a commit 2dc2f76

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

drivers/net/ethernet/mellanox/mlxsw/core_thermal.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,7 @@ static int mlxsw_thermal_set_trip_hyst(struct thermal_zone_device *tzdev,
391391
static int mlxsw_thermal_trend_get(struct thermal_zone_device *tzdev,
392392
int trip, enum thermal_trend *trend)
393393
{
394-
struct mlxsw_thermal_module *tz = tzdev->devdata;
395-
struct mlxsw_thermal *thermal = tz->parent;
394+
struct mlxsw_thermal *thermal = tzdev->devdata;
396395

397396
if (trip < 0 || trip >= MLXSW_THERMAL_NUM_TRIPS)
398397
return -EINVAL;
@@ -593,6 +592,22 @@ mlxsw_thermal_module_trip_hyst_set(struct thermal_zone_device *tzdev, int trip,
593592
return 0;
594593
}
595594

595+
static int mlxsw_thermal_module_trend_get(struct thermal_zone_device *tzdev,
596+
int trip, enum thermal_trend *trend)
597+
{
598+
struct mlxsw_thermal_module *tz = tzdev->devdata;
599+
struct mlxsw_thermal *thermal = tz->parent;
600+
601+
if (trip < 0 || trip >= MLXSW_THERMAL_NUM_TRIPS)
602+
return -EINVAL;
603+
604+
if (tzdev == thermal->tz_highest_dev)
605+
return 1;
606+
607+
*trend = THERMAL_TREND_STABLE;
608+
return 0;
609+
}
610+
596611
static struct thermal_zone_device_ops mlxsw_thermal_module_ops = {
597612
.bind = mlxsw_thermal_module_bind,
598613
.unbind = mlxsw_thermal_module_unbind,
@@ -604,7 +619,7 @@ static struct thermal_zone_device_ops mlxsw_thermal_module_ops = {
604619
.set_trip_temp = mlxsw_thermal_module_trip_temp_set,
605620
.get_trip_hyst = mlxsw_thermal_module_trip_hyst_get,
606621
.set_trip_hyst = mlxsw_thermal_module_trip_hyst_set,
607-
.get_trend = mlxsw_thermal_trend_get,
622+
.get_trend = mlxsw_thermal_module_trend_get,
608623
};
609624

610625
static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev,
@@ -643,7 +658,7 @@ static struct thermal_zone_device_ops mlxsw_thermal_gearbox_ops = {
643658
.set_trip_temp = mlxsw_thermal_module_trip_temp_set,
644659
.get_trip_hyst = mlxsw_thermal_module_trip_hyst_get,
645660
.set_trip_hyst = mlxsw_thermal_module_trip_hyst_set,
646-
.get_trend = mlxsw_thermal_trend_get,
661+
.get_trend = mlxsw_thermal_module_trend_get,
647662
};
648663

649664
static int mlxsw_thermal_get_max_state(struct thermal_cooling_device *cdev,

0 commit comments

Comments
 (0)