Commit 63f4cc01 authored by Jordan Crouse's avatar Jordan Crouse Committed by Rob Clark

drm: Add drm_puts() to complement drm_printf()

Add drm_puts() for a much faster path to print constant strings
into a drm_printer object with memcpy and friends. This can
have seconds off of really large outputs such as GPU dumps.

If the drm_printer object supports a custom puts function then
use that otherwise fall back to the slower legacy printf call.

v2: Add documentation for drm_puts() per Daniel Vetter
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
[robclark fix minor htmldocs warning]
Signed-off-by: default avatarRob Clark <robdclark@gmail.com>
parent cfc57a18
...@@ -122,6 +122,23 @@ void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf) ...@@ -122,6 +122,23 @@ void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf)
} }
EXPORT_SYMBOL(__drm_printfn_debug); EXPORT_SYMBOL(__drm_printfn_debug);
/**
* drm_puts - print a const string to a &drm_printer stream
* @p: the &drm printer
* @str: const string
*
* Allow &drm_printer types that have a constant string
* option to use it.
*/
void drm_puts(struct drm_printer *p, const char *str)
{
if (p->puts)
p->puts(p, str);
else
drm_printf(p, "%s", str);
}
EXPORT_SYMBOL(drm_puts);
/** /**
* drm_printf - print to a &drm_printer stream * drm_printf - print to a &drm_printer stream
* @p: the &drm_printer * @p: the &drm_printer
......
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
struct drm_printer { struct drm_printer {
/* private: */ /* private: */
void (*printfn)(struct drm_printer *p, struct va_format *vaf); void (*printfn)(struct drm_printer *p, struct va_format *vaf);
void (*puts)(struct drm_printer *p, const char *str);
void *arg; void *arg;
const char *prefix; const char *prefix;
}; };
...@@ -80,6 +81,7 @@ void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf); ...@@ -80,6 +81,7 @@ void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf);
__printf(2, 3) __printf(2, 3)
void drm_printf(struct drm_printer *p, const char *f, ...); void drm_printf(struct drm_printer *p, const char *f, ...);
void drm_puts(struct drm_printer *p, const char *str);
__printf(2, 0) __printf(2, 0)
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment