Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/tests: Switch to kunit devices

Kunit recently gained helpers to create test managed devices. This means
that we no longer have to roll our own helpers in KMS and we can reuse
them.

Signed-off-by: Maxime Ripard <mripard@kernel.org>
Tested-by: David Gow <davidgow@google.com>
Signed-off-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Maxime Ripard and committed by
Shuah Khan
d393acce e57cdff0

+3 -63
+3 -63
drivers/gpu/drm/tests/drm_kunit_helpers.c
··· 5 5 #include <drm/drm_kunit_helpers.h> 6 6 #include <drm/drm_managed.h> 7 7 8 + #include <kunit/device.h> 8 9 #include <kunit/resource.h> 9 10 10 11 #include <linux/device.h> ··· 15 14 16 15 static const struct drm_mode_config_funcs drm_mode_config_funcs = { 17 16 }; 18 - 19 - static int fake_probe(struct platform_device *pdev) 20 - { 21 - return 0; 22 - } 23 - 24 - static struct platform_driver fake_platform_driver = { 25 - .probe = fake_probe, 26 - .driver = { 27 - .name = KUNIT_DEVICE_NAME, 28 - }, 29 - }; 30 - 31 - KUNIT_DEFINE_ACTION_WRAPPER(kunit_action_platform_driver_unregister, 32 - platform_driver_unregister, 33 - struct platform_driver *); 34 - KUNIT_DEFINE_ACTION_WRAPPER(kunit_action_platform_device_put, 35 - platform_device_put, 36 - struct platform_device *); 37 - KUNIT_DEFINE_ACTION_WRAPPER(kunit_action_platform_device_del, 38 - platform_device_del, 39 - struct platform_device *); 40 17 41 18 /** 42 19 * drm_kunit_helper_alloc_device - Allocate a mock device for a KUnit test ··· 33 54 */ 34 55 struct device *drm_kunit_helper_alloc_device(struct kunit *test) 35 56 { 36 - struct platform_device *pdev; 37 - int ret; 38 - 39 - ret = platform_driver_register(&fake_platform_driver); 40 - KUNIT_ASSERT_EQ(test, ret, 0); 41 - 42 - ret = kunit_add_action_or_reset(test, 43 - kunit_action_platform_driver_unregister, 44 - &fake_platform_driver); 45 - KUNIT_ASSERT_EQ(test, ret, 0); 46 - 47 - pdev = platform_device_alloc(KUNIT_DEVICE_NAME, PLATFORM_DEVID_NONE); 48 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pdev); 49 - 50 - ret = kunit_add_action_or_reset(test, 51 - kunit_action_platform_device_put, 52 - pdev); 53 - KUNIT_ASSERT_EQ(test, ret, 0); 54 - 55 - ret = platform_device_add(pdev); 56 - KUNIT_ASSERT_EQ(test, ret, 0); 57 - 58 - ret = kunit_add_action_or_reset(test, 59 - kunit_action_platform_device_del, 60 - pdev); 61 - KUNIT_ASSERT_EQ(test, ret, 0); 62 - 63 - return &pdev->dev; 57 + return kunit_device_register(test, KUNIT_DEVICE_NAME); 64 58 } 65 59 EXPORT_SYMBOL_GPL(drm_kunit_helper_alloc_device); 66 60 ··· 46 94 */ 47 95 void drm_kunit_helper_free_device(struct kunit *test, struct device *dev) 48 96 { 49 - struct platform_device *pdev = to_platform_device(dev); 50 - 51 - kunit_release_action(test, 52 - kunit_action_platform_device_del, 53 - pdev); 54 - 55 - kunit_release_action(test, 56 - kunit_action_platform_device_put, 57 - pdev); 58 - 59 - kunit_release_action(test, 60 - kunit_action_platform_driver_unregister, 61 - &fake_platform_driver); 97 + kunit_device_unregister(test, dev); 62 98 } 63 99 EXPORT_SYMBOL_GPL(drm_kunit_helper_free_device); 64 100