Commit 01478d7d authored by Richard Guy Briggs's avatar Richard Guy Briggs Committed by Eric Paris

audit: use atomic_t to simplify audit_serial()

Since there is already a primitive to do this operation in the atomic_t, use it
to simplify audit_serial().
Signed-off-by: default avatarRichard Guy Briggs <rgb@redhat.com>
parent 6eed9b26
...@@ -1301,19 +1301,9 @@ static struct audit_buffer * audit_buffer_alloc(struct audit_context *ctx, ...@@ -1301,19 +1301,9 @@ static struct audit_buffer * audit_buffer_alloc(struct audit_context *ctx,
*/ */
unsigned int audit_serial(void) unsigned int audit_serial(void)
{ {
static DEFINE_SPINLOCK(serial_lock); static atomic_t serial = ATOMIC_INIT(0);
static unsigned int serial = 0;
unsigned long flags; return atomic_add_return(1, &serial);
unsigned int ret;
spin_lock_irqsave(&serial_lock, flags);
do {
ret = ++serial;
} while (unlikely(!ret));
spin_unlock_irqrestore(&serial_lock, flags);
return ret;
} }
static inline void audit_get_stamp(struct audit_context *ctx, static inline void audit_get_stamp(struct audit_context *ctx,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment