examples: Add missing __init/__exit (#209)

Close #207
This commit is contained in:
Chih-En Lin 2023-07-05 09:44:21 +08:00 committed by GitHub
parent d68fd7623e
commit befbaf085b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 20 additions and 20 deletions

View File

@ -40,7 +40,7 @@ static int machine_flywheel_spinup_thread(void *arg)
#endif #endif
} }
static int completions_init(void) static int __init completions_init(void)
{ {
struct task_struct *crank_thread; struct task_struct *crank_thread;
struct task_struct *flywheel_thread; struct task_struct *flywheel_thread;
@ -71,7 +71,7 @@ ERROR_THREAD_1:
return -1; return -1;
} }
static void completions_exit(void) static void __exit completions_exit(void)
{ {
wait_for_completion(&machine.crank_comp); wait_for_completion(&machine.crank_comp);
wait_for_completion(&machine.flywheel_comp); wait_for_completion(&machine.flywheel_comp);

View File

@ -18,7 +18,7 @@ static void show_hash_result(char *plaintext, char *hash_sha256)
pr_info("%s\n", str); pr_info("%s\n", str);
} }
static int cryptosha256_init(void) static int __init cryptosha256_init(void)
{ {
char *plaintext = "This is a test"; char *plaintext = "This is a test";
char hash_sha256[SHA256_LENGTH]; char hash_sha256[SHA256_LENGTH];
@ -57,7 +57,7 @@ static int cryptosha256_init(void)
return 0; return 0;
} }
static void cryptosha256_exit(void) static void __exit cryptosha256_exit(void)
{ {
} }

View File

@ -171,7 +171,7 @@ out:
return ret; return ret;
} }
static int cryptoapi_init(void) static int __init cryptoapi_init(void)
{ {
/* The world's favorite password */ /* The world's favorite password */
char *password = "password123"; char *password = "password123";
@ -186,7 +186,7 @@ static int cryptoapi_init(void)
return 0; return 0;
} }
static void cryptoapi_exit(void) static void __exit cryptoapi_exit(void)
{ {
test_skcipher_finish(&sk); test_skcipher_finish(&sk);
} }

View File

@ -69,7 +69,7 @@ static struct platform_driver devicemodel_driver = {
.remove = devicemodel_remove, .remove = devicemodel_remove,
}; };
static int devicemodel_init(void) static int __init devicemodel_init(void)
{ {
int ret; int ret;
@ -85,7 +85,7 @@ static int devicemodel_init(void)
return 0; return 0;
} }
static void devicemodel_exit(void) static void __exit devicemodel_exit(void)
{ {
pr_info("devicemodel exit\n"); pr_info("devicemodel exit\n");
platform_driver_unregister(&devicemodel_driver); platform_driver_unregister(&devicemodel_driver);

View File

@ -53,7 +53,7 @@ static void atomic_bitwise(void)
pr_info("Bits 5: " BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(word)); 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"); pr_info("example_atomic started\n");
@ -63,7 +63,7 @@ static int example_atomic_init(void)
return 0; return 0;
} }
static void example_atomic_exit(void) static void __exit example_atomic_exit(void)
{ {
pr_info("example_atomic exit\n"); pr_info("example_atomic exit\n");
} }

View File

@ -7,7 +7,7 @@
static DEFINE_MUTEX(mymutex); static DEFINE_MUTEX(mymutex);
static int example_mutex_init(void) static int __init example_mutex_init(void)
{ {
int ret; int ret;
@ -28,7 +28,7 @@ static int example_mutex_init(void)
return 0; return 0;
} }
static void example_mutex_exit(void) static void __exit example_mutex_exit(void)
{ {
pr_info("example_mutex exit\n"); pr_info("example_mutex exit\n");
} }

View File

@ -33,7 +33,7 @@ static void example_write_lock(void)
pr_info("Write Unlocked\n"); pr_info("Write Unlocked\n");
} }
static int example_rwlock_init(void) static int __init example_rwlock_init(void)
{ {
pr_info("example_rwlock started\n"); pr_info("example_rwlock started\n");
@ -43,7 +43,7 @@ static int example_rwlock_init(void)
return 0; return 0;
} }
static void example_rwlock_exit(void) static void __exit example_rwlock_exit(void)
{ {
pr_info("example_rwlock exit\n"); pr_info("example_rwlock exit\n");
} }

View File

@ -40,7 +40,7 @@ static void example_spinlock_dynamic(void)
pr_info("Unlocked dynamic spinlock\n"); 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"); pr_info("example spinlock started\n");
@ -50,7 +50,7 @@ static int example_spinlock_init(void)
return 0; return 0;
} }
static void example_spinlock_exit(void) static void __exit example_spinlock_exit(void)
{ {
pr_info("example spinlock exit\n"); pr_info("example spinlock exit\n");
} }

View File

@ -22,7 +22,7 @@ static void tasklet_fn(unsigned long data)
static DECLARE_TASKLET_OLD(mytask, tasklet_fn); 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"); pr_info("tasklet example init\n");
tasklet_schedule(&mytask); tasklet_schedule(&mytask);
@ -31,7 +31,7 @@ static int example_tasklet_init(void)
return 0; return 0;
} }
static void example_tasklet_exit(void) static void __exit example_tasklet_exit(void)
{ {
pr_info("tasklet example exit\n"); pr_info("tasklet example exit\n");
tasklet_kill(&mytask); tasklet_kill(&mytask);

View File

@ -146,7 +146,7 @@ static struct file_operations fops = {
.unlocked_ioctl = test_ioctl_ioctl, .unlocked_ioctl = test_ioctl_ioctl,
}; };
static int ioctl_init(void) static int __init ioctl_init(void)
{ {
dev_t dev; dev_t dev;
int alloc_ret = -1; int alloc_ret = -1;
@ -174,7 +174,7 @@ error:
return -1; return -1;
} }
static void ioctl_exit(void) static void __exit ioctl_exit(void)
{ {
dev_t dev = MKDEV(test_ioctl_major, 0); dev_t dev = MKDEV(test_ioctl_major, 0);