pos->initialized = false;
 }
 
+static void __thermal_zone_device_update(struct thermal_zone_device *tz,
+                                        enum thermal_notify_event event)
+{
+       int count;
+
+       if (atomic_read(&in_suspend))
+               return;
+
+       if (WARN_ONCE(!tz->ops->get_temp,
+                     "'%s' must not be called without 'get_temp' ops set\n",
+                     __func__))
+               return;
+
+       if (!thermal_zone_device_is_enabled(tz))
+               return;
+
+       update_temperature(tz);
+
+       __thermal_zone_set_trips(tz);
+
+       tz->notify_event = event;
+
+       for (count = 0; count < tz->num_trips; count++)
+               handle_thermal_trip(tz, count);
+
+       monitor_thermal_zone(tz);
+}
+
 static int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
                                        enum thermal_device_mode mode)
 {
        if (!ret)
                tz->mode = mode;
 
-       mutex_unlock(&tz->lock);
+       __thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
 
-       thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
+       mutex_unlock(&tz->lock);
 
        if (mode == THERMAL_DEVICE_ENABLED)
                thermal_notify_tz_enable(tz->id);
 void thermal_zone_device_update(struct thermal_zone_device *tz,
                                enum thermal_notify_event event)
 {
-       int count;
-
-       if (atomic_read(&in_suspend))
-               return;
-
-       if (WARN_ONCE(!tz->ops->get_temp, "'%s' must not be called without "
-                     "'get_temp' ops set\n", __func__))
-               return;
-
        mutex_lock(&tz->lock);
-
-       if (!thermal_zone_device_is_enabled(tz))
-               goto out;
-
-       update_temperature(tz);
-
-       __thermal_zone_set_trips(tz);
-
-       tz->notify_event = event;
-
-       for (count = 0; count < tz->num_trips; count++)
-               handle_thermal_trip(tz, count);
-
-       monitor_thermal_zone(tz);
-out:
+       __thermal_zone_device_update(tz, event);
        mutex_unlock(&tz->lock);
 }
 EXPORT_SYMBOL_GPL(thermal_zone_device_update);