public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] lib/sysfs: Repair override of params = -1
@ 2019-01-10 15:36 Chris Wilson
  2019-01-10 16:01 ` Jani Nikula
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Chris Wilson @ 2019-01-10 15:36 UTC (permalink / raw)
  To: igt-dev; +Cc: Jani Nikula

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@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Jani Nikula <jani.nikula@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

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-01-10 23:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-10 15:36 [igt-dev] [PATCH i-g-t] lib/sysfs: Repair override of params = -1 Chris Wilson
2019-01-10 16:01 ` Jani Nikula
2019-01-10 16:10 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-01-10 23:27 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox