Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Francois Dugast <francois.dugast@intel.com>,
	Peter Senna Tschudin <peter.senna@linux.intel.com>,
	Lucas De Marchi <lucas.demarchi@intel.com>
Subject: [PATCH i-g-t 3/4] lib/igt_sysfs: Move close to be common to all actions
Date: Tue, 17 Dec 2024 21:13:23 -0800	[thread overview]
Message-ID: <20241218051324.2696557-4-lucas.demarchi@intel.com> (raw)
In-Reply-To: <20241218051324.2696557-1-lucas.demarchi@intel.com>

In all cases, close the sysfs dir (except when asserting, which is then
pointless as the test is dying), so move the close to a single place.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 lib/igt_sysfs.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 9427767b0..a1161b68b 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -1513,15 +1513,12 @@ int xe_sysfs_driver_do(int xe_device, char pci_slot[], enum xe_sysfs_driver_acti
 	switch(action) {
 	case XE_SYSFS_DRIVER_BIND:
 		igt_assert(igt_sysfs_set(sysfs, "bind", pci_slot));
-		close(sysfs);
 		break;
 	case XE_SYSFS_DRIVER_TRY_BIND:
 		igt_sysfs_set(sysfs, "bind", pci_slot);
-		close(sysfs);
 		break;
 	case XE_SYSFS_DRIVER_UNBIND:
 		igt_assert(igt_sysfs_set(sysfs, "unbind", pci_slot));
-		close(sysfs);
 		break;
 	case XE_SYSFS_DRIVER_REBIND:
 		igt_assert(igt_sysfs_set(sysfs, "unbind", pci_slot));
@@ -1533,7 +1530,6 @@ int xe_sysfs_driver_do(int xe_device, char pci_slot[], enum xe_sysfs_driver_acti
 		__drm_close_driver(xe_device);
 
 		igt_assert(igt_sysfs_set(sysfs, "bind", pci_slot));
-		close(sysfs);
 
 		/* Renew the client connection */
 		xe_device = drm_open_driver(DRIVER_XE);
@@ -1544,6 +1540,8 @@ int xe_sysfs_driver_do(int xe_device, char pci_slot[], enum xe_sysfs_driver_acti
 		igt_assert(!"missing");
 	}
 
+	close(sysfs);
+
 	return xe_device;
 }
 
-- 
2.47.0


  parent reply	other threads:[~2024-12-18  5:14 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-18  5:13 [PATCH i-g-t 0/4] Device scan fixes Lucas De Marchi
2024-12-18  5:13 ` [PATCH i-g-t 1/4] lib/drmtest: Fix drm_close_driver() Lucas De Marchi
2024-12-18  5:13 ` [PATCH i-g-t 2/4] lib/igt_sysfs: Fix close when rebinding Lucas De Marchi
2024-12-18  5:13 ` Lucas De Marchi [this message]
2024-12-18  5:13 ` [PATCH i-g-t 4/4] lib/igt_device_scan: Fix scan vs bind/unbind/reload Lucas De Marchi
2024-12-18  6:07   ` Peter Senna Tschudin
2024-12-18  6:17   ` Zbigniew Kempczyński
2024-12-20 19:10     ` Lucas De Marchi
2024-12-18  6:34   ` Zbigniew Kempczyński
2024-12-19 16:35     ` Lucas De Marchi
2024-12-20  6:59       ` Zbigniew Kempczyński
2024-12-20 18:52         ` Lucas De Marchi
2024-12-18  8:20   ` Kamil Konieczny
2024-12-18  8:16 ` [PATCH i-g-t 0/4] Device scan fixes Peter Senna Tschudin
2024-12-18 22:04   ` Lucas De Marchi
2024-12-19  8:44     ` Peter Senna Tschudin
2024-12-18 20:55 ` ✓ i915.CI.BAT: success for " Patchwork
2024-12-18 23:00 ` ✓ Xe.CI.BAT: " Patchwork
2024-12-19 10:18 ` ✗ i915.CI.Full: failure " Patchwork
2024-12-19 14:13 ` ✗ Xe.CI.Full: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241218051324.2696557-4-lucas.demarchi@intel.com \
    --to=lucas.demarchi@intel.com \
    --cc=francois.dugast@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=peter.senna@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox