[PATCH 3/5] lib/igt_debugfs: Remove debugfs from igt_debugfs_fopen

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

 



Also add a missing igt_assert to kms_fbc_crc and again add the missing
Returns: section to the api doc.

Signed-off-by: Daniel Vetter <daniel.vetter@xxxxxxxx>
---
 lib/igt_debugfs.c          | 13 ++++++++++---
 lib/igt_debugfs.h          |  2 +-
 tests/kms_fbc_crc.c        |  6 ++++--
 tests/kms_pipe_crc_basic.c |  2 +-
 4 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 2f9c7b117aa5..16d4ffcf4b10 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -161,18 +161,25 @@ int igt_debugfs_open(const char *filename, int mode)
 
 /**
  * igt_debugfs_fopen:
- * @debugfs: debugfs access structure
  * @filename: name of the debugfs node to open
  * @mode: mode string as used by fopen()
  *
  * This opens a debugfs file as a libc FILE. The filename should be
  * relative to the drm device's root, i.e without "drm/&lt;minor&gt;".
+ *
+ * Returns:
+ * The libc FILE pointer for the debugfs file or NULL if that didn't work out.
  */
-FILE *igt_debugfs_fopen(igt_debugfs_t *debugfs, const char *filename,
+FILE *igt_debugfs_fopen(const char *filename,
 			const char *mode)
 {
 	char buf[1024];
 
+	igt_debugfs_t *debugfs = __igt_debugfs_singleton();
+
+	if (!debugfs)
+		return NULL;
+
 	sprintf(buf, "%s/%s", debugfs->dri_path, filename);
 	return fopen(buf, mode);
 }
@@ -333,7 +340,7 @@ void igt_pipe_crc_check(igt_debugfs_t *debugfs)
 	size_t written;
 	int ret;
 
-	ctl = igt_debugfs_fopen(debugfs, "i915_display_crc_ctl", "r+");
+	ctl = igt_debugfs_fopen("i915_display_crc_ctl", "r+");
 	igt_require_f(ctl,
 		      "No display_crc_ctl found, kernel too old\n");
 	written = fwrite(cmd, 1, strlen(cmd), ctl);
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index 690f3dcaec41..6e9cec2b5018 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -43,7 +43,7 @@ typedef struct {
 
 void igt_debugfs_init(igt_debugfs_t *debugfs);
 int igt_debugfs_open(const char *filename, int mode);
-FILE *igt_debugfs_fopen(igt_debugfs_t *debugfs, const char *filename,
+FILE *igt_debugfs_fopen(const char *filename,
 			const char *mode);
 
 /*
diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c
index edcba7a28670..fce3863dc9d7 100644
--- a/tests/kms_fbc_crc.c
+++ b/tests/kms_fbc_crc.c
@@ -239,7 +239,9 @@ static bool fbc_enabled(data_t *data)
 	FILE *status;
 	char str[64] = {};
 
-	status = igt_debugfs_fopen(&data->debugfs, "i915_fbc_status", "r");
+	status = igt_debugfs_fopen("i915_fbc_status", "r");
+	igt_assert(status);
+
 	fread(str, sizeof(str) - 1, 1, status);
 	fclose(status);
 	return strstr(str, "FBC enabled") != NULL;
@@ -494,7 +496,7 @@ igt_main
 		igt_debugfs_init(&data.debugfs);
 		igt_pipe_crc_check(&data.debugfs);
 
-		status = igt_debugfs_fopen(&data.debugfs, "i915_fbc_status", "r");
+		status = igt_debugfs_fopen("i915_fbc_status", "r");
 		igt_require_f(status, "No i915_fbc_status found\n");
 		fread(buf, sizeof(buf), 1, status);
 		fclose(status);
diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c
index 9aa342757793..da5597368f29 100644
--- a/tests/kms_pipe_crc_basic.c
+++ b/tests/kms_pipe_crc_basic.c
@@ -43,7 +43,7 @@ static void test_bad_command(data_t *data, const char *cmd)
 	FILE *ctl;
 	size_t written;
 
-	ctl = igt_debugfs_fopen(&data->debugfs, "i915_display_crc_ctl", "r+");
+	ctl = igt_debugfs_fopen("i915_display_crc_ctl", "r+");
 	written = fwrite(cmd, 1, strlen(cmd), ctl);
 	fflush(ctl);
 	igt_assert_cmpint(written, ==, (strlen(cmd)));
-- 
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