summaryrefslogtreecommitdiff
path: root/lib/igt_sysfs.c
diff options
context:
space:
mode:
authorJani Nikula <jani.nikula@intel.com>2019-01-11 10:48:46 +0200
committerJani Nikula <jani.nikula@intel.com>2019-01-14 11:25:19 +0200
commit71cea1269599f18b6f9a20da1e88f64dcf6e556c (patch)
treeb66c046c548f58c391a1147a4087013560523a28 /lib/igt_sysfs.c
parentfde4dce431bf324939a982017169214e0fa00d4f (diff)
igt/sysfs: drop support for passing -1 fd for Intel
The rabbit hole goes deep in this case, but I couldn't find any place where we'd still rely on -1 for Intel. Drop the remaining support to prevent anyone adding new code using this. Cc: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Diffstat (limited to 'lib/igt_sysfs.c')
-rw-r--r--lib/igt_sysfs.c50
1 files changed, 23 insertions, 27 deletions
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index cce342a0..c57e4ae2 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -86,7 +86,7 @@ static int writeN(int fd, const char *buf, int len)
/**
* igt_sysfs_path:
- * @device: fd of the device (or -1 to default to Intel)
+ * @device: fd of the device
* @path: buffer to fill with the sysfs path to the device
* @pathlen: length of @path buffer
* @idx: optional pointer to store the card index of the opened device
@@ -100,33 +100,29 @@ 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)
+ return NULL;
+
+ if (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 len, ret, maj, min;
+ FILE *file;
+
+ len = snprintf(path, pathlen, "/sys/class/drm/card%d", n);
+
+ 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)
@@ -139,7 +135,7 @@ char *igt_sysfs_path(int device, char *path, int pathlen, int *idx)
/**
* igt_sysfs_open:
- * @device: fd of the device (or -1 to default to Intel)
+ * @device: fd of the device
* @idx: optional pointer to store the card index of the opened device
*
* This opens the sysfs directory corresponding to device for use
@@ -160,7 +156,7 @@ int igt_sysfs_open(int device, int *idx)
/**
* igt_sysfs_set_parameters:
- * @device: fd of the device (or -1 to default to Intel)
+ * @device: fd of the device
* @parameter: the name of the parameter to set
* @fmt: printf-esque format string
*