[PATCH 1/5] lib/igt_debugfs: implement a singleton igt_debugfs_t instance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Allows us to remove every so little bit of boilerplate from
tests, once it's all rolled out.

Signed-off-by: Daniel Vetter <daniel.vetter@xxxxxxxx>
---
 lib/igt_debugfs.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 79b2618b4273..4a3384871717 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -121,6 +121,22 @@ void igt_debugfs_init(igt_debugfs_t *debugfs)
 	igt_assert(__igt_debugfs_init(debugfs));
 }
 
+static igt_debugfs_t *__igt_debugfs_singleton(void)
+{
+	static igt_debugfs_t singleton;
+	static bool init_done = false;
+
+	if (init_done)
+		return &singleton;
+
+	if (__igt_debugfs_init(&singleton)) {
+		init_done = true;
+		return &singleton;
+	} else {
+		return NULL;
+	}
+}
+
 /**
  * igt_debugfs_open:
  * @debugfs: debugfs access structure
-- 
1.8.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux