diff options
author | Lisa Nguyen <lisa.nguyen@linaro.org> | 2015-11-17 23:15:22 -0800 |
---|---|---|
committer | Lisa Nguyen <lisa.nguyen@linaro.org> | 2015-11-19 17:34:09 -0800 |
commit | ddd07af132140ef3f984ca4a24d2089278e35e84 (patch) | |
tree | 72bc6d23934c843bdf6d3b561586fa015b7e230f | |
parent | d75a9830edd5be39a0b5030d1fd12e91dbd8a156 (diff) |
thermal: Create check_for_thermal_zones() function
Create a function to check for thermal zones as
an attempt to remove some redundant code.
Signed-off-by: Lisa Nguyen <lisa.nguyen@linaro.org>
-rw-r--r-- | include/functions.sh | 10 | ||||
-rwxr-xr-x | thermal/thermal_01.sh | 3 | ||||
-rwxr-xr-x | thermal/thermal_03.sh | 3 | ||||
-rwxr-xr-x | thermal/thermal_04.sh | 9 | ||||
-rwxr-xr-x | thermal/thermal_06.sh | 3 |
5 files changed, 21 insertions, 7 deletions
diff --git a/include/functions.sh b/include/functions.sh index b849cce..3841822 100644 --- a/include/functions.sh +++ b/include/functions.sh @@ -725,3 +725,13 @@ restore_thermal_governors() { return 0 } + +check_for_thermal_zones() +{ + thermal_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']" 2>/dev/null) + if [ ! -z "$thermal_zones" ]; then + return 0 + else + return 1 + fi +} diff --git a/thermal/thermal_01.sh b/thermal/thermal_01.sh index 8335299..9cd6f6e 100755 --- a/thermal/thermal_01.sh +++ b/thermal/thermal_01.sh @@ -69,7 +69,8 @@ check_thermal_zone_bindings() { done } -if [ -z "$thermal_zones"]; then +check_for_thermal_zones +if [ $? -ne 0 ]; then log_skip "No thermal zones found" else for_each_thermal_zone check_thermal_zone_attributes diff --git a/thermal/thermal_03.sh b/thermal/thermal_03.sh index 665d851..3259ff4 100755 --- a/thermal/thermal_03.sh +++ b/thermal/thermal_03.sh @@ -59,7 +59,8 @@ check_temperature_change() { trap "heater_kill; sigtrap" HUP INT TERM -if [ -z "$thermal_zones"]; then +check_for_thermal_zones +if [ $? -ne 0 ]; then log_skip "No thermal zones found" else for_each_thermal_zone check_temperature_change diff --git a/thermal/thermal_04.sh b/thermal/thermal_04.sh index e2bd996..f10373d 100755 --- a/thermal/thermal_04.sh +++ b/thermal/thermal_04.sh @@ -39,12 +39,13 @@ verify_cooling_device_temp_change() { dirpath=$THERMAL_PATH/$1 cdev_name=$1 shift 1 - tzonepath=$THERMAL_PATH/thermal_zone0 - test -d $tzonepath + check_for_thermal_zones if [ $? -ne 0 ] ; then - echo "No thermal zone present" - return 1; + log_skip "No thermal zones found." + return 1 fi + + tzonepath="$THERMAL_PATH/thermal_zone0" max_state=$(cat $dirpath/max_state) prev_state_val=$(cat $dirpath/cur_state) diff --git a/thermal/thermal_06.sh b/thermal/thermal_06.sh index 5774977..d57aa0a 100755 --- a/thermal/thermal_06.sh +++ b/thermal/thermal_06.sh @@ -109,7 +109,8 @@ check_trip_point_change() { trap "heater_kill; sigtrap" HUP INT TERM -if [ -z "$thermal_zones"]; then +check_for_thermal_zones +if [ $? -ne 0 ]; then log_skip "No thermal zones found" else for_each_thermal_zone check_trip_point_change |