Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
commit c7387df09815cbce4b24e784c5e992515da02f56 Author: Sven Eckelmann sven@narfation.org Date: Sat Jan 16 10:29:39 2016 +0100
batman-adv: Add compatibility code for kref_get_unless_zero
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Marek Lindner mareklindner@neomailbox.ch
c7387df09815cbce4b24e784c5e992515da02f56 compat-include/linux/{if_ether.h => kref.h} | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/compat-include/linux/if_ether.h b/compat-include/linux/kref.h similarity index 54% copy from compat-include/linux/if_ether.h copy to compat-include/linux/kref.h index 79c8526..bb3442c 100644 --- a/compat-include/linux/if_ether.h +++ b/compat-include/linux/kref.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2016 B.A.T.M.A.N. contributors: +/* Copyright (C) 2007-2016 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * @@ -18,16 +18,29 @@ * of the Linux kernel. */
-#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_IF_ETHER_H_ -#define _NET_BATMAN_ADV_COMPAT_LINUX_IF_ETHER_H_ +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_KREF_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_KREF_H_
#include <linux/version.h> -#include_next <linux/if_ether.h> +#include_next <linux/kref.h> + +#include <linux/atomic.h> +#include <linux/kernel.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0)
-#define ETH_P_BATMAN 0x4305 +/* some stable versions like Linux 3.2.44 also introduced this function + * and would therefore break the build because they trigger a redefinition + * of this function. Instead rename this function to be in the batadv_* + * namespace + */ +#define kref_get_unless_zero(__kref) batadv_kref_get_unless_zero(__kref) + +static inline int __must_check batadv_kref_get_unless_zero(struct kref *kref) +{ + return atomic_add_unless(&kref->refcount, 1, 0); +}
#endif /* < KERNEL_VERSION(3, 8, 0) */
-#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_IF_ETHER_H_ */ +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_KREF_H_ */