Lines Matching refs:stats
671 static void update_time_in_state(struct cooling_dev_stats *stats) in update_time_in_state() argument
675 delta = ktime_sub(now, stats->last_time); in update_time_in_state()
676 stats->time_in_state[stats->state] = in update_time_in_state()
677 ktime_add(stats->time_in_state[stats->state], delta); in update_time_in_state()
678 stats->last_time = now; in update_time_in_state()
684 struct cooling_dev_stats *stats = cdev->stats; in thermal_cooling_device_stats_update() local
686 if (!stats) in thermal_cooling_device_stats_update()
689 spin_lock(&stats->lock); in thermal_cooling_device_stats_update()
691 if (stats->state == new_state) in thermal_cooling_device_stats_update()
694 update_time_in_state(stats); in thermal_cooling_device_stats_update()
695 stats->trans_table[stats->state * stats->max_states + new_state]++; in thermal_cooling_device_stats_update()
696 stats->state = new_state; in thermal_cooling_device_stats_update()
697 stats->total_trans++; in thermal_cooling_device_stats_update()
700 spin_unlock(&stats->lock); in thermal_cooling_device_stats_update()
707 struct cooling_dev_stats *stats = cdev->stats; in total_trans_show() local
710 spin_lock(&stats->lock); in total_trans_show()
711 ret = sprintf(buf, "%u\n", stats->total_trans); in total_trans_show()
712 spin_unlock(&stats->lock); in total_trans_show()
722 struct cooling_dev_stats *stats = cdev->stats; in time_in_state_ms_show() local
726 spin_lock(&stats->lock); in time_in_state_ms_show()
727 update_time_in_state(stats); in time_in_state_ms_show()
729 for (i = 0; i < stats->max_states; i++) { in time_in_state_ms_show()
731 ktime_to_ms(stats->time_in_state[i])); in time_in_state_ms_show()
733 spin_unlock(&stats->lock); in time_in_state_ms_show()
743 struct cooling_dev_stats *stats = cdev->stats; in reset_store() local
744 int i, states = stats->max_states; in reset_store()
746 spin_lock(&stats->lock); in reset_store()
748 stats->total_trans = 0; in reset_store()
749 stats->last_time = ktime_get(); in reset_store()
750 memset(stats->trans_table, 0, in reset_store()
751 states * states * sizeof(*stats->trans_table)); in reset_store()
753 for (i = 0; i < stats->max_states; i++) in reset_store()
754 stats->time_in_state[i] = ktime_set(0, 0); in reset_store()
756 spin_unlock(&stats->lock); in reset_store()
765 struct cooling_dev_stats *stats = cdev->stats; in trans_table_show() local
771 for (i = 0; i < stats->max_states; i++) { in trans_table_show()
781 for (i = 0; i < stats->max_states; i++) { in trans_table_show()
787 for (j = 0; j < stats->max_states; j++) { in trans_table_show()
791 stats->trans_table[i * stats->max_states + j]); in trans_table_show()
826 struct cooling_dev_stats *stats; in cooling_device_stats_setup() local
841 var = sizeof(*stats); in cooling_device_stats_setup()
842 var += sizeof(*stats->time_in_state) * states; in cooling_device_stats_setup()
843 var += sizeof(*stats->trans_table) * states * states; in cooling_device_stats_setup()
845 stats = kzalloc(var, GFP_KERNEL); in cooling_device_stats_setup()
846 if (!stats) in cooling_device_stats_setup()
849 stats->time_in_state = (ktime_t *)(stats + 1); in cooling_device_stats_setup()
850 stats->trans_table = (unsigned int *)(stats->time_in_state + states); in cooling_device_stats_setup()
851 cdev->stats = stats; in cooling_device_stats_setup()
852 stats->last_time = ktime_get(); in cooling_device_stats_setup()
853 stats->max_states = states; in cooling_device_stats_setup()
855 spin_lock_init(&stats->lock); in cooling_device_stats_setup()
867 kfree(cdev->stats); in cooling_device_stats_destroy()
868 cdev->stats = NULL; in cooling_device_stats_destroy()