1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2020 Intel Corporation
6 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
8 #include <linux/init.h>
9 #include <linux/module.h>
10 #include <linux/printk.h>
12 /* a tiny module only meant to test set/clear_bit */
14 /* use an enum because thats the most common BITMAP usage */
25 static DECLARE_BITMAP(g_bitmap, BITOPS_LENGTH);
27 static int __init test_bitops_startup(void)
29 pr_warn("Loaded test module\n");
30 set_bit(BITOPS_4, g_bitmap);
31 set_bit(BITOPS_7, g_bitmap);
32 set_bit(BITOPS_11, g_bitmap);
33 set_bit(BITOPS_31, g_bitmap);
34 set_bit(BITOPS_88, g_bitmap);
38 static void __exit test_bitops_unstartup(void)
42 clear_bit(BITOPS_4, g_bitmap);
43 clear_bit(BITOPS_7, g_bitmap);
44 clear_bit(BITOPS_11, g_bitmap);
45 clear_bit(BITOPS_31, g_bitmap);
46 clear_bit(BITOPS_88, g_bitmap);
48 bit_set = find_first_bit(g_bitmap, BITOPS_LAST);
49 if (bit_set != BITOPS_LAST)
50 pr_err("ERROR: FOUND SET BIT %d\n", bit_set);
52 pr_warn("Unloaded test module\n");
55 module_init(test_bitops_startup);
56 module_exit(test_bitops_unstartup);
58 MODULE_AUTHOR("Jesse Brandeburg <jesse.brandeburg@intel.com>");
59 MODULE_LICENSE("GPL");
60 MODULE_DESCRIPTION("Bit testing module");