xref: /kernel/linux/linux-5.10/lib/test_module.c (revision 8c2ecf20)
18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * This module emits "Hello, world" on printk when loaded.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * It is designed to be used for basic evaluation of the module loading
68c2ecf20Sopenharmony_ci * subsystem (for example when validating module signing/verification). It
78c2ecf20Sopenharmony_ci * lacks any extra dependencies, and will not normally be loaded by the
88c2ecf20Sopenharmony_ci * system unless explicitly requested by name.
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <linux/init.h>
148c2ecf20Sopenharmony_ci#include <linux/module.h>
158c2ecf20Sopenharmony_ci#include <linux/printk.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cistatic int __init test_module_init(void)
188c2ecf20Sopenharmony_ci{
198c2ecf20Sopenharmony_ci	pr_warn("Hello, world\n");
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci	return 0;
228c2ecf20Sopenharmony_ci}
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cimodule_init(test_module_init);
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cistatic void __exit test_module_exit(void)
278c2ecf20Sopenharmony_ci{
288c2ecf20Sopenharmony_ci	pr_warn("Goodbye\n");
298c2ecf20Sopenharmony_ci}
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_cimodule_exit(test_module_exit);
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ciMODULE_AUTHOR("Kees Cook <keescook@chromium.org>");
348c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
35