From: Hiroshi DOYU Date: Mon, 14 May 2012 07:47:57 +0000 (+0300) Subject: driver core: Add dev_*_ratelimited() family X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=6ca045930338485a8cdef117e74372aa1678009d;p=linux-beck.git driver core: Add dev_*_ratelimited() family Add dev_*_ratelimited() family, dev_* version of pr_*_ratelimited(). Using Joe Perches's proposal/implementation. Signed-off-by: Hiroshi DOYU Cc: Joe Perches Signed-off-by: Greg Kroah-Hartman --- diff --git a/include/linux/device.h b/include/linux/device.h index 863acf8a0dce..a8db2cfa2c81 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -23,6 +23,7 @@ #include #include #include +#include #include struct device; @@ -933,6 +934,32 @@ int _dev_info(const struct device *dev, const char *fmt, ...) #endif +#define dev_level_ratelimited(dev_level, dev, fmt, ...) \ +do { \ + static DEFINE_RATELIMIT_STATE(_rs, \ + DEFAULT_RATELIMIT_INTERVAL, \ + DEFAULT_RATELIMIT_BURST); \ + if (__ratelimit(&_rs)) \ + dev_level(dev, fmt, ##__VA_ARGS__); \ +} while (0) + +#define dev_emerg_ratelimited(dev, fmt, ...) \ + dev_level_ratelimited(dev_emerg, dev, fmt, ##__VA_ARGS__) +#define dev_alert_ratelimited(dev, fmt, ...) \ + dev_level_ratelimited(dev_alert, dev, fmt, ##__VA_ARGS__) +#define dev_crit_ratelimited(dev, fmt, ...) \ + dev_level_ratelimited(dev_crit, dev, fmt, ##__VA_ARGS__) +#define dev_err_ratelimited(dev, fmt, ...) \ + dev_level_ratelimited(dev_err, dev, fmt, ##__VA_ARGS__) +#define dev_warn_ratelimited(dev, fmt, ...) \ + dev_level_ratelimited(dev_warn, dev, fmt, ##__VA_ARGS__) +#define dev_notice_ratelimited(dev, fmt, ...) \ + dev_level_ratelimited(dev_notice, dev, fmt, ##__VA_ARGS__) +#define dev_info_ratelimited(dev, fmt, ...) \ + dev_level_ratelimited(dev_info, dev, fmt, ##__VA_ARGS__) +#define dev_dbg_ratelimited(dev, fmt, ...) \ + dev_level_ratelimited(dev_dbg, dev, fmt, ##__VA_ARGS__) + /* * Stupid hackaround for existing uses of non-printk uses dev_info *