[Intel-gfx] [PATCH i-g-t 1/3] lib/igt_sysfs: Remove support for finding sysfs path with no device opened

Tvrtko Ursulin tursulin at ursulin.net
Tue Nov 28 18:09:55 UTC 2017


From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

It looks like no callers actually use this so remove it to simplify.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
 lib/igt_sysfs.c | 39 ++++++++++++++++-----------------------
 1 file changed, 16 insertions(+), 23 deletions(-)

diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index e7c67dae3a13..dd057dc04947 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -102,33 +102,26 @@ char *igt_sysfs_path(int device, char *path, int pathlen, int *idx)
 {
 	struct stat st;
 
-	if (device != -1 && (fstat(device, &st) || !S_ISCHR(st.st_mode)))
+	if (device < 0 || fstat(device, &st) || !S_ISCHR(st.st_mode))
 		return NULL;
 
 	for (int n = 0; n < 16; n++) {
 		int len = snprintf(path, pathlen, "/sys/class/drm/card%d", n);
-		if (device != -1) {
-			FILE *file;
-			int ret, maj, min;
-
-			sprintf(path + len, "/dev");
-			file = fopen(path, "r");
-			if (!file)
-				continue;
-
-			ret = fscanf(file, "%d:%d", &maj, &min);
-			fclose(file);
-
-			if (ret != 2 ||
-			    major(st.st_rdev) != maj ||
-			    minor(st.st_rdev) != min)
-				continue;
-		} else {
-			/* Bleh. Search for intel */
-			sprintf(path + len, "/error");
-			if (stat(path, &st))
-				continue;
-		}
+		int ret, maj, min;
+		FILE *file;
+
+		sprintf(path + len, "/dev");
+		file = fopen(path, "r");
+		if (!file)
+			continue;
+
+		ret = fscanf(file, "%d:%d", &maj, &min);
+		fclose(file);
+
+		if (ret != 2 ||
+			major(st.st_rdev) != maj ||
+			minor(st.st_rdev) != min)
+			continue;
 
 		path[len] = '\0';
 		if (idx)
-- 
2.14.1



More information about the Intel-gfx mailing list