Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 6f73862fabd9 ("mlxsw: core: Add the hottest thermal zone detection")
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vadim Pasternak and committed by
David S. Miller
2dc2f760 4e2905ad

+19 -4
+19 -4
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
··· 391 391 static int mlxsw_thermal_trend_get(struct thermal_zone_device *tzdev, 392 392 int trip, enum thermal_trend *trend) 393 393 { 394 - struct mlxsw_thermal_module *tz = tzdev->devdata; 395 - struct mlxsw_thermal *thermal = tz->parent; 394 + struct mlxsw_thermal *thermal = tzdev->devdata; 396 395 397 396 if (trip < 0 || trip >= MLXSW_THERMAL_NUM_TRIPS) 398 397 return -EINVAL; ··· 592 593 return 0; 593 594 } 594 595 596 + static int mlxsw_thermal_module_trend_get(struct thermal_zone_device *tzdev, 597 + int trip, enum thermal_trend *trend) 598 + { 599 + struct mlxsw_thermal_module *tz = tzdev->devdata; 600 + struct mlxsw_thermal *thermal = tz->parent; 601 + 602 + if (trip < 0 || trip >= MLXSW_THERMAL_NUM_TRIPS) 603 + return -EINVAL; 604 + 605 + if (tzdev == thermal->tz_highest_dev) 606 + return 1; 607 + 608 + *trend = THERMAL_TREND_STABLE; 609 + return 0; 610 + } 611 + 595 612 static struct thermal_zone_device_ops mlxsw_thermal_module_ops = { 596 613 .bind = mlxsw_thermal_module_bind, 597 614 .unbind = mlxsw_thermal_module_unbind, ··· 619 604 .set_trip_temp = mlxsw_thermal_module_trip_temp_set, 620 605 .get_trip_hyst = mlxsw_thermal_module_trip_hyst_get, 621 606 .set_trip_hyst = mlxsw_thermal_module_trip_hyst_set, 622 - .get_trend = mlxsw_thermal_trend_get, 607 + .get_trend = mlxsw_thermal_module_trend_get, 623 608 }; 624 609 625 610 static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev, ··· 658 643 .set_trip_temp = mlxsw_thermal_module_trip_temp_set, 659 644 .get_trip_hyst = mlxsw_thermal_module_trip_hyst_get, 660 645 .set_trip_hyst = mlxsw_thermal_module_trip_hyst_set, 661 - .get_trend = mlxsw_thermal_trend_get, 646 + .get_trend = mlxsw_thermal_module_trend_get, 662 647 }; 663 648 664 649 static int mlxsw_thermal_get_max_state(struct thermal_cooling_device *cdev,