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

Merge branch 'mlxsw-core_thermal-small-cleanups'

Petr Machata says:

====================
mlxsw: core_thermal: Small cleanups

Ido Schimmel says:

Clean up various issues which I noticed while addressing feedback on a
different patchset.
====================

Link: https://patch.msgid.link/cover.1722345311.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+12 -31
+12 -31
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
··· 411 411 static int 412 412 mlxsw_thermal_module_tz_init(struct mlxsw_thermal_module *module_tz) 413 413 { 414 - char tz_name[THERMAL_NAME_LENGTH]; 414 + char tz_name[40]; 415 415 int err; 416 416 417 417 if (module_tz->slot_index) ··· 445 445 thermal_zone_device_unregister(tzdev); 446 446 } 447 447 448 - static void 449 - mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core, 450 - struct mlxsw_thermal *thermal, 448 + static int 449 + mlxsw_thermal_module_init(struct mlxsw_thermal *thermal, 451 450 struct mlxsw_thermal_area *area, u8 module) 452 451 { 453 452 struct mlxsw_thermal_module *module_tz; 454 453 455 454 module_tz = &area->tz_module_arr[module]; 456 - /* Skip if parent is already set (case of port split). */ 457 - if (module_tz->parent) 458 - return; 459 455 module_tz->module = module; 460 456 module_tz->slot_index = area->slot_index; 461 457 module_tz->parent = thermal; ··· 461 465 sizeof(thermal->trips)); 462 466 memcpy(module_tz->cooling_states, default_cooling_states, 463 467 sizeof(thermal->cooling_states)); 468 + 469 + return mlxsw_thermal_module_tz_init(module_tz); 464 470 } 465 471 466 472 static void mlxsw_thermal_module_fini(struct mlxsw_thermal_module *module_tz) 467 473 { 468 - if (module_tz && module_tz->tzdev) { 469 - mlxsw_thermal_module_tz_fini(module_tz->tzdev); 470 - module_tz->tzdev = NULL; 471 - module_tz->parent = NULL; 472 - } 474 + mlxsw_thermal_module_tz_fini(module_tz->tzdev); 473 475 } 474 476 475 477 static int ··· 475 481 struct mlxsw_thermal *thermal, 476 482 struct mlxsw_thermal_area *area) 477 483 { 478 - struct mlxsw_thermal_module *module_tz; 479 484 char mgpir_pl[MLXSW_REG_MGPIR_LEN]; 480 485 int i, err; 481 486 ··· 496 503 if (!area->tz_module_arr) 497 504 return -ENOMEM; 498 505 499 - for (i = 0; i < area->tz_module_num; i++) 500 - mlxsw_thermal_module_init(dev, core, thermal, area, i); 501 - 502 506 for (i = 0; i < area->tz_module_num; i++) { 503 - module_tz = &area->tz_module_arr[i]; 504 - if (!module_tz->parent) 505 - continue; 506 - err = mlxsw_thermal_module_tz_init(module_tz); 507 + err = mlxsw_thermal_module_init(thermal, area, i); 507 508 if (err) 508 - goto err_thermal_module_tz_init; 509 + goto err_thermal_module_init; 509 510 } 510 511 511 512 return 0; 512 513 513 - err_thermal_module_tz_init: 514 - for (i = area->tz_module_num - 1; i >= 0; i--) 514 + err_thermal_module_init: 515 + for (i--; i >= 0; i--) 515 516 mlxsw_thermal_module_fini(&area->tz_module_arr[i]); 516 517 kfree(area->tz_module_arr); 517 518 return err; ··· 808 821 err_thermal_gearboxes_init: 809 822 mlxsw_thermal_modules_fini(thermal, &thermal->line_cards[0]); 810 823 err_thermal_modules_init: 811 - if (thermal->tzdev) { 812 - thermal_zone_device_unregister(thermal->tzdev); 813 - thermal->tzdev = NULL; 814 - } 824 + thermal_zone_device_unregister(thermal->tzdev); 815 825 err_thermal_zone_device_register: 816 826 err_thermal_cooling_device_register: 817 827 for (i = 0; i < MLXSW_MFCR_PWMS_MAX; i++) ··· 829 845 thermal); 830 846 mlxsw_thermal_gearboxes_fini(thermal, &thermal->line_cards[0]); 831 847 mlxsw_thermal_modules_fini(thermal, &thermal->line_cards[0]); 832 - if (thermal->tzdev) { 833 - thermal_zone_device_unregister(thermal->tzdev); 834 - thermal->tzdev = NULL; 835 - } 848 + thermal_zone_device_unregister(thermal->tzdev); 836 849 837 850 for (i = 0; i < MLXSW_MFCR_PWMS_MAX; i++) 838 851 thermal_cooling_device_unregister(thermal->cdevs[i].cdev);