Commit 89e3f909 authored by Dmitry Monakhov's avatar Dmitry Monakhov Committed by Linus Torvalds

ratelimit: add initialization macro

Signed-off-by: default avatarDmitry Monakhov <dmonakhov@openvz.org>
Cc: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 92cab82b
...@@ -17,14 +17,20 @@ struct ratelimit_state { ...@@ -17,14 +17,20 @@ struct ratelimit_state {
unsigned long begin; unsigned long begin;
}; };
#define DEFINE_RATELIMIT_STATE(name, interval_init, burst_init) \ #define RATELIMIT_STATE_INIT(name, interval_init, burst_init) { \
\
struct ratelimit_state name = { \
.lock = __RAW_SPIN_LOCK_UNLOCKED(name.lock), \ .lock = __RAW_SPIN_LOCK_UNLOCKED(name.lock), \
.interval = interval_init, \ .interval = interval_init, \
.burst = burst_init, \ .burst = burst_init, \
} }
#define RATELIMIT_STATE_INIT_DISABLED \
RATELIMIT_STATE_INIT(ratelimit_state, 0, DEFAULT_RATELIMIT_BURST)
#define DEFINE_RATELIMIT_STATE(name, interval_init, burst_init) \
\
struct ratelimit_state name = \
RATELIMIT_STATE_INIT(name, interval_init, burst_init) \
static inline void ratelimit_state_init(struct ratelimit_state *rs, static inline void ratelimit_state_init(struct ratelimit_state *rs,
int interval, int burst) int interval, int burst)
{ {
......
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