summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/igt_debugfs.c35
-rw-r--r--lib/igt_debugfs.h1
-rw-r--r--lib/igt_kms.c25
3 files changed, 18 insertions, 43 deletions
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index bd9ea3f0..d64694c7 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -222,34 +222,6 @@ int igt_debugfs_open(int device, const char *filename, int mode)
}
/**
- * igt_debugfs_fopen:
- * @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/<minor>".
- *
- * Returns:
- * The libc FILE pointer for the debugfs file or NULL if that didn't work out.
- */
-FILE *igt_debugfs_fopen(int device,
- const char *filename,
- const char *mode)
-{
- FILE *file;
- int fd;
-
- fd = igt_debugfs_open(device, filename, O_RDWR);
- if (fd < 0)
- return NULL;
-
- file = fdopen(fd, mode);
- close(fd);
-
- return file;
-}
-
-/**
* __igt_debugfs_read:
* @filename: file name
* @buf: buffer where the contents will be stored, allocated by the caller
@@ -281,14 +253,16 @@ void __igt_debugfs_read(int fd, const char *filename, char *buf, int buf_size)
*
* Returns: True if the @substring is found to occur in @filename
*/
-bool igt_debugfs_search(int fd, const char *filename, const char *substring)
+bool igt_debugfs_search(int device, const char *filename, const char *substring)
{
FILE *file;
size_t n = 0;
char *line = NULL;
bool matched = false;
+ int fd;
- file = igt_debugfs_fopen(fd, filename, "r");
+ fd = igt_debugfs_open(device, filename, O_RDONLY);
+ file = fdopen(fd, "r");
igt_assert(file);
while (getline(&line, &n, file) >= 0) {
@@ -299,6 +273,7 @@ bool igt_debugfs_search(int fd, const char *filename, const char *substring)
free(line);
fclose(file);
+ close(fd);
return matched;
}
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index cdad562d..7b846a83 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -36,7 +36,6 @@ const char *igt_debugfs_mount(void);
int igt_debugfs_dir(int device);
int igt_debugfs_open(int fd, const char *filename, int mode);
-FILE *igt_debugfs_fopen(int fd, const char *filename, const char *mode);
void __igt_debugfs_read(int fd, const char *filename, char *buf, int buf_size);
bool igt_debugfs_search(int fd, const char *filename, const char *substring);
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index d9f96725..5811414f 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1324,34 +1324,34 @@ static void parse_crtc(char *info, struct kmstest_crtc *crtc)
igt_assert_eq(ret, 2);
}
-void kmstest_get_crtc(int fd, enum pipe pipe, struct kmstest_crtc *crtc)
+void kmstest_get_crtc(int device, enum pipe pipe, struct kmstest_crtc *crtc)
{
char tmp[256];
- FILE *fid;
- const char *mode = "r";
+ FILE *file;
int ncrtc;
int line;
long int n;
+ int fd;
- fid = igt_debugfs_fopen(fd, "i915_display_info", mode);
-
- igt_skip_on(fid == NULL);
+ fd = igt_debugfs_open(device, "i915_display_info", O_RDONLY);
+ file = fdopen(fd, "r");
+ igt_skip_on(file == NULL);
ncrtc = 0;
line = 0;
- while (fgets(tmp, 256, fid) != NULL) {
+ while (fgets(tmp, 256, file) != NULL) {
if ((strstr(tmp, "CRTC") != NULL) && (line > 0)) {
if (strstr(tmp, "active=yes") != NULL) {
crtc->active = true;
parse_crtc(tmp, crtc);
- n = ftell(fid);
- crtc->n_planes = parse_planes(fid, NULL);
+ n = ftell(file);
+ crtc->n_planes = parse_planes(file, NULL);
crtc->planes = calloc(crtc->n_planes, sizeof(*crtc->planes));
igt_assert_f(crtc->planes, "Failed to allocate memory for %d planes\n", crtc->n_planes);
- fseek(fid, n, SEEK_SET);
- parse_planes(fid, crtc->planes);
+ fseek(file, n, SEEK_SET);
+ parse_planes(file, crtc->planes);
if (crtc->pipe != pipe) {
free(crtc->planes);
@@ -1365,7 +1365,8 @@ void kmstest_get_crtc(int fd, enum pipe pipe, struct kmstest_crtc *crtc)
line++;
}
- fclose(fid);
+ fclose(file);
+ close(fd);
igt_skip_on(ncrtc == 0);
}