@@ -411,7 +411,7 @@ static const struct thermal_cooling_device_ops mlxsw_cooling_ops = {
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,17 +445,13 @@ static void mlxsw_thermal_module_tz_fini(struct thermal_zone_device *tzdev)
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 ;
@@ -465,23 +461,20 @@ mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core,
465
461
sizeof (thermal -> trips ));
466
462
memcpy (module_tz -> cooling_states , default_cooling_states ,
467
463
sizeof (thermal -> cooling_states ));
464
+
465
+ return mlxsw_thermal_module_tz_init (module_tz );
468
466
}
469
467
470
468
static void mlxsw_thermal_module_fini (struct mlxsw_thermal_module * module_tz )
471
469
{
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 );
477
471
}
478
472
479
473
static int
480
474
mlxsw_thermal_modules_init (struct device * dev , struct mlxsw_core * core ,
481
475
struct mlxsw_thermal * thermal ,
482
476
struct mlxsw_thermal_area * area )
483
477
{
484
- struct mlxsw_thermal_module * module_tz ;
485
478
char mgpir_pl [MLXSW_REG_MGPIR_LEN ];
486
479
int i , err ;
487
480
@@ -503,22 +496,16 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
503
496
if (!area -> tz_module_arr )
504
497
return - ENOMEM ;
505
498
506
- for (i = 0 ; i < area -> tz_module_num ; i ++ )
507
- mlxsw_thermal_module_init (dev , core , thermal , area , i );
508
-
509
499
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 );
514
501
if (err )
515
- goto err_thermal_module_tz_init ;
502
+ goto err_thermal_module_init ;
516
503
}
517
504
518
505
return 0 ;
519
506
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 -- )
522
509
mlxsw_thermal_module_fini (& area -> tz_module_arr [i ]);
523
510
kfree (area -> tz_module_arr );
524
511
return err ;
@@ -821,10 +808,7 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
821
808
err_thermal_gearboxes_init :
822
809
mlxsw_thermal_modules_fini (thermal , & thermal -> line_cards [0 ]);
823
810
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 );
828
812
err_thermal_zone_device_register :
829
813
err_thermal_cooling_device_register :
830
814
for (i = 0 ; i < MLXSW_MFCR_PWMS_MAX ; i ++ )
@@ -845,10 +829,7 @@ void mlxsw_thermal_fini(struct mlxsw_thermal *thermal)
845
829
thermal );
846
830
mlxsw_thermal_gearboxes_fini (thermal , & thermal -> line_cards [0 ]);
847
831
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 );
852
833
853
834
for (i = 0 ; i < MLXSW_MFCR_PWMS_MAX ; i ++ )
854
835
thermal_cooling_device_unregister (thermal -> cdevs [i ].cdev );
0 commit comments