[igt-dev] [PATCH i-g-t] lib/sysfs: Repair override of params = -1

Chris Wilson chris at chris-wilson.co.uk
Thu Jan 10 15:36:22 UTC 2019


Commit e27626898b87 ("igt: Check the physical swizzle status") stopped
trying to chase the parameters from the device sysfs, entirely by
accident. Make it a tiny bit more robust by forgiving the sysfs device
not being present and jumping to the /sys/module + driver name param
lookup fallback.

Reported-by: Jani Nikula <jani.nikula at intel.com>
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Jani Nikula <jani.nikula at intel.com>
---
 lib/igt_sysfs.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index d323b81dd..cce342a05 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -189,7 +189,7 @@ bool igt_sysfs_set_parameter(int device,
 
 /**
  * igt_sysfs_open_parameters:
- * @device: fd of the device (or -1 to default to Intel)
+ * @device: fd of the device
  *
  * This opens the module parameters directory (under sysfs) corresponding
  * to the device for use with igt_sysfs_set() and igt_sysfs_get().
@@ -199,15 +199,15 @@ bool igt_sysfs_set_parameter(int device,
  */
 int igt_sysfs_open_parameters(int device)
 {
-	int dir, params;
+	int dir, params = -1;
 
 	dir = igt_sysfs_open(device, &params);
-	if (dir < 0)
-		return -1;
-
-	params = -1;
-	//params = openat(dir, "device/driver/module/parameters", O_RDONLY);
-	close(dir);
+	if (dir >= 0) {
+		params = openat(dir,
+				"device/driver/module/parameters",
+				O_RDONLY);
+		close(dir);
+	}
 
 	if (params < 0) { /* builtin? */
 		drm_version_t version;
-- 
2.20.1



More information about the igt-dev mailing list