From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752180AbdLQJtt (ORCPT ); Sun, 17 Dec 2017 04:49:49 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:35251 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751005AbdLQJto (ORCPT ); Sun, 17 Dec 2017 04:49:44 -0500 X-Google-Smtp-Source: ACJfBounWXEP2rzu/nJntyl2rUPBI0ej+EsCQ/ay+s/59V4uy5fgJLHA6GeF68qo0GhFC1QVb8h/eA== From: Pravin Shedge To: akpm@linux-foundation.org, fkostenzer@live.at, andriy.shevchenko@linux.intel.com, geert@linux-m68k.org, paul.gortmaker@windriver.com, linux-kernel@vger.kernel.org Cc: pravin.shedge4linux@gmail.com Subject: [PATCH] lib: add module unload support to sort tests Date: Sun, 17 Dec 2017 15:19:27 +0530 Message-Id: <1513504167-4118-1-git-send-email-pravin.shedge4linux@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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