From: Maxime Ripard Date: Thu, 1 Dec 2022 15:11:39 +0000 (+0100) Subject: drm/tests: helpers: Switch to a platform_device X-Git-Tag: v6.6.7~1918^2~23^2~1189 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0bdc2e28efd9e1b76297cc8f3c54cac3806803ff;p=platform%2Fkernel%2Flinux-starfive.git drm/tests: helpers: Switch to a platform_device The device managed resources are ran if the device has bus, which is not the case of a root_device. Let's use a platform_device instead. Reviewed-by: Javier Martinez Canillas Reviewed-by: MaĆ­ra Canal Link: https://lore.kernel.org/r/20221123-rpi-kunit-tests-v3-8-4615a663a84a@cerno.tech Signed-off-by: Maxime Ripard --- diff --git a/drivers/gpu/drm/tests/drm_kunit_helpers.c b/drivers/gpu/drm/tests/drm_kunit_helpers.c index 4bf98bd..b66ce77 100644 --- a/drivers/gpu/drm/tests/drm_kunit_helpers.c +++ b/drivers/gpu/drm/tests/drm_kunit_helpers.c @@ -7,6 +7,7 @@ #include #include +#include #define KUNIT_DEVICE_NAME "drm-kunit-mock-device" @@ -32,7 +33,16 @@ static const struct drm_mode_config_funcs drm_mode_config_funcs = { */ struct device *drm_kunit_helper_alloc_device(struct kunit *test) { - return root_device_register(KUNIT_DEVICE_NAME); + struct platform_device *pdev; + int ret; + + pdev = platform_device_alloc(KUNIT_DEVICE_NAME, PLATFORM_DEVID_NONE); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pdev); + + ret = platform_device_add(pdev); + KUNIT_ASSERT_EQ(test, ret, 0); + + return &pdev->dev; } EXPORT_SYMBOL_GPL(drm_kunit_helper_alloc_device); @@ -45,7 +55,9 @@ EXPORT_SYMBOL_GPL(drm_kunit_helper_alloc_device); */ void drm_kunit_helper_free_device(struct kunit *test, struct device *dev) { - root_device_unregister(dev); + struct platform_device *pdev = to_platform_device(dev); + + platform_device_unregister(pdev); } EXPORT_SYMBOL_GPL(drm_kunit_helper_free_device);