summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/tests/drm_client_modeset_test.c
diff options
context:
space:
mode:
authorMaxime Ripard <maxime@cerno.tech>2022-12-01 18:11:38 +0300
committerMaxime Ripard <maxime@cerno.tech>2022-12-08 11:56:55 +0300
commit9ecd8045bf64f8f277acea4bf35c14b369529f09 (patch)
treec3ce41a4a03d5593a1fb09dbdbf5189c2492308c /drivers/gpu/drm/tests/drm_client_modeset_test.c
parent1d041a469e5de3d9d1b208e12af9265882dcd221 (diff)
downloadlinux-9ecd8045bf64f8f277acea4bf35c14b369529f09.tar.xz
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_client_modeset_test.c')
-rw-r--r--drivers/gpu/drm/tests/drm_client_modeset_test.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/gpu/drm/tests/drm_client_modeset_test.c b/drivers/gpu/drm/tests/drm_client_modeset_test.c
index 4d475ae6dbb6..053dbc0106d9 100644
--- a/drivers/gpu/drm/tests/drm_client_modeset_test.c
+++ b/drivers/gpu/drm/tests/drm_client_modeset_test.c
@@ -15,6 +15,7 @@
struct drm_client_modeset_test_priv {
struct drm_device *drm;
+ struct device *dev;
struct drm_connector connector;
};
@@ -59,7 +60,10 @@ static int drm_client_modeset_test_init(struct kunit *test)
test->priv = 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);
ret = drmm_connector_init(priv->drm, &priv->connector,
@@ -76,6 +80,13 @@ static int drm_client_modeset_test_init(struct kunit *test)
return 0;
}
+static void drm_client_modeset_test_exit(struct kunit *test)
+{
+ struct drm_client_modeset_test_priv *priv = test->priv;
+
+ drm_kunit_helper_free_device(test, priv->dev);
+}
+
static void drm_test_pick_cmdline_res_1920_1080_60(struct kunit *test)
{
struct drm_client_modeset_test_priv *priv = test->priv;
@@ -175,6 +186,7 @@ static struct kunit_case drm_test_pick_cmdline_tests[] = {
static struct kunit_suite drm_test_pick_cmdline_test_suite = {
.name = "drm_test_pick_cmdline",
.init = drm_client_modeset_test_init,
+ .exit = drm_client_modeset_test_exit,
.test_cases = drm_test_pick_cmdline_tests
};