Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Anshuman Gupta <anshuman.gupta@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: petri.latvala@intel.com
Subject: [igt-dev] [PATCH i-g-t v2 1/2] lib/igt_kmod: Don't use process exit return value
Date: Mon, 21 Feb 2022 15:54:22 +0530	[thread overview]
Message-ID: <20220221102423.8089-2-anshuman.gupta@intel.com> (raw)
In-Reply-To: <20220221102423.8089-1-anshuman.gupta@intel.com>

Kmod igt library functions like igt_i915_driver_{load, unload}
uses process exit IGT_EXIT_{FAILURE, SKIP, SUCCESS} return values.
Let these function return actual return values
from returned igt_kmod_{load, unload} functions.

Suggested-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
---
 lib/igt_kmod.c | 34 +++++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index a249ea922..cf7a3b228 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -355,22 +355,26 @@ igt_kmod_list_loaded(void)
 int
 igt_i915_driver_load(const char *opts)
 {
+	int ret;
+
 	if (opts)
 		igt_info("Reloading i915 with %s\n\n", opts);
 
-	if (igt_kmod_load("i915", opts)) {
+	ret = igt_kmod_load("i915", opts);
+	if (ret) {
 		igt_warn("Could not load i915\n");
-		return IGT_EXIT_FAILURE;
+		return ret;
 	}
 
 	bind_fbcon(true);
 	igt_kmod_load("snd_hda_intel", NULL);
 
-	return IGT_EXIT_SUCCESS;
+	return 0;
 }
 
 int __igt_i915_driver_unload(const char **who)
 {
+	int ret;
 	const char *sound[] = {
 		"snd_hda_intel",
 		"snd_hdmi_lpe_audio",
@@ -390,32 +394,36 @@ int __igt_i915_driver_unload(const char **who)
 		if (igt_kmod_is_loaded(*m)) {
 			igt_terminate_process(SIGTERM, "alsactl");
 			kick_snd_hda_intel();
-			if (igt_kmod_unload(*m, 0)) {
+			ret = igt_kmod_unload(*m, 0);
+			if (ret) {
 				if (who)
 					*who = *m;
-				return IGT_EXIT_FAILURE;
+				return ret;
 			}
 		}
 	}
 
 	for (const char **m = aux; *m; m++) {
-		if (igt_kmod_is_loaded(*m))
-			if (igt_kmod_unload(*m, 0)) {
+		if (igt_kmod_is_loaded(*m)) {
+			ret = igt_kmod_unload(*m, 0);
+			if (ret) {
 				if (who)
 					*who = *m;
-				return IGT_EXIT_FAILURE;
+				return ret;
 			}
+		}
 	}
 
 	if (igt_kmod_is_loaded("i915")) {
-		if (igt_kmod_unload("i915", 0)) {
+		ret = igt_kmod_unload("i915", 0);
+		if (ret) {
 			if (who)
 				*who = "i915";
-			return IGT_EXIT_FAILURE;
+			return ret;
 		}
 	}
 
-	return IGT_EXIT_SUCCESS;
+	return 0;
 }
 
 /**
@@ -447,10 +455,10 @@ igt_i915_driver_unload(void)
 
 	if (igt_kmod_is_loaded("i915")) {
 		igt_warn("i915.ko still loaded!\n");
-		return IGT_EXIT_FAILURE;
+		return -EBUSY;
 	}
 
-	return IGT_EXIT_SUCCESS;
+	return 0;
 }
 
 /**
-- 
2.26.2

  reply	other threads:[~2022-02-21 10:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-21 10:24 [igt-dev] [PATCH i-g-t v2 0/2] Avoid process exit return values in igt_kmod Anshuman Gupta
2022-02-21 10:24 ` Anshuman Gupta [this message]
2022-02-21 20:28   ` [igt-dev] [PATCH i-g-t v2 1/2] lib/igt_kmod: Don't use process exit return value Dixit, Ashutosh
2022-02-21 10:24 ` [igt-dev] [PATCH i-g-t v2 2/2] test/perf_pmu: Change module unload assertion Anshuman Gupta
2022-02-21 20:29   ` Dixit, Ashutosh
2022-02-21 14:19 ` [igt-dev] ✗ Fi.CI.BAT: failure for Avoid process exit return values in igt_kmod (rev2) Patchwork
2022-02-21 17:24   ` Anshuman Gupta
2022-02-22  3:45 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2022-02-22  5:13 ` [igt-dev] ✗ Fi.CI.IGT: failure " 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=20220221102423.8089-2-anshuman.gupta@intel.com \
    --to=anshuman.gupta@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=petri.latvala@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