Skip to content

Commit

Permalink
ratelimit: add initialization macro
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Monakhov <[email protected]>
Cc: Akinobu Mita <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Dmitry Monakhov authored and torvalds committed Dec 13, 2014
1 parent 92cab82 commit 89e3f90
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions include/linux/ratelimit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 89e3f90

Please sign in to comment.