diff options
author | Michal Marek <mmarek@suse.cz> | 2010-12-01 13:13:56 +0100 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2010-12-01 13:13:56 +0100 |
commit | 307991055b0ce65d53dc1eb501c456c10eb36360 (patch) | |
tree | 71bb9263dc71344e5d7b97ca6d5cf223f1f1a856 /include/linux/atomic.h | |
parent | 1198c6d45a1ef5f4f7fdfbf33ef7d270493ec575 (diff) | |
parent | 9b4320b77bab4031649c484da1c595f39c2e43cd (diff) | |
download | kernel_samsung_espresso10-307991055b0ce65d53dc1eb501c456c10eb36360.zip kernel_samsung_espresso10-307991055b0ce65d53dc1eb501c456c10eb36360.tar.gz kernel_samsung_espresso10-307991055b0ce65d53dc1eb501c456c10eb36360.tar.bz2 |
Merge branch 'kconfig_fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-next into kbuild/rc-fixes
Diffstat (limited to 'include/linux/atomic.h')
-rw-r--r-- | include/linux/atomic.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/include/linux/atomic.h b/include/linux/atomic.h new file mode 100644 index 0000000..96c038e --- /dev/null +++ b/include/linux/atomic.h @@ -0,0 +1,37 @@ +#ifndef _LINUX_ATOMIC_H +#define _LINUX_ATOMIC_H +#include <asm/atomic.h> + +/** + * atomic_inc_not_zero_hint - increment if not null + * @v: pointer of type atomic_t + * @hint: probable value of the atomic before the increment + * + * This version of atomic_inc_not_zero() gives a hint of probable + * value of the atomic. This helps processor to not read the memory + * before doing the atomic read/modify/write cycle, lowering + * number of bus transactions on some arches. + * + * Returns: 0 if increment was not done, 1 otherwise. + */ +#ifndef atomic_inc_not_zero_hint +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint) +{ + int val, c = hint; + + /* sanity test, should be removed by compiler if hint is a constant */ + if (!hint) + return atomic_inc_not_zero(v); + + do { + val = atomic_cmpxchg(v, c, c + 1); + if (val == c) + return 1; + c = val; + } while (c); + + return 0; +} +#endif + +#endif /* _LINUX_ATOMIC_H */ |