All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib: add module unload support to sort tests
@ 2017-12-17  9:49 Pravin Shedge
  2017-12-18 22:21 ` Andrew Morton
  2017-12-22 18:25 ` [PATCH v2] " Pravin Shedge
  0 siblings, 2 replies; 8+ messages in thread
From: Pravin Shedge @ 2017-12-17  9:49 UTC (permalink / raw)
  To: akpm, fkostenzer, andriy.shevchenko, geert, paul.gortmaker, linux-kernel
  Cc: pravin.shedge4linux

test_sort.c perform array-based and linked list sort test. Code allows to
compile either as a loadable modules or builtin into the kernel.

Current code is not allow to unload the test_sort.ko module after
successful completion.

This patch add support to unload the "test_sort.ko" module.

Signed-off-by: Pravin Shedge <pravin.shedge4linux@gmail.com>
---
 lib/test_sort.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/test_sort.c b/lib/test_sort.c
index d389c1c..26c98d0 100644
--- a/lib/test_sort.c
+++ b/lib/test_sort.c
@@ -13,11 +13,12 @@ static int __init cmpint(const void *a, const void *b)
 
 static int __init test_sort_init(void)
 {
-	int *a, i, r = 1, err = -ENOMEM;
+	int *a, i, r = 1;
+	int err = -EAGAIN; /* Fail will directly unload the module */
 
 	a = kmalloc_array(TEST_LEN, sizeof(*a), GFP_KERNEL);
 	if (!a)
-		return err;
+		return -ENOMEM;
 
 	for (i = 0; i < TEST_LEN; i++) {
 		r = (r * 725861) % 6599;
@@ -26,13 +27,12 @@ static int __init test_sort_init(void)
 
 	sort(a, TEST_LEN, sizeof(*a), cmpint, NULL);
 
-	err = -EINVAL;
 	for (i = 0; i < TEST_LEN-1; i++)
 		if (a[i] > a[i+1]) {
 			pr_err("test has failed\n");
+			err = -EINVAL;
 			goto exit;
 		}
-	err = 0;
 	pr_info("test passed\n");
 exit:
 	kfree(a);
-- 
2.7.4

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

end of thread, other threads:[~2017-12-22 18:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-17  9:49 [PATCH] lib: add module unload support to sort tests Pravin Shedge
2017-12-18 22:21 ` Andrew Morton
2017-12-19 17:40   ` Pravin Shedge
2017-12-19 22:51     ` Andrew Morton
2017-12-19 23:06       ` Randy Dunlap
2017-12-20  4:13     ` Paul Gortmaker
2017-12-21  2:05       ` Pravin Shedge
2017-12-22 18:25 ` [PATCH v2] " Pravin Shedge

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.