From 84d6642e4d1609562abb421341c9a90c023247a1 Mon Sep 17 00:00:00 2001 From: Dominik Sliwa Date: Tue, 4 Jul 2017 11:53:51 +0200 Subject: backports:fix compilation with toradex kernels Signed-off-by: Dominik Sliwa --- drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'drivers/net/wireless/intel/iwlwifi/pcie/rx.c') diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c index de94dfd..971499c 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c @@ -37,6 +37,32 @@ #include "internal.h" #include "iwl-op-mode.h" + #if LINUX_VERSION_IS_LESS(3,7,0) +/* + * atomic_dec_if_positive - decrement by 1 if old value positive + * @v: pointer of type atomic_t + * + * The function returns the old value of *v minus 1, even if + * the atomic variable, v, was not decremented. + */ +#ifndef atomic_dec_if_positive +static inline int atomic_dec_if_positive(atomic_t *v) +{ + int c, old, dec; + c = atomic_read(v); + for (;;) { + dec = c - 1; + if (unlikely(dec < 0)) + break; + old = atomic_cmpxchg((v), c, dec); + if (likely(old == c)) + break; + c = old; + } + return dec; +} +#endif +#endif /****************************************************************************** * * RX path functions -- cgit v1.2.3