mirror of https://gitee.com/openkylin/linux.git
drm: Add a helper function for printing a debugfs_regset32.
The debugfs_regset32 is nice to use for reducing boilerplate in dumping a bunch of regs in debugfs, but we also want to be able to print to dmesg them at runtime for driver debugging. drm_printer lets us format debugfs and the printk the same way. v2: Add some kerneldoc for the function (requested by danvet) Signed-off-by: Eric Anholt <eric@anholt.net> Link: https://patchwork.freedesktop.org/patch/msgid/20190220210343.28157-1-eric@anholt.net Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> (v1) Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
3f0b646e1a
commit
5f513cc89e
|
@ -253,3 +253,31 @@ void drm_err(const char *format, ...)
|
|||
va_end(args);
|
||||
}
|
||||
EXPORT_SYMBOL(drm_err);
|
||||
|
||||
/**
|
||||
* drm_print_regset32 - print the contents of registers to a
|
||||
* &drm_printer stream.
|
||||
*
|
||||
* @p: the &drm printer
|
||||
* @regset: the list of registers to print.
|
||||
*
|
||||
* Often in driver debug, it's useful to be able to either capture the
|
||||
* contents of registers in the steady state using debugfs or at
|
||||
* specific points during operation. This lets the driver have a
|
||||
* single list of registers for both.
|
||||
*/
|
||||
void drm_print_regset32(struct drm_printer *p, struct debugfs_regset32 *regset)
|
||||
{
|
||||
int namelen = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < regset->nregs; i++)
|
||||
namelen = max(namelen, (int)strlen(regset->regs[i].name));
|
||||
|
||||
for (i = 0; i < regset->nregs; i++) {
|
||||
drm_printf(p, "%*s = 0x%08x\n",
|
||||
namelen, regset->regs[i].name,
|
||||
readl(regset->base + regset->regs[i].offset));
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(drm_print_regset32);
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <linux/printk.h>
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/debugfs.h>
|
||||
|
||||
/**
|
||||
* DOC: print
|
||||
|
@ -84,6 +85,7 @@ 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, ...);
|
||||
void drm_puts(struct drm_printer *p, const char *str);
|
||||
void drm_print_regset32(struct drm_printer *p, struct debugfs_regset32 *regset);
|
||||
|
||||
__printf(2, 0)
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue