Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] drm/tests: wrong constant family in drm_kunit_helper_printer() kernel-doc --
commit 886820e203ca83b1374826ea99ea6f649c1fd41e Author: Maxime Ripard <[email protected]> drm/tests: kunit: Add a drm_printer helper This commit adds drm_kunit_helper_printer() to create a drm_printer that forwards messages to kunit_log() at a specified log level. > diff --git a/drivers/gpu/drm/tests/drm_kunit_helpers.c > b/drivers/gpu/drm/tests/drm_kunit_helpers.c > index 63d0249465005..fad911772ee59 100644 > --- a/drivers/gpu/drm/tests/drm_kunit_helpers.c > +++ b/drivers/gpu/drm/tests/drm_kunit_helpers.c > @@ -8,6 +8,7 @@ > #include <drm/drm_fourcc.h> > #include <drm/drm_kunit_helpers.h> > #include <drm/drm_managed.h> > +#include <drm/drm_print.h> > > #include <kunit/device.h> > #include <kunit/resource.h> > @@ -18,6 +19,83 @@ > > #define KUNIT_DEVICE_NAME "drm-kunit-mock-device" > > +struct drm_printer_ctx { > + struct drm_printer p; > + int level; > + struct kunit *test; > +}; > + > +/* > + * kunit_log() is a macro that only accepts a compile-time log level, > + * so the level has to be dispatched to the matching kunit_log() call. > + */ > +static void drm_kunit_printf(struct drm_printer *p, struct va_format *vaf) > +{ > + struct drm_printer_ctx *ctx = p->arg; > + > + switch (ctx->level) { > + case LOGLEVEL_EMERG: > + kunit_log(KERN_EMERG, ctx->test, "%pV", vaf); > + break; [ ... ] > +/** > + * drm_kunit_helper_printer - Creates a &drm_printer logging into a KUnit > test log > + * @test: The test context object > + * @level: The log level to log the messages at, one of the KERN_* constants [Severity: Low] Should the kernel-doc for @level in drm_kunit_helper_printer() refer to the LOGLEVEL_* constants instead of KERN_*? The KERN_* macros are string literals, whereas drm_kunit_helper_printer() takes an int level and drm_kunit_printf() switches on ctx->level against LOGLEVEL_EMERG through LOGLEVEL_INFO. Passing a KERN_* constant here will trigger a pointer-to-integer conversion warning and fall through to the default case in drm_kunit_printf(). -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=24
