Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
commit e08aac0e4d20bb21d821a98b43afd47dd0708528 Author: Sven Eckelmann sven@narfation.org Date: Fri Jan 19 09:34:45 2018 +0100
batman-adv: Fix DECLARE_EWMA compat with newer kernels
Newer kernels removed the ACCESS_ONCE macro and are now using the more specialized forms READ_ONCE and WRITE_ONCE. The DECLARE_EWMA compat code used ACCESS_ONCE and fails to build against kernels which include the commit b899a850431e ("compiler.h: Remove ACCESS_ONCE()").
Signed-off-by: Sven Eckelmann sven@narfation.org
e08aac0e4d20bb21d821a98b43afd47dd0708528 compat-include/linux/average.h | 8 +++++--- compat-include/linux/{seq_file.h => compiler.h} | 17 +++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/compat-include/linux/average.h b/compat-include/linux/average.h index a1e3c25..ce847d5 100644 --- a/compat-include/linux/average.h +++ b/compat-include/linux/average.h @@ -25,6 +25,8 @@ #include_next <linux/average.h>
#include <linux/bug.h> +#include <linux/compiler.h> +#include <linux/log2.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) #undef DECLARE_EWMA @@ -77,7 +79,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; \ \ @@ -86,10 +88,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 /* _NET_BATMAN_ADV_COMPAT_LINUX_AVERAGE_H */ diff --git a/compat-include/linux/seq_file.h b/compat-include/linux/compiler.h similarity index 76% copy from compat-include/linux/seq_file.h copy to compat-include/linux/compiler.h index 3e8dbb4..62b6a2f 100644 --- a/compat-include/linux/seq_file.h +++ b/compat-include/linux/compiler.h @@ -18,19 +18,20 @@ * of the Linux kernel. */
-#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_SEQ_FILE_H_ -#define _NET_BATMAN_ADV_COMPAT_LINUX_SEQ_FILE_H_ +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_COMPILER_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_COMPILER_H_
#include <linux/version.h> -#include_next <linux/seq_file.h> +#include_next <linux/compiler.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
-static inline bool seq_has_overflowed(struct seq_file *m) -{ - return m->count == m->size; -} +#define READ_ONCE(x) ACCESS_ONCE(x) + +#define WRITE_ONCE(x, val) ({ \ + ACCESS_ONCE(x) = (val); \ +})
#endif /* < KERNEL_VERSION(3, 19, 0) */
-#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_SEQ_FILE_H_ */ +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_COMPILER_H_ */