[RFC 4/5] drm: Use drm_printk for all logging macros
Tvrtko Ursulin
tursulin at ursulin.net
Tue Dec 6 18:58:00 UTC 2016
From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Eliminate _DRM_PRINTK macro and use drm_printk for all log levels.
This required drm_printk to vary the verbosity level of the logged
metadata depending on the log level.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
drivers/gpu/drm/drm_drv.c | 31 ++++++++++++++++++++++---------
include/drm/drmP.h | 44 ++++++++++++++++++++++++++++++--------------
2 files changed, 52 insertions(+), 23 deletions(-)
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index a2f4eb4509b9..bda4639c73e4 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -80,12 +80,21 @@ void drm_dev_printk(const struct device *dev, const char *level,
vaf.fmt = format;
vaf.va = &args;
- if (dev)
- dev_printk(level, dev, "[%s:%ps]%s %pV",
- driver, function_name, prefix, &vaf);
- else
- printk("%s[%s:%ps]%s %pV",
- level, driver, function_name, prefix, &vaf);
+ if (level[1] != KERN_DEBUG[1]) {
+ if (dev)
+ dev_printk(level, dev, "[%s]%s %pV",
+ driver, prefix, &vaf);
+ else
+ printk("%s[%s]%s %pV",
+ level, driver, prefix, &vaf);
+ } else {
+ if (dev)
+ dev_printk(level, dev, "[%s:%ps]%s %pV",
+ driver, function_name, prefix, &vaf);
+ else
+ printk("%s[%s:%ps]%s %pV",
+ level, driver, function_name, prefix, &vaf);
+ }
va_end(args);
}
@@ -104,9 +113,13 @@ void drm_printk(const char *level, unsigned int category,
vaf.fmt = format;
vaf.va = &args;
- printk("%s[%s:%ps]%s %pV",
- level, driver, __builtin_return_address(0),
- strcmp(level, KERN_ERR) == 0 ? " *ERROR*" : "", &vaf);
+ if (level[1] != KERN_DEBUG[1])
+ printk("%s[%s]%s %pV",
+ level, driver,
+ strcmp(level, KERN_ERR) == 0 ? " *ERROR*" : "", &vaf);
+ else
+ printk("%s[%s:%ps] %pV",
+ level, driver, __builtin_return_address(0), &vaf);
va_end(args);
}
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 8661045ffaf1..b8f9dcd49b36 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -146,25 +146,41 @@ struct dma_buf_attachment;
/** \name Macros to make printk easier */
/*@{*/
-#define _DRM_PRINTK(once, level, fmt, ...) \
- do { \
- printk##once(KERN_##level "[" DRM_NAME "] " fmt, \
- ##__VA_ARGS__); \
- } while (0)
-
#define DRM_INFO(fmt, ...) \
- _DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__)
-#define DRM_NOTE(fmt, ...) \
- _DRM_PRINTK(, NOTICE, fmt, ##__VA_ARGS__)
-#define DRM_WARN(fmt, ...) \
- _DRM_PRINTK(, WARNING, fmt, ##__VA_ARGS__)
+ drm_printk(KERN_INFO, DRM_UT_NONE, DRM_NAME, fmt, ##__VA_ARGS__)
#define DRM_INFO_ONCE(fmt, ...) \
- _DRM_PRINTK(_once, INFO, fmt, ##__VA_ARGS__)
+({ \
+ static bool __print_once __read_mostly; \
+ if (!__print_once) { \
+ __print_once = true; \
+ DRM_INFO(fmt, ##__VA_ARGS__); \
+ } \
+})
+
+#define DRM_NOTE(fmt, ...) \
+ drm_printk(KERN_NOTICE, DRM_UT_NONE, DRM_NAME, fmt, ##__VA_ARGS__)
+
#define DRM_NOTE_ONCE(fmt, ...) \
- _DRM_PRINTK(_once, NOTICE, fmt, ##__VA_ARGS__)
+({ \
+ static bool __print_once __read_mostly; \
+ if (!__print_once) { \
+ __print_once = true; \
+ DRM_NOTE(fmt, ##__VA_ARGS__); \
+ } \
+})
+
+#define DRM_WARN(fmt, ...) \
+ drm_printk(KERN_WARNING, DRM_UT_NONE, DRM_NAME, fmt, ##__VA_ARGS__)
+
#define DRM_WARN_ONCE(fmt, ...) \
- _DRM_PRINTK(_once, WARNING, fmt, ##__VA_ARGS__)
+({ \
+ static bool __print_once __read_mostly; \
+ if (!__print_once) { \
+ __print_once = true; \
+ DRM_WARN(fmt, ##__VA_ARGS__); \
+ } \
+})
/**
* Error output.
--
2.7.4
More information about the dri-devel
mailing list