Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Kunal Joshi <kunal1.joshi@intel.com>
Subject: [igt-dev] [PATCH i-g-t 2/3] lib/igt_chamelium: Duplicate the caller's drm_fd
Date: Tue,  7 Jul 2020 16:18:13 +0300	[thread overview]
Message-ID: <20200707131814.17540-2-imre.deak@intel.com> (raw)
In-Reply-To: <20200707131814.17540-1-imre.deak@intel.com>

Take a copy of the caller's FD so that the Chamelium lib functions can
access the DRM file regardless of when the caller closes its own FD.

This is needed at least by the next patch.

Cc: Lyude Paul <lyude@redhat.com>
Cc: Kunal Joshi <kunal1.joshi@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 lib/igt_chamelium.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index 5924e5615..90a2d04bb 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -2485,7 +2485,7 @@ struct chamelium *chamelium_init(int drm_fd)
 	if (cleanup_instance)
 		chamelium_deinit(cleanup_instance);
 
-	chamelium->drm_fd = drm_fd;
+	chamelium->drm_fd = dup(drm_fd);
 	IGT_INIT_LIST_HEAD(&chamelium->edids);
 
 	if (!chamelium_read_port_mappings(chamelium, drm_fd))
@@ -2511,6 +2511,8 @@ struct chamelium *chamelium_init(int drm_fd)
 
 	return chamelium;
 error:
+	close(chamelium->drm_fd);
+
 	chamelium_deinit_rpc_only(chamelium);
 
 	return NULL;
@@ -2550,6 +2552,8 @@ void chamelium_deinit(struct chamelium *chamelium)
 		free(pos);
 	}
 
+	close(chamelium->drm_fd);
+
 	xmlrpc_client_destroy(chamelium->client);
 
 	for (i = 0; i < chamelium->port_count; i++)
-- 
2.23.1

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

  parent reply	other threads:[~2020-07-07 13:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07 13:18 [igt-dev] [PATCH i-g-t 1/3] lib/igt_chamelium: Sanitize the init error and deinit path Imre Deak
2020-07-07  8:19 ` Kunal Joshi
2020-07-07 13:18 ` Imre Deak [this message]
2020-07-07 13:18 ` [igt-dev] [PATCH i-g-t 3/3] lib/igt_chamelium: Wait for connectors after replugging them at exit Imre Deak
2020-07-07 13:41 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/3] lib/igt_chamelium: Sanitize the init error and deinit path Patchwork
2020-07-08 10:08   ` Imre Deak
2020-07-08 11:53     ` Vudum, Lakshminarayana
2020-07-07 16:02 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2020-07-08 10:54 ` [igt-dev] ✓ Fi.CI.IGT: success " 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=20200707131814.17540-2-imre.deak@intel.com \
    --to=imre.deak@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kunal1.joshi@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