diff options
author | Richard Guy Briggs <rgb@redhat.com> | 2014-06-13 18:22:00 -0400 |
---|---|---|
committer | Eric Paris <eparis@redhat.com> | 2014-09-23 16:37:52 -0400 |
commit | 01478d7d60f654419ba863856cad0446bcb73a59 (patch) | |
tree | 3b8b9a1ef0b17e57234b79c92e8383d9a7944ee9 /kernel/audit.c | |
parent | 6eed9b261334932c742458edd64b7b9fd0b981a9 (diff) |
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: Richard Guy Briggs <rgb@redhat.com>
Diffstat (limited to 'kernel/audit.c')
-rw-r--r-- | kernel/audit.c | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/kernel/audit.c b/kernel/audit.c index 8a82d481393d..7aef7cbd7bcf 100644 --- a/kernel/audit.c +++ b/kernel/audit.c | |||
@@ -1301,19 +1301,9 @@ err: | |||
1301 | */ | 1301 | */ |
1302 | unsigned int audit_serial(void) | 1302 | unsigned int audit_serial(void) |
1303 | { | 1303 | { |
1304 | static DEFINE_SPINLOCK(serial_lock); | 1304 | static atomic_t serial = ATOMIC_INIT(0); |
1305 | static unsigned int serial = 0; | ||
1306 | 1305 | ||
1307 | unsigned long flags; | 1306 | return atomic_add_return(1, &serial); |
1308 | unsigned int ret; | ||
1309 | |||
1310 | spin_lock_irqsave(&serial_lock, flags); | ||
1311 | do { | ||
1312 | ret = ++serial; | ||
1313 | } while (unlikely(!ret)); | ||
1314 | spin_unlock_irqrestore(&serial_lock, flags); | ||
1315 | |||
1316 | return ret; | ||
1317 | } | 1307 | } |
1318 | 1308 | ||
1319 | static inline void audit_get_stamp(struct audit_context *ctx, | 1309 | static inline void audit_get_stamp(struct audit_context *ctx, |