diff options
| author | Paul Mundt <lethal@linux-sh.org> | 2011-01-07 10:29:26 +0900 |
|---|---|---|
| committer | Paul Mundt <lethal@linux-sh.org> | 2011-01-07 10:29:26 +0900 |
| commit | 5e93c6b4ecd78b1bab49bad1dc2f6ed7ec0115ee (patch) | |
| tree | 4f4e321a1ca0baf64d8af528080c71f93495a7d7 /include/linux/average.h | |
| parent | 98d27b8abf413a310df6676f7d2128ada1cccc08 (diff) | |
| parent | 3c0cb7c31c206aaedb967e44b98442bbeb17a6c4 (diff) | |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6 into rmobile-latest
Conflicts:
arch/arm/mach-shmobile/Kconfig
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'include/linux/average.h')
| -rw-r--r-- | include/linux/average.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/include/linux/average.h b/include/linux/average.h new file mode 100644 index 000000000000..c6028fd742c1 --- /dev/null +++ b/include/linux/average.h @@ -0,0 +1,30 @@ +#ifndef _LINUX_AVERAGE_H +#define _LINUX_AVERAGE_H + +/* Exponentially weighted moving average (EWMA) */ + +/* For more documentation see lib/average.c */ + +struct ewma { + unsigned long internal; + unsigned long factor; + unsigned long weight; +}; + +extern void ewma_init(struct ewma *avg, unsigned long factor, + unsigned long weight); + +extern struct ewma *ewma_add(struct ewma *avg, unsigned long val); + +/** + * ewma_read() - Get average value + * @avg: Average structure + * + * Returns the average value held in @avg. + */ +static inline unsigned long ewma_read(const struct ewma *avg) +{ + return avg->internal >> avg->factor; +} + +#endif /* _LINUX_AVERAGE_H */ |
