[PATCH v3 4/8] drm/print: Add drm_printf_indent()
Noralf Trønnes
noralf at tronnes.org
Thu Oct 26 16:57:27 UTC 2017
Add drm_printf_indent() that adds tab indentation according to argument.
Signed-off-by: Noralf Trønnes <noralf at tronnes.org>
---
drivers/gpu/drm/drm_print.c | 21 +++++++++++++++++++++
include/drm/drm_print.h | 2 ++
2 files changed, 23 insertions(+)
diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c
index 0b3bf476dc4b..dac3ee98b30f 100644
--- a/drivers/gpu/drm/drm_print.c
+++ b/drivers/gpu/drm/drm_print.c
@@ -64,6 +64,27 @@ void drm_printf(struct drm_printer *p, const char *f, ...)
}
EXPORT_SYMBOL(drm_printf);
+/**
+ * drm_printf_indent - print to a &drm_printer stream with indentation
+ * @p: the &drm_printer
+ * @i: indentation
+ * @f: format string
+ */
+void drm_printf_indent(struct drm_printer *p, unsigned int i, const char *f, ...)
+{
+ struct va_format vaf;
+ va_list args;
+
+ drm_printf(p, "%.*s", i, "\t\t\t\t\t\t\t\t\t\t");
+
+ va_start(args, f);
+ vaf.fmt = f;
+ vaf.va = &args;
+ p->printfn(p, &vaf);
+ va_end(args);
+}
+EXPORT_SYMBOL(drm_printf_indent);
+
#define DRM_PRINTK_FMT "[" DRM_NAME ":%s]%s %pV"
void drm_dev_printk(const struct device *dev, const char *level,
diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
index 7b9c86a6ca3e..73dcd16eca49 100644
--- a/include/drm/drm_print.h
+++ b/include/drm/drm_print.h
@@ -79,6 +79,8 @@ void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf);
__printf(2, 3)
void drm_printf(struct drm_printer *p, const char *f, ...);
+__printf(3, 4)
+void drm_printf_indent(struct drm_printer *p, unsigned int i, const char *f, ...);
/**
--
2.14.2
More information about the dri-devel
mailing list