diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2017-11-20 15:58:59 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2017-11-21 11:57:49 +0000 |
commit | 538091ce7008b4281d912422d8bb676c541401a4 (patch) | |
tree | 406fa375e51a17d2d87500cd6c5aa8a2ee230abf /lib/igt_debugfs.c | |
parent | 9fb5344bab2540e3d12a7d3a94c2a3801a6fec36 (diff) |
tools: Stop opening the driver just to find the debugfs
Since the tools want to work without the module loaded, remove the
assumption that we want to load the driver to find debugfs.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Ville Syrjala <ville.syrjala@linux.intel.com>
Diffstat (limited to 'lib/igt_debugfs.c')
-rw-r--r-- | lib/igt_debugfs.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c index 40cfd87a..5670099f 100644 --- a/lib/igt_debugfs.c +++ b/lib/igt_debugfs.c @@ -150,19 +150,22 @@ char *igt_debugfs_path(int device, char *path, int pathlen) const char *debugfs_root; int idx; - if (fstat(device, &st)) { - igt_debug("Couldn't stat FD for DRM device: %s\n", strerror(errno)); - return NULL; - } - - if (!S_ISCHR(st.st_mode)) { - igt_debug("FD for DRM device not a char device!\n"); - return NULL; - } - debugfs_root = igt_debugfs_mount(); igt_assert(debugfs_root); + memset(&st, 0, sizeof(st)); + if (device != -1) { /* if no fd, we presume we want dri/0 */ + if (fstat(device, &st)) { + igt_debug("Couldn't stat FD for DRM device: %m\n"); + return NULL; + } + + if (!S_ISCHR(st.st_mode)) { + igt_debug("FD for DRM device not a char device!\n"); + return NULL; + } + } + idx = minor(st.st_rdev); snprintf(path, pathlen, "%s/dri/%d/name", debugfs_root, idx); if (stat(path, &st)) |