summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/tests/drm_modes_test.c
diff options
context:
space:
mode:
authorMaxime Ripard <maxime@cerno.tech>2022-12-01 16:11:38 +0100
committerMaxime Ripard <maxime@cerno.tech>2022-12-08 09:56:55 +0100
commit9ecd8045bf64f8f277acea4bf35c14b369529f09 (patch)
treec3ce41a4a03d5593a1fb09dbdbf5189c2492308c /drivers/gpu/drm/tests/drm_modes_test.c
parent1d041a469e5de3d9d1b208e12af9265882dcd221 (diff)
drm/tests: helpers: Create the device in another function
We'll need in some tests to control when the device needs to be added and removed, so let's split the device creation from the DRM device creation function. Reviewed-by: MaĆ­ra Canal <mcanal@igalia.com> Link: https://lore.kernel.org/r/20221123-rpi-kunit-tests-v3-7-4615a663a84a@cerno.tech Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Diffstat (limited to 'drivers/gpu/drm/tests/drm_modes_test.c')
-rw-r--r--drivers/gpu/drm/tests/drm_modes_test.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/gpu/drm/tests/drm_modes_test.c b/drivers/gpu/drm/tests/drm_modes_test.c
index 35965ad86188..d1e9f3c0433a 100644
--- a/drivers/gpu/drm/tests/drm_modes_test.c
+++ b/drivers/gpu/drm/tests/drm_modes_test.c
@@ -13,6 +13,7 @@
struct drm_test_modes_priv {
struct drm_device *drm;
+ struct device *dev;
};
static int drm_test_modes_init(struct kunit *test)
@@ -22,7 +23,11 @@ static int drm_test_modes_init(struct kunit *test)
priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, priv);
- priv->drm = drm_kunit_helper_alloc_drm_device(test, DRIVER_MODESET);
+ priv->dev = drm_kunit_helper_alloc_device(test);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->dev);
+
+ priv->drm = drm_kunit_helper_alloc_drm_device(test, priv->dev,
+ DRIVER_MODESET);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->drm);
test->priv = priv;
@@ -30,6 +35,13 @@ static int drm_test_modes_init(struct kunit *test)
return 0;
}
+static void drm_test_modes_exit(struct kunit *test)
+{
+ struct drm_test_modes_priv *priv = test->priv;
+
+ drm_kunit_helper_free_device(test, priv->dev);
+}
+
static void drm_test_modes_analog_tv_ntsc_480i(struct kunit *test)
{
struct drm_test_modes_priv *priv = test->priv;
@@ -135,6 +147,7 @@ static struct kunit_case drm_modes_analog_tv_tests[] = {
static struct kunit_suite drm_modes_analog_tv_test_suite = {
.name = "drm_modes_analog_tv",
.init = drm_test_modes_init,
+ .exit = drm_test_modes_exit,
.test_cases = drm_modes_analog_tv_tests,
};