aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/average.h
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2017-11-28 16:19:52 +0000
committerMark Brown <broonie@kernel.org>2017-11-28 16:19:52 +0000
commit69830d3909849dee33b9a2de88ece3d59c75a1b8 (patch)
tree67e22ac989e782ddc104f186dee54d1675e76923 /include/linux/average.h
parentASoC: rk3399_gru_sound: Map BTN_0 to KEY_PLAYPAUSE (diff)
parentASoC: add snd_soc_disconnect_sync() (diff)
downloadlinux-dev-69830d3909849dee33b9a2de88ece3d59c75a1b8.tar.xz
linux-dev-69830d3909849dee33b9a2de88ece3d59c75a1b8.zip
Merge branch 'topic/disconnect' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-rcar
Diffstat (limited to 'include/linux/average.h')
-rw-r--r--include/linux/average.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/include/linux/average.h b/include/linux/average.h
index 1b6f5560c264..a1a8f09631ce 100644
--- a/include/linux/average.h
+++ b/include/linux/average.h
@@ -2,6 +2,10 @@
#ifndef _LINUX_AVERAGE_H
#define _LINUX_AVERAGE_H
+#include <linux/bug.h>
+#include <linux/compiler.h>
+#include <linux/log2.h>
+
/*
* Exponentially weighted moving average (EWMA)
*
@@ -49,7 +53,7 @@
static inline void ewma_##name##_add(struct ewma_##name *e, \
unsigned long val) \
{ \
- unsigned long internal = ACCESS_ONCE(e->internal); \
+ unsigned long internal = READ_ONCE(e->internal); \
unsigned long weight_rcp = ilog2(_weight_rcp); \
unsigned long precision = _precision; \
\
@@ -58,10 +62,10 @@
BUILD_BUG_ON((_precision) > 30); \
BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
\
- ACCESS_ONCE(e->internal) = internal ? \
+ WRITE_ONCE(e->internal, internal ? \
(((internal << weight_rcp) - internal) + \
(val << precision)) >> weight_rcp : \
- (val << precision); \
+ (val << precision)); \
}
#endif /* _LINUX_AVERAGE_H */