drm/panel-edp: Add STA 116QHD024002
[drm/drm-misc.git] / include / linux / ratelimit_types.h
blob765232ce0b5e9986bbf686155c1237edd6bb0a96
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_RATELIMIT_TYPES_H
3 #define _LINUX_RATELIMIT_TYPES_H
5 #include <linux/bits.h>
6 #include <linux/param.h>
7 #include <linux/spinlock_types_raw.h>
9 #define DEFAULT_RATELIMIT_INTERVAL (5 * HZ)
10 #define DEFAULT_RATELIMIT_BURST 10
12 /* issue num suppressed message on exit */
13 #define RATELIMIT_MSG_ON_RELEASE BIT(0)
15 struct ratelimit_state {
16 raw_spinlock_t lock; /* protect the state */
18 int interval;
19 int burst;
20 int printed;
21 int missed;
22 unsigned int flags;
23 unsigned long begin;
26 #define RATELIMIT_STATE_INIT_FLAGS(name, interval_init, burst_init, flags_init) { \
27 .lock = __RAW_SPIN_LOCK_UNLOCKED(name.lock), \
28 .interval = interval_init, \
29 .burst = burst_init, \
30 .flags = flags_init, \
33 #define RATELIMIT_STATE_INIT(name, interval_init, burst_init) \
34 RATELIMIT_STATE_INIT_FLAGS(name, interval_init, burst_init, 0)
36 #define RATELIMIT_STATE_INIT_DISABLED \
37 RATELIMIT_STATE_INIT(ratelimit_state, 0, DEFAULT_RATELIMIT_BURST)
39 #define DEFINE_RATELIMIT_STATE(name, interval_init, burst_init) \
41 struct ratelimit_state name = \
42 RATELIMIT_STATE_INIT(name, interval_init, burst_init) \
44 extern int ___ratelimit(struct ratelimit_state *rs, const char *func);
45 #define __ratelimit(state) ___ratelimit(state, __func__)
47 #endif /* _LINUX_RATELIMIT_TYPES_H */