@@ -560,15 +560,20 @@ static int cm_get_battery_temperature(struct charger_manager *cm,
return -ENODEV;
#ifdef CONFIG_THERMAL
- ret = thermal_zone_get_temp(cm->tzd_batt, (unsigned long *)temp);
- if (!ret)
- /* Calibrate temperature unit */
- *temp /= 100;
-#else
+ if (cm->tzd_batt && !IS_ERR(cm->tzd_batt)) {
+ unsigned long _temp;
+ ret = thermal_zone_get_temp(cm->tzd_batt, &_temp);
+ if (!ret) {
+ /* Calibrate temperature unit */
+ _temp /= 100;
+ *temp = _temp;
+ return 0;
+ }
+ }
+#endif
ret = cm->fuel_gauge->get_property(cm->fuel_gauge,
POWER_SUPPLY_PROP_TEMP,
(union power_supply_propval *)temp);
-#endif
return ret;
}