drm-shim: Replace usage of mtx_t with simple_mtx_t in drm_shim.c
authorYonggang Luo <luoyonggang@gmail.com>
Wed, 9 Nov 2022 06:18:37 +0000 (14:18 +0800)
committerMarge Bot <emma+marge@anholt.net>
Wed, 31 May 2023 15:44:50 +0000 (15:44 +0000)
This is a prepare for removing _MTX_INITIALIZER_NP.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: David Heidelberg <david.heidelberg@collabora.com>
Acked-by: Eric Engestrom <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21284>

src/drm-shim/drm_shim.c

index a048735..f7481aa 100644 (file)
 
 #include "util/anon_file.h"
 #include "util/set.h"
+#include "util/simple_mtx.h"
 #include "util/u_debug.h"
 #include "drm_shim.h"
 
 #define REAL_FUNCTION_POINTER(x) __typeof__(x) *real_##x
 
-static mtx_t shim_lock = _MTX_INITIALIZER_NP;
+static simple_mtx_t shim_lock = SIMPLE_MTX_INITIALIZER;
 struct set *opendir_set;
 bool drm_shim_debug;
 
@@ -608,9 +609,9 @@ opendir(const char *name)
          dir = fake_dev_dri;
       }
 
-      mtx_lock(&shim_lock);
+      simple_mtx_lock(&shim_lock);
       _mesa_set_add(opendir_set, dir);
-      mtx_unlock(&shim_lock);
+      simple_mtx_unlock(&shim_lock);
    }
 
    return dir;
@@ -628,7 +629,7 @@ readdir(DIR *dir)
 
    static struct dirent render_node_dirent = { 0 };
 
-   mtx_lock(&shim_lock);
+   simple_mtx_lock(&shim_lock);
    if (_mesa_set_search(opendir_set, dir)) {
       strcpy(render_node_dirent.d_name,
              render_node_dirent_name);
@@ -636,7 +637,7 @@ readdir(DIR *dir)
       ent = &render_node_dirent;
       _mesa_set_remove_key(opendir_set, dir);
    }
-   mtx_unlock(&shim_lock);
+   simple_mtx_unlock(&shim_lock);
 
    if (!ent && dir != fake_dev_dri)
       ent = real_readdir(dir);
@@ -656,7 +657,7 @@ readdir64(DIR *dir)
 
    static struct dirent64 render_node_dirent = { 0 };
 
-   mtx_lock(&shim_lock);
+   simple_mtx_lock(&shim_lock);
    if (_mesa_set_search(opendir_set, dir)) {
       strcpy(render_node_dirent.d_name,
              render_node_dirent_name);
@@ -664,7 +665,7 @@ readdir64(DIR *dir)
       ent = &render_node_dirent;
       _mesa_set_remove_key(opendir_set, dir);
    }
-   mtx_unlock(&shim_lock);
+   simple_mtx_unlock(&shim_lock);
 
    if (!ent && dir != fake_dev_dri)
       ent = real_readdir64(dir);
@@ -678,9 +679,9 @@ closedir(DIR *dir)
 {
    init_shim();
 
-   mtx_lock(&shim_lock);
+   simple_mtx_lock(&shim_lock);
    _mesa_set_remove_key(opendir_set, dir);
-   mtx_unlock(&shim_lock);
+   simple_mtx_unlock(&shim_lock);
 
    if (dir != fake_dev_dri)
       return real_closedir(dir);