5 * @file energy/tm_stat.h
6 * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 * Copyright (C) Samsung Electronics, 2013
29 #include <linux/types.h>
30 #include <linux/time.h>
35 * @brief Description of statistic time
38 u64 timestamp; /**< Time stamp */
39 u64 running; /**< Running time */
44 * Initialize of tm_stat struct @hideinitializer
46 #define DEFINE_TM_STAT(tm_name) \
47 struct tm_stat tm_name = { \
53 static inline u64 get_ntime(void)
57 return timespec_to_ns(&ts);
60 static inline void tm_stat_init(struct tm_stat *tm)
66 static inline void tm_stat_set_timestamp(struct tm_stat *tm, u64 time)
71 static inline u64 tm_stat_timestamp(struct tm_stat *tm)
76 static inline void tm_stat_update(struct tm_stat *tm, u64 time)
78 tm->running += time - tm->timestamp;
81 static inline u64 tm_stat_running(struct tm_stat *tm)
86 static inline u64 tm_stat_current_running(struct tm_stat *tm, u64 now)
88 if (unlikely(now < tm->timestamp))
89 printk("XXX %p WARNING now(%llu) < tmstmp(%llu)\n",
90 tm, now, tm->timestamp);
91 return tm->timestamp ? tm->running + now - tm->timestamp: tm->running;
94 #endif /* _TM_STAT_H */