This patch simplifies the way we search for objects inside the thermal sysfs tree. In some cases, the current code is not listing all expected objects. With this simplification, all objects are now listed.
Signed-off-by: Eduardo Valentin eduardo.valentin@ti.com --- include/thermal_functions.sh | 24 ++++++++++-------------- 1 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/include/thermal_functions.sh b/include/thermal_functions.sh index 692529c..84d2ed6 100644 --- a/include/thermal_functions.sh +++ b/include/thermal_functions.sh @@ -57,9 +57,8 @@ for_each_thermal_zone() { local func=$1 shift 1
- zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") + zones=$(ls $THERMAL_PATH | grep "thermal_zone")
- ALL_ZONE=$zone for zone in $zones; do INC=0 $func $zone $@ @@ -73,10 +72,8 @@ get_total_trip_point_of_zone() { local zone_path=$THERMAL_PATH/$1 local count=0 shift 1 - trips=$(ls $zone_path | grep "trip_point_['$MAX_ZONE']_temp") - for trip in $trips; do - count=$((count + 1)) - done + count=$(ls $zone_path/trip_point_*_temp | wc -l) + return $count }
@@ -87,7 +84,7 @@ for_each_trip_point_of_zone() { local func=$2 local zone_name=$1 shift 2 - trips=$(ls $zone_path | grep "trip_point_['$MAX_ZONE']_temp") + trips=$(ls $zone_path/trip_point_*_temp) for trip in $trips; do $func $zone_name $count count=$((count + 1)) @@ -102,7 +99,7 @@ for_each_binding_of_zone() { local func=$2 local zone_name=$1 shift 2 - trips=$(ls $zone_path | grep "cdev['$MAX_CDEV']_trip_point") + trips=$(ls $zone_path/cdev*_trip_point) for trip in $trips; do $func $zone_name $count count=$((count + 1)) @@ -124,7 +121,7 @@ check_valid_binding() { shift 2
log_begin "checking $descr" - if [ $trip_point > $trip_point_max ]; then + if [ $trip_point -ge $trip_point_max ]; then log_end "fail" return 1 fi @@ -141,7 +138,7 @@ validate_trip_bindings() { shift 2
check_file $trip_point $dirpath || return 1 - check_valid_binding $trip_point $zone_name || return 1 + check_valid_binding $bind_no $zone_name || return 1 }
validate_trip_level() { @@ -162,9 +159,8 @@ for_each_cooling_device() { local func=$1 shift 1
- devices=$(ls $THERMAL_PATH | grep "cooling_device['$MAX_CDEV']") + devices=$(ls $THERMAL_PATH | grep "cooling_device")
- ALL_DEVICE=$devices for device in $devices; do INC=0 $func $device $@ @@ -218,7 +214,7 @@ disable_all_thermal_zones() { mode_list= local index=0
- local th_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") + local th_zones=$(ls $THERMAL_PATH | grep "thermal_zone") for zone in $th_zones; do mode_list[$index]=$(cat $THERMAL_PATH/$zone/mode) index=$((index + 1)) @@ -231,7 +227,7 @@ enable_all_thermal_zones() {
local index=0
- local th_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") + local th_zones=$(ls $THERMAL_PATH | grep "thermal_zone") for zone in $th_zones; do echo $mode_list[$index] > $THERMAL_PATH/$zone/mode index=$((index + 1))