diff options
author | David Gow <davidgow@google.com> | 2023-11-28 15:24:06 +0800 |
---|---|---|
committer | Shuah Khan <skhan@linuxfoundation.org> | 2023-12-18 13:21:14 -0700 |
commit | e847934bb124b2ad14bf967d6682e43b0b94c78a (patch) | |
tree | 9f9572852cbda7c173e5121fbfdd3c9b919e34e6 /drivers/gpu/drm/tests/drm_kunit_helpers.c | |
parent | 56778b49c9a2cbc32c6b0fbd3ba1a9d64192d3af (diff) | |
download | linux-stable-e847934bb124b2ad14bf967d6682e43b0b94c78a.tar.gz linux-stable-e847934bb124b2ad14bf967d6682e43b0b94c78a.tar.bz2 linux-stable-e847934bb124b2ad14bf967d6682e43b0b94c78a.zip |
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: Maxime Ripard <mripard@kernel.org>
Signed-off-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'drivers/gpu/drm/tests/drm_kunit_helpers.c')
-rw-r--r-- | drivers/gpu/drm/tests/drm_kunit_helpers.c | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/drivers/gpu/drm/tests/drm_kunit_helpers.c b/drivers/gpu/drm/tests/drm_kunit_helpers.c index bccb33b900f3..c251e6b34de0 100644 --- a/drivers/gpu/drm/tests/drm_kunit_helpers.c +++ b/drivers/gpu/drm/tests/drm_kunit_helpers.c @@ -27,27 +27,15 @@ static struct platform_driver fake_platform_driver = { }, }; -static void kunit_action_platform_driver_unregister(void *ptr) -{ - struct platform_driver *drv = ptr; - - platform_driver_unregister(drv); - -} - -static void kunit_action_platform_device_put(void *ptr) -{ - 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); -} +KUNIT_DEFINE_ACTION_WRAPPER(kunit_action_platform_driver_unregister, + platform_driver_unregister, + struct platform_driver *); +KUNIT_DEFINE_ACTION_WRAPPER(kunit_action_platform_device_put, + platform_device_put, + struct platform_device *); +KUNIT_DEFINE_ACTION_WRAPPER(kunit_action_platform_device_del, + platform_device_del, + struct platform_device *); /** * drm_kunit_helper_alloc_device - Allocate a mock device for a KUnit test |