--- drivers/thermal/thermal_core.c | 11 +++++++---- drivers/thermal/thermal_debugfs.c | 7 ++++++- 2 files changed, 13 insertions(+), 5 deletions(-) Index: linux-pm/drivers/thermal/thermal_core.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_core.c +++ linux-pm/drivers/thermal/thermal_core.c @@ -964,7 +964,8 @@ __thermal_cooling_device_register(struct { struct thermal_cooling_device *cdev; struct thermal_zone_device *pos = NULL; - unsigned long current_state; + unsigned long val; + int current_state; int id, ret; if (!ops || !ops->get_max_state || !ops->get_cur_state || @@ -1002,9 +1003,11 @@ __thermal_cooling_device_register(struct if (ret) goto out_cdev_type; - ret = cdev->ops->get_cur_state(cdev, ¤t_state); - if (ret) - goto out_cdev_type; + ret = cdev->ops->get_cur_state(cdev, &val); + if (val >= 0 && val <= INT_MAX) + current_state = val; + else + current_state = -1; thermal_cooling_device_setup_sysfs(cdev); Index: linux-pm/drivers/thermal/thermal_debugfs.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_debugfs.c +++ linux-pm/drivers/thermal/thermal_debugfs.c @@ -421,6 +421,8 @@ void thermal_debug_cdev_state_update(con cdev_dbg = &thermal_dbg->cdev_dbg; old_state = cdev_dbg->current_state; + if (old_state < 0) + goto unlock; /* * Get the old state information in the durations list. If @@ -463,6 +465,7 @@ void thermal_debug_cdev_state_update(con cdev_dbg->total++; +unlock: mutex_unlock(&thermal_dbg->lock); } @@ -499,7 +502,9 @@ void thermal_debug_cdev_add(struct therm * duration will be printed by cdev_dt_seq_show() as expected if it * runs before the first state transition. */ - thermal_debugfs_cdev_record_get(thermal_dbg, cdev_dbg->durations, state); + if (state >= 0) + thermal_debugfs_cdev_record_get(thermal_dbg, cdev_dbg->durations, + state); debugfs_create_file("trans_table", 0400, thermal_dbg->d_top, thermal_dbg, &tt_fops);