Skip to content

Commit 65b0085

Browse files
willdeaconIngo Molnar
authored andcommitted
locking/refcount: Consolidate REFCOUNT_{MAX,SATURATED} definitions
The definitions of REFCOUNT_MAX and REFCOUNT_SATURATED are the same, regardless of CONFIG_REFCOUNT_FULL, so consolidate them into a single pair of definitions. Signed-off-by: Will Deacon <[email protected]> Reviewed-by: Ard Biesheuvel <[email protected]> Reviewed-by: Kees Cook <[email protected]> Tested-by: Hanjun Guo <[email protected]> Cc: Ard Biesheuvel <[email protected]> Cc: Elena Reshetova <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 1eb085d commit 65b0085

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

include/linux/refcount.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ typedef struct refcount_struct {
2222
} refcount_t;
2323

2424
#define REFCOUNT_INIT(n) { .refs = ATOMIC_INIT(n), }
25+
#define REFCOUNT_MAX INT_MAX
26+
#define REFCOUNT_SATURATED (INT_MIN / 2)
2527

2628
enum refcount_saturation_type {
2729
REFCOUNT_ADD_NOT_ZERO_OVF,
@@ -57,9 +59,6 @@ static inline unsigned int refcount_read(const refcount_t *r)
5759
#ifdef CONFIG_REFCOUNT_FULL
5860
#include <linux/bug.h>
5961

60-
#define REFCOUNT_MAX INT_MAX
61-
#define REFCOUNT_SATURATED (INT_MIN / 2)
62-
6362
/*
6463
* Variant of atomic_t specialized for reference counts.
6564
*
@@ -300,10 +299,6 @@ static inline void refcount_dec(refcount_t *r)
300299
refcount_warn_saturate(r, REFCOUNT_DEC_LEAK);
301300
}
302301
#else /* CONFIG_REFCOUNT_FULL */
303-
304-
#define REFCOUNT_MAX INT_MAX
305-
#define REFCOUNT_SATURATED (INT_MIN / 2)
306-
307302
# ifdef CONFIG_ARCH_HAS_REFCOUNT
308303
# include <asm/refcount.h>
309304
# else

0 commit comments

Comments
 (0)