ratelimit: add initialization macro
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> Cc: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
92cab82b2c
commit
89e3f90995
1 changed files with 9 additions and 3 deletions
|
@ -17,14 +17,20 @@ struct ratelimit_state {
|
|||
unsigned long begin;
|
||||
};
|
||||
|
||||
#define DEFINE_RATELIMIT_STATE(name, interval_init, burst_init) \
|
||||
\
|
||||
struct ratelimit_state name = { \
|
||||
#define RATELIMIT_STATE_INIT(name, interval_init, burst_init) { \
|
||||
.lock = __RAW_SPIN_LOCK_UNLOCKED(name.lock), \
|
||||
.interval = interval_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,
|
||||
int interval, int burst)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue