Skip to content

Commit 9bb3ec1

Browse files
committed
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/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 9c26a1d + b0d2132 commit 9bb3ec1

File tree

1 file changed

+12
-31
lines changed

1 file changed

+12
-31
lines changed

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

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ static const struct thermal_cooling_device_ops mlxsw_cooling_ops = {
411411
static int
412412
mlxsw_thermal_module_tz_init(struct mlxsw_thermal_module *module_tz)
413413
{
414-
char tz_name[THERMAL_NAME_LENGTH];
414+
char tz_name[40];
415415
int err;
416416

417417
if (module_tz->slot_index)
@@ -445,17 +445,13 @@ static void mlxsw_thermal_module_tz_fini(struct thermal_zone_device *tzdev)
445445
thermal_zone_device_unregister(tzdev);
446446
}
447447

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,
451450
struct mlxsw_thermal_area *area, u8 module)
452451
{
453452
struct mlxsw_thermal_module *module_tz;
454453

455454
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;
459455
module_tz->module = module;
460456
module_tz->slot_index = area->slot_index;
461457
module_tz->parent = thermal;
@@ -465,23 +461,20 @@ mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core,
465461
sizeof(thermal->trips));
466462
memcpy(module_tz->cooling_states, default_cooling_states,
467463
sizeof(thermal->cooling_states));
464+
465+
return mlxsw_thermal_module_tz_init(module_tz);
468466
}
469467

470468
static void mlxsw_thermal_module_fini(struct mlxsw_thermal_module *module_tz)
471469
{
472-
if (module_tz && module_tz->tzdev) {
473-
mlxsw_thermal_module_tz_fini(module_tz->tzdev);
474-
module_tz->tzdev = NULL;
475-
module_tz->parent = NULL;
476-
}
470+
mlxsw_thermal_module_tz_fini(module_tz->tzdev);
477471
}
478472

479473
static int
480474
mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
481475
struct mlxsw_thermal *thermal,
482476
struct mlxsw_thermal_area *area)
483477
{
484-
struct mlxsw_thermal_module *module_tz;
485478
char mgpir_pl[MLXSW_REG_MGPIR_LEN];
486479
int i, err;
487480

@@ -503,22 +496,16 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
503496
if (!area->tz_module_arr)
504497
return -ENOMEM;
505498

506-
for (i = 0; i < area->tz_module_num; i++)
507-
mlxsw_thermal_module_init(dev, core, thermal, area, i);
508-
509499
for (i = 0; i < area->tz_module_num; i++) {
510-
module_tz = &area->tz_module_arr[i];
511-
if (!module_tz->parent)
512-
continue;
513-
err = mlxsw_thermal_module_tz_init(module_tz);
500+
err = mlxsw_thermal_module_init(thermal, area, i);
514501
if (err)
515-
goto err_thermal_module_tz_init;
502+
goto err_thermal_module_init;
516503
}
517504

518505
return 0;
519506

520-
err_thermal_module_tz_init:
521-
for (i = area->tz_module_num - 1; i >= 0; i--)
507+
err_thermal_module_init:
508+
for (i--; i >= 0; i--)
522509
mlxsw_thermal_module_fini(&area->tz_module_arr[i]);
523510
kfree(area->tz_module_arr);
524511
return err;
@@ -821,10 +808,7 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
821808
err_thermal_gearboxes_init:
822809
mlxsw_thermal_modules_fini(thermal, &thermal->line_cards[0]);
823810
err_thermal_modules_init:
824-
if (thermal->tzdev) {
825-
thermal_zone_device_unregister(thermal->tzdev);
826-
thermal->tzdev = NULL;
827-
}
811+
thermal_zone_device_unregister(thermal->tzdev);
828812
err_thermal_zone_device_register:
829813
err_thermal_cooling_device_register:
830814
for (i = 0; i < MLXSW_MFCR_PWMS_MAX; i++)
@@ -845,10 +829,7 @@ void mlxsw_thermal_fini(struct mlxsw_thermal *thermal)
845829
thermal);
846830
mlxsw_thermal_gearboxes_fini(thermal, &thermal->line_cards[0]);
847831
mlxsw_thermal_modules_fini(thermal, &thermal->line_cards[0]);
848-
if (thermal->tzdev) {
849-
thermal_zone_device_unregister(thermal->tzdev);
850-
thermal->tzdev = NULL;
851-
}
832+
thermal_zone_device_unregister(thermal->tzdev);
852833

853834
for (i = 0; i < MLXSW_MFCR_PWMS_MAX; i++)
854835
thermal_cooling_device_unregister(thermal->cdevs[i].cdev);

0 commit comments

Comments
 (0)