From befbaf085b5bbebf37a58d4a118b85b8f65ddaef Mon Sep 17 00:00:00 2001 From: Chih-En Lin Date: Wed, 5 Jul 2023 09:44:21 +0800 Subject: [PATCH] examples: Add missing __init/__exit (#209) Close #207 --- examples/completions.c | 4 ++-- examples/cryptosha256.c | 4 ++-- examples/cryptosk.c | 4 ++-- examples/devicemodel.c | 4 ++-- examples/example_atomic.c | 4 ++-- examples/example_mutex.c | 4 ++-- examples/example_rwlock.c | 4 ++-- examples/example_spinlock.c | 4 ++-- examples/example_tasklet.c | 4 ++-- examples/ioctl.c | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/examples/completions.c b/examples/completions.c index 23c7f2b..9fd229c 100644 --- a/examples/completions.c +++ b/examples/completions.c @@ -40,7 +40,7 @@ static int machine_flywheel_spinup_thread(void *arg) #endif } -static int completions_init(void) +static int __init completions_init(void) { struct task_struct *crank_thread; struct task_struct *flywheel_thread; @@ -71,7 +71,7 @@ ERROR_THREAD_1: return -1; } -static void completions_exit(void) +static void __exit completions_exit(void) { wait_for_completion(&machine.crank_comp); wait_for_completion(&machine.flywheel_comp); diff --git a/examples/cryptosha256.c b/examples/cryptosha256.c index 029659b..300069b 100644 --- a/examples/cryptosha256.c +++ b/examples/cryptosha256.c @@ -18,7 +18,7 @@ static void show_hash_result(char *plaintext, char *hash_sha256) pr_info("%s\n", str); } -static int cryptosha256_init(void) +static int __init cryptosha256_init(void) { char *plaintext = "This is a test"; char hash_sha256[SHA256_LENGTH]; @@ -57,7 +57,7 @@ static int cryptosha256_init(void) return 0; } -static void cryptosha256_exit(void) +static void __exit cryptosha256_exit(void) { } diff --git a/examples/cryptosk.c b/examples/cryptosk.c index ece6a03..7d4799a 100644 --- a/examples/cryptosk.c +++ b/examples/cryptosk.c @@ -171,7 +171,7 @@ out: return ret; } -static int cryptoapi_init(void) +static int __init cryptoapi_init(void) { /* The world's favorite password */ char *password = "password123"; @@ -186,7 +186,7 @@ static int cryptoapi_init(void) return 0; } -static void cryptoapi_exit(void) +static void __exit cryptoapi_exit(void) { test_skcipher_finish(&sk); } diff --git a/examples/devicemodel.c b/examples/devicemodel.c index 6fe923e..c2c6620 100644 --- a/examples/devicemodel.c +++ b/examples/devicemodel.c @@ -69,7 +69,7 @@ static struct platform_driver devicemodel_driver = { .remove = devicemodel_remove, }; -static int devicemodel_init(void) +static int __init devicemodel_init(void) { int ret; @@ -85,7 +85,7 @@ static int devicemodel_init(void) return 0; } -static void devicemodel_exit(void) +static void __exit devicemodel_exit(void) { pr_info("devicemodel exit\n"); platform_driver_unregister(&devicemodel_driver); diff --git a/examples/example_atomic.c b/examples/example_atomic.c index 7ae8fb8..81bdcdb 100644 --- a/examples/example_atomic.c +++ b/examples/example_atomic.c @@ -53,7 +53,7 @@ static void atomic_bitwise(void) pr_info("Bits 5: " BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(word)); } -static int example_atomic_init(void) +static int __init example_atomic_init(void) { pr_info("example_atomic started\n"); @@ -63,7 +63,7 @@ static int example_atomic_init(void) return 0; } -static void example_atomic_exit(void) +static void __exit example_atomic_exit(void) { pr_info("example_atomic exit\n"); } diff --git a/examples/example_mutex.c b/examples/example_mutex.c index 6baf61f..de98bc8 100644 --- a/examples/example_mutex.c +++ b/examples/example_mutex.c @@ -7,7 +7,7 @@ static DEFINE_MUTEX(mymutex); -static int example_mutex_init(void) +static int __init example_mutex_init(void) { int ret; @@ -28,7 +28,7 @@ static int example_mutex_init(void) return 0; } -static void example_mutex_exit(void) +static void __exit example_mutex_exit(void) { pr_info("example_mutex exit\n"); } diff --git a/examples/example_rwlock.c b/examples/example_rwlock.c index 3bdcb14..121d79e 100644 --- a/examples/example_rwlock.c +++ b/examples/example_rwlock.c @@ -33,7 +33,7 @@ static void example_write_lock(void) pr_info("Write Unlocked\n"); } -static int example_rwlock_init(void) +static int __init example_rwlock_init(void) { pr_info("example_rwlock started\n"); @@ -43,7 +43,7 @@ static int example_rwlock_init(void) return 0; } -static void example_rwlock_exit(void) +static void __exit example_rwlock_exit(void) { pr_info("example_rwlock exit\n"); } diff --git a/examples/example_spinlock.c b/examples/example_spinlock.c index 483034f..a08944b 100644 --- a/examples/example_spinlock.c +++ b/examples/example_spinlock.c @@ -40,7 +40,7 @@ static void example_spinlock_dynamic(void) pr_info("Unlocked dynamic spinlock\n"); } -static int example_spinlock_init(void) +static int __init example_spinlock_init(void) { pr_info("example spinlock started\n"); @@ -50,7 +50,7 @@ static int example_spinlock_init(void) return 0; } -static void example_spinlock_exit(void) +static void __exit example_spinlock_exit(void) { pr_info("example spinlock exit\n"); } diff --git a/examples/example_tasklet.c b/examples/example_tasklet.c index bd894dc..84d622c 100644 --- a/examples/example_tasklet.c +++ b/examples/example_tasklet.c @@ -22,7 +22,7 @@ static void tasklet_fn(unsigned long data) static DECLARE_TASKLET_OLD(mytask, tasklet_fn); -static int example_tasklet_init(void) +static int __init example_tasklet_init(void) { pr_info("tasklet example init\n"); tasklet_schedule(&mytask); @@ -31,7 +31,7 @@ static int example_tasklet_init(void) return 0; } -static void example_tasklet_exit(void) +static void __exit example_tasklet_exit(void) { pr_info("tasklet example exit\n"); tasklet_kill(&mytask); diff --git a/examples/ioctl.c b/examples/ioctl.c index 5172732..3b75706 100644 --- a/examples/ioctl.c +++ b/examples/ioctl.c @@ -146,7 +146,7 @@ static struct file_operations fops = { .unlocked_ioctl = test_ioctl_ioctl, }; -static int ioctl_init(void) +static int __init ioctl_init(void) { dev_t dev; int alloc_ret = -1; @@ -174,7 +174,7 @@ error: return -1; } -static void ioctl_exit(void) +static void __exit ioctl_exit(void) { dev_t dev = MKDEV(test_ioctl_major, 0);