public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC 1/1] driver core: Add dev_*_ratelimited() family
@ 2012-05-12 10:52 Hiroshi Doyu
       [not found] ` <20120512.135227.1196366807162247040.hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  2012-05-12 15:31 ` Joe Perches
  0 siblings, 2 replies; 14+ messages in thread
From: Hiroshi Doyu @ 2012-05-12 10:52 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
  Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

Hi,

An unclosed "if" statement in the MACRO seems a bit risky, but I don't
have any better/simple solution for this, ATM. Is there any alternative?


From: Hiroshi DOYU <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

Add dev_*_ratelimited() family, dev_* version of pr_*_ratelimited().

Signed-off-by: Hiroshi DOYU <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
 include/linux/device.h |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/include/linux/device.h b/include/linux/device.h
index 8b9d03a..9d976df 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -23,6 +23,7 @@
 #include <linux/mutex.h>
 #include <linux/pm.h>
 #include <linux/atomic.h>
+#include <linux/ratelimit.h>
 #include <asm/device.h>
 
 struct device;
@@ -937,6 +938,27 @@ int _dev_info(const struct device *dev, const char *fmt, ...)
 
 #endif
 
+#define IF_DEV_RATELIMITED						\
+	static DEFINE_RATELIMIT_STATE(_rs,				\
+				      DEFAULT_RATELIMIT_INTERVAL,	\
+				      DEFAULT_RATELIMIT_BURST);		\
+	if (__ratelimit(&_rs))
+
+#define dev_emerg_ratelimited(dev, fmt, ...)				\
+	do { IF_DEV_RATELIMITED dev_printk(KERN_EMERG, dev, fmt, ##__VA_ARGS__); } while (0)
+#define dev_alert_ratelimited(dev, fmt, ...)				\
+	do { IF_DEV_RATELIMITED dev_printk(KERN_ALERT, dev, fmt, ##__VA_ARGS__); } while (0)
+#define dev_crit_ratelimited(dev, fmt, ...)				\
+	do { IF_DEV_RATELIMITED dev_printk(KERN_CRIT, dev, fmt, ##__VA_ARGS__); } while (0)
+#define dev_err_ratelimited(dev, fmt, ...)				\
+	do { IF_DEV_RATELIMITED dev_printk(KERN_ERR, dev, fmt, ##__VA_ARGS__); } while (0)
+#define dev_warn_ratelimited(dev, fmt, ...)				\
+	do { IF_DEV_RATELIMITED dev_printk(KERN_WARNING, dev, fmt, ##__VA_ARGS__); } while (0)
+#define dev_notice_ratelimited(dev, fmt, ...)				\
+	do { IF_DEV_RATELIMITED dev_printk(KERN_NOTICE, dev, fmt, ##__VA_ARGS__); } while (0)
+#define dev_info_ratelimited(dev, fmt, ...)				\
+	do { IF_DEV_RATELIMITED dev_printk(KERN_INFO, dev, fmt, ##__VA_ARGS__); } while (0)
+
 /*
  * Stupid hackaround for existing uses of non-printk uses dev_info
  *
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-05-14 19:09 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-12 10:52 [RFC 1/1] driver core: Add dev_*_ratelimited() family Hiroshi Doyu
     [not found] ` <20120512.135227.1196366807162247040.hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-05-12 11:32   ` Bernd Petrovitsch
2012-05-12 15:31 ` Joe Perches
2012-05-14  5:00   ` Hiroshi Doyu
2012-05-14  5:25     ` Joe Perches
2012-05-14  5:40       ` Hiroshi Doyu
     [not found]         ` <20120514.084014.1683295633804914511.hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-05-14  6:05           ` Joe Perches
2012-05-14  7:45             ` Hiroshi Doyu
     [not found]               ` <20120514.104512.775373956832728793.hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-05-14  7:47                 ` [PATCH 1/2] " Hiroshi DOYU
2012-05-14  7:47                   ` [PATCH 2/2] memory: tegra{20,30}-mc: Use dev_err_ratelimited() Hiroshi DOYU
2012-05-14 10:07                     ` [v2 1/1] " Hiroshi DOYU
     [not found]                       ` <1336990031-15567-1-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-05-14 18:33                         ` Stephen Warren
     [not found]                           ` <4FB14FDE.2080409-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-05-14 18:57                             ` Hiroshi Doyu
2012-05-14 19:09                             ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox