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

thermal: Simplify or eliminate unnecessary set_mode() methods

Setting polling_delay is now done at thermal_core level (by not polling
DISABLED devices), so no need to repeat this code.

int340x: Checking for an impossible enum value is unnecessary.
acpi/thermal: It only prints debug messages.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
[for acerhdf]
Acked-by: Peter Kaestle <peter@piie.net>
Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20200629122925.21729-11-andrzej.p@collabora.com

authored by

Andrzej Pietrasiewicz and committed by
Daniel Lezcano
5d7bd8aa b56bdff7

-87
-26
drivers/acpi/thermal.c
··· 525 525 return 0; 526 526 } 527 527 528 - static int thermal_set_mode(struct thermal_zone_device *thermal, 529 - enum thermal_device_mode mode) 530 - { 531 - struct acpi_thermal *tz = thermal->devdata; 532 - 533 - if (!tz) 534 - return -EINVAL; 535 - 536 - if (mode != THERMAL_DEVICE_DISABLED && 537 - mode != THERMAL_DEVICE_ENABLED) 538 - return -EINVAL; 539 - /* 540 - * enable/disable thermal management from ACPI thermal driver 541 - */ 542 - if (mode == THERMAL_DEVICE_DISABLED) 543 - pr_warn("thermal zone will be disabled\n"); 544 - 545 - ACPI_DEBUG_PRINT((ACPI_DB_INFO, 546 - "%s kernel ACPI thermal control\n", 547 - mode == THERMAL_DEVICE_ENABLED ? 548 - "Enable" : "Disable")); 549 - 550 - return 0; 551 - } 552 - 553 528 static int thermal_get_trip_type(struct thermal_zone_device *thermal, 554 529 int trip, enum thermal_trip_type *type) 555 530 { ··· 811 836 .bind = acpi_thermal_bind_cooling_device, 812 837 .unbind = acpi_thermal_unbind_cooling_device, 813 838 .get_temp = thermal_get_temp, 814 - .set_mode = thermal_set_mode, 815 839 .get_trip_type = thermal_get_trip_type, 816 840 .get_trip_temp = thermal_get_trip_temp, 817 841 .get_crit_temp = thermal_get_crit_temp,
-30
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
··· 275 275 return 0; 276 276 } 277 277 278 - static int mlxsw_thermal_set_mode(struct thermal_zone_device *tzdev, 279 - enum thermal_device_mode mode) 280 - { 281 - struct mlxsw_thermal *thermal = tzdev->devdata; 282 - 283 - if (mode == THERMAL_DEVICE_ENABLED) 284 - tzdev->polling_delay = thermal->polling_delay; 285 - else 286 - tzdev->polling_delay = 0; 287 - 288 - return 0; 289 - } 290 - 291 278 static int mlxsw_thermal_get_temp(struct thermal_zone_device *tzdev, 292 279 int *p_temp) 293 280 { ··· 374 387 static struct thermal_zone_device_ops mlxsw_thermal_ops = { 375 388 .bind = mlxsw_thermal_bind, 376 389 .unbind = mlxsw_thermal_unbind, 377 - .set_mode = mlxsw_thermal_set_mode, 378 390 .get_temp = mlxsw_thermal_get_temp, 379 391 .get_trip_type = mlxsw_thermal_get_trip_type, 380 392 .get_trip_temp = mlxsw_thermal_get_trip_temp, ··· 429 443 WARN_ON(err); 430 444 } 431 445 return err; 432 - } 433 - 434 - static int mlxsw_thermal_module_mode_set(struct thermal_zone_device *tzdev, 435 - enum thermal_device_mode mode) 436 - { 437 - struct mlxsw_thermal_module *tz = tzdev->devdata; 438 - struct mlxsw_thermal *thermal = tz->parent; 439 - 440 - if (mode == THERMAL_DEVICE_ENABLED) 441 - tzdev->polling_delay = thermal->polling_delay; 442 - else 443 - tzdev->polling_delay = 0; 444 - 445 - return 0; 446 446 } 447 447 448 448 static int mlxsw_thermal_module_temp_get(struct thermal_zone_device *tzdev, ··· 546 574 static struct thermal_zone_device_ops mlxsw_thermal_module_ops = { 547 575 .bind = mlxsw_thermal_module_bind, 548 576 .unbind = mlxsw_thermal_module_unbind, 549 - .set_mode = mlxsw_thermal_module_mode_set, 550 577 .get_temp = mlxsw_thermal_module_temp_get, 551 578 .get_trip_type = mlxsw_thermal_module_trip_type_get, 552 579 .get_trip_temp = mlxsw_thermal_module_trip_temp_get, ··· 583 612 static struct thermal_zone_device_ops mlxsw_thermal_gearbox_ops = { 584 613 .bind = mlxsw_thermal_module_bind, 585 614 .unbind = mlxsw_thermal_module_unbind, 586 - .set_mode = mlxsw_thermal_module_mode_set, 587 615 .get_temp = mlxsw_thermal_gearbox_temp_get, 588 616 .get_trip_type = mlxsw_thermal_module_trip_type_get, 589 617 .get_trip_temp = mlxsw_thermal_module_trip_temp_get,
-3
drivers/platform/x86/acerhdf.c
··· 397 397 { 398 398 acerhdf_change_fanstate(ACERHDF_FAN_AUTO); 399 399 kernelmode = 0; 400 - if (thz_dev) 401 - thz_dev->polling_delay = 0; 402 400 403 401 pr_notice("kernel mode fan control OFF\n"); 404 402 } ··· 404 406 { 405 407 kernelmode = 1; 406 408 407 - thz_dev->polling_delay = interval*1000; 408 409 pr_notice("kernel mode fan control ON\n"); 409 410 } 410 411
-6
drivers/thermal/imx_thermal.c
··· 338 338 const struct thermal_soc_data *soc_data = data->socdata; 339 339 340 340 if (mode == THERMAL_DEVICE_ENABLED) { 341 - tz->polling_delay = IMX_POLLING_DELAY; 342 - tz->passive_delay = IMX_PASSIVE_DELAY; 343 - 344 341 regmap_write(map, soc_data->sensor_ctrl + REG_CLR, 345 342 soc_data->power_down_mask); 346 343 regmap_write(map, soc_data->sensor_ctrl + REG_SET, ··· 352 355 soc_data->measure_temp_mask); 353 356 regmap_write(map, soc_data->sensor_ctrl + REG_SET, 354 357 soc_data->power_down_mask); 355 - 356 - tz->polling_delay = 0; 357 - tz->passive_delay = 0; 358 358 359 359 if (data->irq_enabled) { 360 360 disable_irq(data->irq);
-4
drivers/thermal/intel/int340x_thermal/int3400_thermal.c
··· 386 386 if (!priv) 387 387 return -EINVAL; 388 388 389 - if (mode != THERMAL_DEVICE_ENABLED && 390 - mode != THERMAL_DEVICE_DISABLED) 391 - return -EINVAL; 392 - 393 389 if (mode != thermal->mode) 394 390 result = int3400_thermal_run_osc(priv->adev->handle, 395 391 priv->current_uuid_index,
-18
drivers/thermal/thermal_of.c
··· 267 267 return 0; 268 268 } 269 269 270 - static int of_thermal_set_mode(struct thermal_zone_device *tz, 271 - enum thermal_device_mode mode) 272 - { 273 - struct __thermal_zone *data = tz->devdata; 274 - 275 - if (mode == THERMAL_DEVICE_ENABLED) { 276 - tz->polling_delay = data->polling_delay; 277 - tz->passive_delay = data->passive_delay; 278 - } else { 279 - tz->polling_delay = 0; 280 - tz->passive_delay = 0; 281 - } 282 - 283 - return 0; 284 - } 285 - 286 270 static int of_thermal_get_trip_type(struct thermal_zone_device *tz, int trip, 287 271 enum thermal_trip_type *type) 288 272 { ··· 358 374 } 359 375 360 376 static struct thermal_zone_device_ops of_thermal_ops = { 361 - .set_mode = of_thermal_set_mode, 362 - 363 377 .get_trip_type = of_thermal_get_trip_type, 364 378 .get_trip_temp = of_thermal_get_trip_temp, 365 379 .set_trip_temp = of_thermal_set_trip_temp,