lib/test_bitops: Do the full test during module init
diff mbox series

Message ID 20200706095100.19157-1-geert@linux-m68k.org
State New, archived
Headers show
Series
  • lib/test_bitops: Do the full test during module init
Related show

Commit Message

Geert Uytterhoeven July 6, 2020, 9:51 a.m. UTC
Currently, the bitops test consists of two parts: one part is executed
during module load, the second part during module unload. This is
cumbersome for the user, as he has to perform two steps to execute all
tests, and is different from most (all?) other tests.

Merge the two parts, so both are executed during module load.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 lib/test_bitops.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

Comments

Andy Shevchenko July 6, 2020, 10:39 a.m. UTC | #1
On Mon, Jul 6, 2020 at 12:53 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Currently, the bitops test consists of two parts: one part is executed
> during module load, the second part during module unload. This is
> cumbersome for the user, as he has to perform two steps to execute all
> tests, and is different from most (all?) other tests.
>
> Merge the two parts, so both are executed during module load.

Does your change prevent you from unloading the module?
Geert Uytterhoeven July 6, 2020, 11:28 a.m. UTC | #2
Hi Andy,

On Mon, Jul 6, 2020 at 12:39 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Mon, Jul 6, 2020 at 12:53 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > Currently, the bitops test consists of two parts: one part is executed
> > during module load, the second part during module unload. This is
> > cumbersome for the user, as he has to perform two steps to execute all
> > tests, and is different from most (all?) other tests.
> >
> > Merge the two parts, so both are executed during module load.
>
> Does your change prevent you from unloading the module?

Good point, you need a dummy module_exit() for that.
Stay tuned for v2.

Gr{oetje,eeting}s,

                        Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Patch
diff mbox series

diff --git a/lib/test_bitops.c b/lib/test_bitops.c
index ced25e3a779baf96..810ae6bc72fac5c3 100644
--- a/lib/test_bitops.c
+++ b/lib/test_bitops.c
@@ -50,11 +50,11 @@  static unsigned long order_comb_long[][2] = {
 };
 #endif
 
-static int __init test_bitops_startup(void)
+static int __init test_bitops(void)
 {
-	int i;
+	int i, bit_set;
 
-	pr_warn("Loaded test module\n");
+	pr_info("Starting bitops test\n");
 	set_bit(BITOPS_4, g_bitmap);
 	set_bit(BITOPS_7, g_bitmap);
 	set_bit(BITOPS_11, g_bitmap);
@@ -81,12 +81,8 @@  static int __init test_bitops_startup(void)
 				       order_comb_long[i][0]);
 	}
 #endif
-	return 0;
-}
 
-static void __exit test_bitops_unstartup(void)
-{
-	int bit_set;
+	barrier();
 
 	clear_bit(BITOPS_4, g_bitmap);
 	clear_bit(BITOPS_7, g_bitmap);
@@ -98,11 +94,12 @@  static void __exit test_bitops_unstartup(void)
 	if (bit_set != BITOPS_LAST)
 		pr_err("ERROR: FOUND SET BIT %d\n", bit_set);
 
-	pr_warn("Unloaded test module\n");
+	pr_info("Completed bitops test\n");
+
+	return 0;
 }
 
-module_init(test_bitops_startup);
-module_exit(test_bitops_unstartup);
+module_init(test_bitops);
 
 MODULE_AUTHOR("Jesse Brandeburg <jesse.brandeburg@intel.com>, Wei Yang <richard.weiyang@gmail.com>");
 MODULE_LICENSE("GPL");