audit: use atomic_t to simplify audit_serial()
authorRichard Guy Briggs <rgb@redhat.com>
Fri, 13 Jun 2014 22:22:00 +0000 (18:22 -0400)
committerEric Paris <eparis@redhat.com>
Tue, 23 Sep 2014 20:37:52 +0000 (16:37 -0400)
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 <rgb@redhat.com>
kernel/audit.c

index 8a82d48..7aef7cb 100644 (file)
@@ -1301,19 +1301,9 @@ err:
  */
 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,