Skip to contentSkip to conversation

drm/test: use kunit action wrapper macro in the gem shmem test suite

PATCH Applied Marco Pagani 2 participants 2 messages Jul 23, 2024 – Jul 25, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/test: use kunit action wrapper macro in the gem shmem test suite

Replace deferred action function wrappers with equivalent ones defined using the macro introduced by commit 56778b49c9a2 ("kunit: Add a macro to wrap a deferred action function")

---
 drivers/gpu/drm/tests/drm_gem_shmem_test.c | 27 ++++++----------------
 1 file changed, 7 insertions(+), 20 deletions(-)
drivers/gpu/drm/tests/drm_gem_shmem_test.c +7 -20
index c3758faa1b83..f7f7d8b0f61f 100644
@@ -23,29 +23,16 @@
 #define TEST_BYTE		0xae
 
 /*
- * Wrappers to avoid an explicit type casting when passing action
- * functions to kunit_add_action().
+ * Wrappers to avoid cast warnings when passing action functions
+ * directly to kunit_add_action().
  */
-static void kfree_wrapper(void *ptr)
-{
-	const void *obj = ptr;
-
-	kfree(obj);
-}
-
-static void sg_free_table_wrapper(void *ptr)
-{
-	struct sg_table *sgt = ptr;
+KUNIT_DEFINE_ACTION_WRAPPER(kfree_wrapper, kfree, const void *);
 
-	sg_free_table(sgt);
-}
-
-static void drm_gem_shmem_free_wrapper(void *ptr)
-{
-	struct drm_gem_shmem_object *shmem = ptr;
+KUNIT_DEFINE_ACTION_WRAPPER(sg_free_table_wrapper, sg_free_table,
+			    struct sg_table *);
 
-	drm_gem_shmem_free(shmem);
-}
+KUNIT_DEFINE_ACTION_WRAPPER(drm_gem_shmem_free_wrapper, drm_gem_shmem_free,
+			    struct drm_gem_shmem_object *);
 
 /*
  * Test creating a shmem GEM object backed by shmem buffer. The test
Signature · 1 line
2.45.2
#1 lore raw
Quoted 5 lines · Marco Pagani

Replace deferred action function wrappers with equivalent ones defined using the macro introduced by commit 56778b49c9a2 ("kunit: Add a macro to wrap a deferred action function")

Merged to drm-misc-next, thanks for your patch.
-Sima

Quoted 48 lines
---
 drivers/gpu/drm/tests/drm_gem_shmem_test.c | 27 ++++++----------------
 1 file changed, 7 insertions(+), 20 deletions(-)
drivers/gpu/drm/tests/drm_gem_shmem_test.c +7 -20
index c3758faa1b83..f7f7d8b0f61f 100644
@@ -23,29 +23,16 @@
 #define TEST_BYTE		0xae
 
 /*
- * Wrappers to avoid an explicit type casting when passing action
- * functions to kunit_add_action().
+ * Wrappers to avoid cast warnings when passing action functions
+ * directly to kunit_add_action().
  */
-static void kfree_wrapper(void *ptr)
-{
-	const void *obj = ptr;
-
-	kfree(obj);
-}
-
-static void sg_free_table_wrapper(void *ptr)
-{
-	struct sg_table *sgt = ptr;
+KUNIT_DEFINE_ACTION_WRAPPER(kfree_wrapper, kfree, const void *);
 
-	sg_free_table(sgt);
-}
-
-static void drm_gem_shmem_free_wrapper(void *ptr)
-{
-	struct drm_gem_shmem_object *shmem = ptr;
+KUNIT_DEFINE_ACTION_WRAPPER(sg_free_table_wrapper, sg_free_table,
+			    struct sg_table *);
 
-	drm_gem_shmem_free(shmem);
-}
+KUNIT_DEFINE_ACTION_WRAPPER(drm_gem_shmem_free_wrapper, drm_gem_shmem_free,
+			    struct drm_gem_shmem_object *);
 
 /*
  * Test creating a shmem GEM object backed by shmem buffer. The test
Signature · 1 line
2.45.2
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch