Commit e847934b authored by David Gow's avatar David Gow Committed by Shuah Khan

drm/tests: Use KUNIT_DEFINE_ACTION_WRAPPER()

In order to pass functions to kunit_add_action(), they need to be of the
kunit_action_t type. While casting the function pointer can work, it
will break control-flow integrity.

drm_kunit_helpers already defines wrappers, but we now have a macro
which does this automatically. Using this greatly reduces the
boilerplate needed.
Acked-by: default avatarMaxime Ripard <mripard@kernel.org>
Signed-off-by: default avatarDavid Gow <davidgow@google.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent 56778b49
...@@ -27,27 +27,15 @@ static struct platform_driver fake_platform_driver = { ...@@ -27,27 +27,15 @@ static struct platform_driver fake_platform_driver = {
}, },
}; };
static void kunit_action_platform_driver_unregister(void *ptr) KUNIT_DEFINE_ACTION_WRAPPER(kunit_action_platform_driver_unregister,
{ platform_driver_unregister,
struct platform_driver *drv = ptr; struct platform_driver *);
KUNIT_DEFINE_ACTION_WRAPPER(kunit_action_platform_device_put,
platform_driver_unregister(drv); platform_device_put,
struct platform_device *);
} KUNIT_DEFINE_ACTION_WRAPPER(kunit_action_platform_device_del,
platform_device_del,
static void kunit_action_platform_device_put(void *ptr) struct platform_device *);
{
struct platform_device *pdev = ptr;
platform_device_put(pdev);
}
static void kunit_action_platform_device_del(void *ptr)
{
struct platform_device *pdev = ptr;
platform_device_del(pdev);
}
/** /**
* drm_kunit_helper_alloc_device - Allocate a mock device for a KUnit test * drm_kunit_helper_alloc_device - Allocate a mock device for a KUnit test
......
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