drm/printer: Add drm_vprintf()
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 23 Nov 2017 08:40:46 +0000 (08:40 +0000)
committerJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Thu, 23 Nov 2017 10:31:49 +0000 (12:31 +0200)
Simple va_args equivalent to the existing drm_printf() for use with the
drm_printer.

v2: Fixup kerneldoc to match final parameter names.
v3: Turn it into a kerneldoc comment

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Rob Clark <robdclark@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Acked-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20171123084051.30203-1-chris@chris-wilson.co.uk
drivers/gpu/drm/drm_print.c
include/drm/drm_print.h

index 82ff327eb2df8cde1c773979b8bbfc6812e4594d..781518fd88e36849f5b5f80a277202d3e113aa2e 100644 (file)
@@ -55,13 +55,10 @@ EXPORT_SYMBOL(__drm_printfn_debug);
  */
 void drm_printf(struct drm_printer *p, const char *f, ...)
 {
-       struct va_format vaf;
        va_list args;
 
        va_start(args, f);
-       vaf.fmt = f;
-       vaf.va = &args;
-       p->printfn(p, &vaf);
+       drm_vprintf(p, f, &args);
        va_end(args);
 }
 EXPORT_SYMBOL(drm_printf);
index 0968e411f56274f8e4c1be7ae8ab39458da17266..5f9932e2246e19629024b979852bc40a3eb63c06 100644 (file)
@@ -80,6 +80,21 @@ 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, ...);
 
+/**
+ * drm_vprintf - print to a &drm_printer stream
+ * @p: the &drm_printer
+ * @fmt: format string
+ * @va: the va_list
+ */
+__printf(2, 0)
+static inline void
+drm_vprintf(struct drm_printer *p, const char *fmt, va_list *va)
+{
+       struct va_format vaf = { .fmt = fmt, .va = va };
+
+       p->printfn(p, &vaf);
+}
+
 /**
  * drm_printf_indent - Print to a &drm_printer stream with indentation
  * @printer: DRM printer