Skip to content

Commit

Permalink
audit: use atomic_t to simplify audit_serial()
Browse files Browse the repository at this point in the history
Since there is already a primitive to do this operation in the atomic_t, use it
to simplify audit_serial().

Signed-off-by: Richard Guy Briggs <[email protected]>
  • Loading branch information
rgbriggs authored and eparis committed Sep 23, 2014
1 parent 6eed9b2 commit 01478d7
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions kernel/audit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1301,19 +1301,9 @@ static struct audit_buffer * audit_buffer_alloc(struct audit_context *ctx,
*/
unsigned int audit_serial(void)
{
static DEFINE_SPINLOCK(serial_lock);
static unsigned int serial = 0;
static atomic_t serial = ATOMIC_INIT(0);

unsigned long flags;
unsigned int ret;

spin_lock_irqsave(&serial_lock, flags);
do {
ret = ++serial;
} while (unlikely(!ret));
spin_unlock_irqrestore(&serial_lock, flags);

return ret;
return atomic_add_return(1, &serial);
}

static inline void audit_get_stamp(struct audit_context *ctx,
Expand Down

0 comments on commit 01478d7

Please sign in to comment.