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>
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 @@
     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 @@
 
 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 @@
     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 @@
 
 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