mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-07-08 00:23:23 -04:00
seqlock: Fold seqcount_LOCKNAME_init() definition
Manual repetition is boring and error prone. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
This commit is contained in:
parent
a8772dccb2
commit
e4e9ab3f9f
1 changed files with 14 additions and 47 deletions
|
@ -143,12 +143,6 @@ static inline void seqcount_lockdep_reader_access(const seqcount_t *s)
|
||||||
__SEQ_LOCK(.lock = (assoc_lock)) \
|
__SEQ_LOCK(.lock = (assoc_lock)) \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define seqcount_locktype_init(s, assoc_lock) \
|
|
||||||
do { \
|
|
||||||
seqcount_init(&(s)->seqcount); \
|
|
||||||
__SEQ_LOCK((s)->lock = (assoc_lock)); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SEQCNT_SPINLOCK_ZERO - static initializer for seqcount_spinlock_t
|
* SEQCNT_SPINLOCK_ZERO - static initializer for seqcount_spinlock_t
|
||||||
* @name: Name of the seqcount_spinlock_t instance
|
* @name: Name of the seqcount_spinlock_t instance
|
||||||
|
@ -157,14 +151,6 @@ do { \
|
||||||
#define SEQCNT_SPINLOCK_ZERO(name, lock) \
|
#define SEQCNT_SPINLOCK_ZERO(name, lock) \
|
||||||
SEQCOUNT_LOCKTYPE_ZERO(name, lock)
|
SEQCOUNT_LOCKTYPE_ZERO(name, lock)
|
||||||
|
|
||||||
/**
|
|
||||||
* seqcount_spinlock_init - runtime initializer for seqcount_spinlock_t
|
|
||||||
* @s: Pointer to the seqcount_spinlock_t instance
|
|
||||||
* @lock: Pointer to the associated spinlock
|
|
||||||
*/
|
|
||||||
#define seqcount_spinlock_init(s, lock) \
|
|
||||||
seqcount_locktype_init(s, lock)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SEQCNT_RAW_SPINLOCK_ZERO - static initializer for seqcount_raw_spinlock_t
|
* SEQCNT_RAW_SPINLOCK_ZERO - static initializer for seqcount_raw_spinlock_t
|
||||||
* @name: Name of the seqcount_raw_spinlock_t instance
|
* @name: Name of the seqcount_raw_spinlock_t instance
|
||||||
|
@ -173,14 +159,6 @@ do { \
|
||||||
#define SEQCNT_RAW_SPINLOCK_ZERO(name, lock) \
|
#define SEQCNT_RAW_SPINLOCK_ZERO(name, lock) \
|
||||||
SEQCOUNT_LOCKTYPE_ZERO(name, lock)
|
SEQCOUNT_LOCKTYPE_ZERO(name, lock)
|
||||||
|
|
||||||
/**
|
|
||||||
* seqcount_raw_spinlock_init - runtime initializer for seqcount_raw_spinlock_t
|
|
||||||
* @s: Pointer to the seqcount_raw_spinlock_t instance
|
|
||||||
* @lock: Pointer to the associated raw_spinlock
|
|
||||||
*/
|
|
||||||
#define seqcount_raw_spinlock_init(s, lock) \
|
|
||||||
seqcount_locktype_init(s, lock)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SEQCNT_RWLOCK_ZERO - static initializer for seqcount_rwlock_t
|
* SEQCNT_RWLOCK_ZERO - static initializer for seqcount_rwlock_t
|
||||||
* @name: Name of the seqcount_rwlock_t instance
|
* @name: Name of the seqcount_rwlock_t instance
|
||||||
|
@ -189,14 +167,6 @@ do { \
|
||||||
#define SEQCNT_RWLOCK_ZERO(name, lock) \
|
#define SEQCNT_RWLOCK_ZERO(name, lock) \
|
||||||
SEQCOUNT_LOCKTYPE_ZERO(name, lock)
|
SEQCOUNT_LOCKTYPE_ZERO(name, lock)
|
||||||
|
|
||||||
/**
|
|
||||||
* seqcount_rwlock_init - runtime initializer for seqcount_rwlock_t
|
|
||||||
* @s: Pointer to the seqcount_rwlock_t instance
|
|
||||||
* @lock: Pointer to the associated rwlock
|
|
||||||
*/
|
|
||||||
#define seqcount_rwlock_init(s, lock) \
|
|
||||||
seqcount_locktype_init(s, lock)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SEQCNT_MUTEX_ZERO - static initializer for seqcount_mutex_t
|
* SEQCNT_MUTEX_ZERO - static initializer for seqcount_mutex_t
|
||||||
* @name: Name of the seqcount_mutex_t instance
|
* @name: Name of the seqcount_mutex_t instance
|
||||||
|
@ -205,14 +175,6 @@ do { \
|
||||||
#define SEQCNT_MUTEX_ZERO(name, lock) \
|
#define SEQCNT_MUTEX_ZERO(name, lock) \
|
||||||
SEQCOUNT_LOCKTYPE_ZERO(name, lock)
|
SEQCOUNT_LOCKTYPE_ZERO(name, lock)
|
||||||
|
|
||||||
/**
|
|
||||||
* seqcount_mutex_init - runtime initializer for seqcount_mutex_t
|
|
||||||
* @s: Pointer to the seqcount_mutex_t instance
|
|
||||||
* @lock: Pointer to the associated mutex
|
|
||||||
*/
|
|
||||||
#define seqcount_mutex_init(s, lock) \
|
|
||||||
seqcount_locktype_init(s, lock)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SEQCNT_WW_MUTEX_ZERO - static initializer for seqcount_ww_mutex_t
|
* SEQCNT_WW_MUTEX_ZERO - static initializer for seqcount_ww_mutex_t
|
||||||
* @name: Name of the seqcount_ww_mutex_t instance
|
* @name: Name of the seqcount_ww_mutex_t instance
|
||||||
|
@ -222,15 +184,7 @@ do { \
|
||||||
SEQCOUNT_LOCKTYPE_ZERO(name, lock)
|
SEQCOUNT_LOCKTYPE_ZERO(name, lock)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* seqcount_ww_mutex_init - runtime initializer for seqcount_ww_mutex_t
|
* typedef seqcount_LOCKNAME_t - sequence counter with LOCKTYPR associated
|
||||||
* @s: Pointer to the seqcount_ww_mutex_t instance
|
|
||||||
* @lock: Pointer to the associated ww_mutex
|
|
||||||
*/
|
|
||||||
#define seqcount_ww_mutex_init(s, lock) \
|
|
||||||
seqcount_locktype_init(s, lock)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* typedef seqcount_LOCKNAME_t - sequence counter with spinlock associated
|
|
||||||
* @seqcount: The real sequence counter
|
* @seqcount: The real sequence counter
|
||||||
* @lock: Pointer to the associated spinlock
|
* @lock: Pointer to the associated spinlock
|
||||||
*
|
*
|
||||||
|
@ -240,6 +194,12 @@ do { \
|
||||||
* that the write side critical section is properly serialized.
|
* that the write side critical section is properly serialized.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* seqcount_LOCKNAME_init() - runtime initializer for seqcount_LOCKNAME_t
|
||||||
|
* @s: Pointer to the seqcount_LOCKNAME_t instance
|
||||||
|
* @lock: Pointer to the associated LOCKTYPE
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SEQCOUNT_LOCKTYPE() - Instantiate seqcount_LOCKNAME_t and helpers
|
* SEQCOUNT_LOCKTYPE() - Instantiate seqcount_LOCKNAME_t and helpers
|
||||||
* @locktype: actual typename
|
* @locktype: actual typename
|
||||||
|
@ -253,6 +213,13 @@ typedef struct seqcount_##lockname { \
|
||||||
__SEQ_LOCK(locktype *lock); \
|
__SEQ_LOCK(locktype *lock); \
|
||||||
} seqcount_##lockname##_t; \
|
} seqcount_##lockname##_t; \
|
||||||
\
|
\
|
||||||
|
static __always_inline void \
|
||||||
|
seqcount_##lockname##_init(seqcount_##lockname##_t *s, locktype *lock) \
|
||||||
|
{ \
|
||||||
|
seqcount_init(&s->seqcount); \
|
||||||
|
__SEQ_LOCK(s->lock = lock); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
static __always_inline seqcount_t * \
|
static __always_inline seqcount_t * \
|
||||||
__seqcount_##lockname##_ptr(seqcount_##lockname##_t *s) \
|
__seqcount_##lockname##_ptr(seqcount_##lockname##_t *s) \
|
||||||
{ \
|
{ \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue