Disable all thermal zones before verifying cpufreq cooling devices

Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
diff --git a/include/thermal_functions.sh b/include/thermal_functions.sh
index ae6c9c0..692529c 100644
--- a/include/thermal_functions.sh
+++ b/include/thermal_functions.sh
@@ -212,3 +212,29 @@
     fi
     return $id1
 }
+
+disable_all_thermal_zones() {
+
+    mode_list=
+    local index=0
+
+    local th_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']")
+    for zone in $th_zones; do
+	mode_list[$index]=$(cat $THERMAL_PATH/$zone/mode)
+        index=$((index + 1))
+	echo -n "disabled" > $THERMAL_PATH/$zone/mode
+    done
+    return 0
+}
+
+enable_all_thermal_zones() {
+
+    local index=0
+
+    local th_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']")
+    for zone in $th_zones; do
+	echo $mode_list[$index] > $THERMAL_PATH/$zone/mode
+        index=$((index + 1))
+    done
+    return 0
+}
diff --git a/thermal/thermal_05.sh b/thermal/thermal_05.sh
index 901fea1..e7e2710 100755
--- a/thermal/thermal_05.sh
+++ b/thermal/thermal_05.sh
@@ -33,7 +33,6 @@
     local cdev_name=$1
     shift 1
 
-    local tzonepath=$THERMAL_PATH/thermal_zone0
     local cpufreq_cdev=$(cat $dirpath/type)
     cat $dirpath/type | grep cpufreq
     if [ $? -ne 0  ] ; then
@@ -42,8 +41,7 @@
 
     local max_state=$(cat $dirpath/max_state)
     local prev_state_val=$(cat $dirpath/cur_state)
-    local prev_mode_val=$(cat $tzonepath/mode)
-    echo -n disabled > $tzonepath/mode
+    disable_all_thermal_zones
 
     local count=1
     local before_scale_max=0
@@ -70,7 +68,7 @@
 
 	count=$((count+1))
     done
-    echo $prev_mode_val > $tzonepath/mode
+    enable_all_thermal_zones
     echo $prev_state_val > $dirpath/cur_state
 }
 for_each_cooling_device verify_cpufreq_cooling_device_action