Skip to content

Commit 0efc94c

Browse files
author
Peter Zijlstra
committed
seqcount: Compress SEQCNT_LOCKNAME_ZERO()
Less is more. Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
1 parent e4e9ab3 commit 0efc94c

File tree

1 file changed

+18
-45
lines changed

1 file changed

+18
-45
lines changed

include/linux/seqlock.h

Lines changed: 18 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -138,51 +138,6 @@ static inline void seqcount_lockdep_reader_access(const seqcount_t *s)
138138
#define __SEQ_LOCK(expr)
139139
#endif
140140

141-
#define SEQCOUNT_LOCKTYPE_ZERO(seq_name, assoc_lock) { \
142-
.seqcount = SEQCNT_ZERO(seq_name.seqcount), \
143-
__SEQ_LOCK(.lock = (assoc_lock)) \
144-
}
145-
146-
/**
147-
* SEQCNT_SPINLOCK_ZERO - static initializer for seqcount_spinlock_t
148-
* @name: Name of the seqcount_spinlock_t instance
149-
* @lock: Pointer to the associated spinlock
150-
*/
151-
#define SEQCNT_SPINLOCK_ZERO(name, lock) \
152-
SEQCOUNT_LOCKTYPE_ZERO(name, lock)
153-
154-
/**
155-
* SEQCNT_RAW_SPINLOCK_ZERO - static initializer for seqcount_raw_spinlock_t
156-
* @name: Name of the seqcount_raw_spinlock_t instance
157-
* @lock: Pointer to the associated raw_spinlock
158-
*/
159-
#define SEQCNT_RAW_SPINLOCK_ZERO(name, lock) \
160-
SEQCOUNT_LOCKTYPE_ZERO(name, lock)
161-
162-
/**
163-
* SEQCNT_RWLOCK_ZERO - static initializer for seqcount_rwlock_t
164-
* @name: Name of the seqcount_rwlock_t instance
165-
* @lock: Pointer to the associated rwlock
166-
*/
167-
#define SEQCNT_RWLOCK_ZERO(name, lock) \
168-
SEQCOUNT_LOCKTYPE_ZERO(name, lock)
169-
170-
/**
171-
* SEQCNT_MUTEX_ZERO - static initializer for seqcount_mutex_t
172-
* @name: Name of the seqcount_mutex_t instance
173-
* @lock: Pointer to the associated mutex
174-
*/
175-
#define SEQCNT_MUTEX_ZERO(name, lock) \
176-
SEQCOUNT_LOCKTYPE_ZERO(name, lock)
177-
178-
/**
179-
* SEQCNT_WW_MUTEX_ZERO - static initializer for seqcount_ww_mutex_t
180-
* @name: Name of the seqcount_ww_mutex_t instance
181-
* @lock: Pointer to the associated ww_mutex
182-
*/
183-
#define SEQCNT_WW_MUTEX_ZERO(name, lock) \
184-
SEQCOUNT_LOCKTYPE_ZERO(name, lock)
185-
186141
/**
187142
* typedef seqcount_LOCKNAME_t - sequence counter with LOCKTYPR associated
188143
* @seqcount: The real sequence counter
@@ -263,6 +218,24 @@ SEQCOUNT_LOCKTYPE(rwlock_t, rwlock, false, s->lock)
263218
SEQCOUNT_LOCKTYPE(struct mutex, mutex, true, s->lock)
264219
SEQCOUNT_LOCKTYPE(struct ww_mutex, ww_mutex, true, &s->lock->base)
265220

221+
/**
222+
* SEQCNT_LOCKNAME_ZERO - static initializer for seqcount_LOCKNAME_t
223+
* @name: Name of the seqcount_LOCKNAME_t instance
224+
* @lock: Pointer to the associated LOCKTYPE
225+
*/
226+
227+
#define SEQCOUNT_LOCKTYPE_ZERO(seq_name, assoc_lock) { \
228+
.seqcount = SEQCNT_ZERO(seq_name.seqcount), \
229+
__SEQ_LOCK(.lock = (assoc_lock)) \
230+
}
231+
232+
#define SEQCNT_SPINLOCK_ZERO(name, lock) SEQCOUNT_LOCKTYPE_ZERO(name, lock)
233+
#define SEQCNT_RAW_SPINLOCK_ZERO(name, lock) SEQCOUNT_LOCKTYPE_ZERO(name, lock)
234+
#define SEQCNT_RWLOCK_ZERO(name, lock) SEQCOUNT_LOCKTYPE_ZERO(name, lock)
235+
#define SEQCNT_MUTEX_ZERO(name, lock) SEQCOUNT_LOCKTYPE_ZERO(name, lock)
236+
#define SEQCNT_WW_MUTEX_ZERO(name, lock) SEQCOUNT_LOCKTYPE_ZERO(name, lock)
237+
238+
266239
#define __seqprop_case(s, lockname, prop) \
267240
seqcount_##lockname##_t: __seqcount_##lockname##_##prop((void *)(s))
268241

0 commit comments

Comments
 (0)