X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=drivers%2Fgpu%2Fdrm%2Fdrm_print.c;h=dfa27367ebb8537ec8874616e0f0b5532de34121;hb=2dc5d44ccc5e7f032dbea2735b243f7f50ff863e;hp=a17c8a14dba4f9401c7ffbfed8d1eda4d0e2153a;hpb=5fe7b600a116187e10317d83fb56922c4ef6b76d;p=linux.git diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index a17c8a14dba4..dfa27367ebb8 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -147,6 +147,12 @@ void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf) } EXPORT_SYMBOL(__drm_printfn_debug); +void __drm_printfn_err(struct drm_printer *p, struct va_format *vaf) +{ + pr_err("*ERROR* %s %pV", p->prefix, vaf); +} +EXPORT_SYMBOL(__drm_printfn_err); + /** * drm_puts - print a const string to a &drm_printer stream * @p: the &drm printer @@ -179,6 +185,39 @@ void drm_printf(struct drm_printer *p, const char *f, ...) } EXPORT_SYMBOL(drm_printf); +/** + * drm_print_bits - print bits to a &drm_printer stream + * + * Print bits (in flag fields for example) in human readable form. + * The first name in the @bits array is for the bit indexed by @from. + * + * @p: the &drm_printer + * @value: field value. + * @bits: Array with bit names. + * @from: start of bit range to print (inclusive). + * @to: end of bit range to print (exclusive). + */ +void drm_print_bits(struct drm_printer *p, + unsigned long value, const char *bits[], + unsigned int from, unsigned int to) +{ + bool first = true; + unsigned int i; + + for (i = from; i < to; i++) { + if (!(value & (1 << i))) + continue; + if (WARN_ON_ONCE(!bits[i-from])) + continue; + drm_printf(p, "%s%s", first ? "" : ",", + bits[i-from]); + first = false; + } + if (first) + drm_printf(p, "(none)"); +} +EXPORT_SYMBOL(drm_print_bits); + void drm_dev_printk(const struct device *dev, const char *level, const char *format, ...) {