summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/tests/drm_probe_helper_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_probe_helper_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_probe_helper_test.c')
-rw-r--r--drivers/gpu/drm/tests/drm_probe_helper_test.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/gpu/drm/tests/drm_probe_helper_test.c b/drivers/gpu/drm/tests/drm_probe_helper_test.c
index 86ea988e14be..bfca61c6099d 100644
--- a/drivers/gpu/drm/tests/drm_probe_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_probe_helper_test.c
@@ -17,6 +17,7 @@
struct drm_probe_helper_test_priv {
struct drm_device *drm;
+ struct device *dev;
struct drm_connector connector;
};
@@ -39,7 +40,10 @@ static int drm_probe_helper_test_init(struct kunit *test)
KUNIT_ASSERT_NOT_NULL(test, priv);
test->priv = priv;
- priv->drm = drm_kunit_helper_alloc_drm_device(test,
+ 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 | DRIVER_ATOMIC);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->drm);
@@ -55,6 +59,13 @@ static int drm_probe_helper_test_init(struct kunit *test)
return 0;
}
+static void drm_probe_helper_test_exit(struct kunit *test)
+{
+ struct drm_probe_helper_test_priv *priv = test->priv;
+
+ drm_kunit_helper_free_device(test, priv->dev);
+}
+
typedef struct drm_display_mode *(*expected_mode_func_t)(struct drm_device *);
struct drm_connector_helper_tv_get_modes_test {
@@ -196,6 +207,7 @@ static struct kunit_case drm_test_connector_helper_tv_get_modes_tests[] = {
static struct kunit_suite drm_test_connector_helper_tv_get_modes_suite = {
.name = "drm_connector_helper_tv_get_modes",
.init = drm_probe_helper_test_init,
+ .exit = drm_probe_helper_test_exit,
.test_cases = drm_test_connector_helper_tv_get_modes_tests,
};