diff --git a/common/src/userspace_comm.c b/common/src/userspace_comm.c index cfa209a7faf2495cf12e5e9c638bbc7c7df61173..320391c10b6bc316948a73d9b0acb6ea4aeb878e 100644 --- a/common/src/userspace_comm.c +++ b/common/src/userspace_comm.c @@ -3,7 +3,6 @@ * * This file provides the implementation of the functions declared in * userspace_comm.h. - * */ #include "../include/userspace_comm.h" diff --git a/daemon/src/receive.c b/daemon/src/receive.c index b37c6e3cfb50f0d6b4b86f04840741f4fa6c7de1..75f709a77a3f981218e623e30085edfa56e2ea8b 100644 --- a/daemon/src/receive.c +++ b/daemon/src/receive.c @@ -3,7 +3,6 @@ * * This file provides the implementation of the functions declared in * receive.h. - * */ #include "../include/receive.h" diff --git a/daemon/src/send.c b/daemon/src/send.c index 8a72d182f270eeb07b7a32be8623ef043d4f64ef..0c1aef37f4f864d03b19ad25883c91af259f422b 100644 --- a/daemon/src/send.c +++ b/daemon/src/send.c @@ -3,7 +3,6 @@ * * This file provides the implementation of the functions declared in * send.h. - * */ #include "../include/send.h" diff --git a/kernel/kmod.c b/kernel/kmod.c index 8dbb96c3f5331eae23e3a783308595f0aa7d7938..563414e69893e840b0c9be34854cff7f709ebc14 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c @@ -146,7 +146,7 @@ static ssize_t device_write(struct file *filp, const char *input, size_t length, } if (temp_data.count >= MAX_MEASUREMENTS) { - printk(KERN_ALERT "lkm: Tried to write more measurements than allowed\n"); + printk(KERN_ALERT "sibyl: tried to write more measurements than allowed\n"); return -EFAULT; } @@ -197,8 +197,6 @@ static inline void send_byte(uint8_t byte) { } static void send_buffer(void) { - printk(KERN_INFO "Send %zu bytes\n", primary_send_buffer_size); - unsigned long flags; local_irq_save(flags); @@ -226,7 +224,7 @@ static int timed_thread_fn(void *args) { return 0; } -static int __init lkm_init(void) { +static int __init kmod_init(void) { dev_t dev; mutex_init(&send_buffer_mutex); @@ -275,7 +273,7 @@ static int __init lkm_init(void) { vfree(secondary_send_buffer); vfree(packet->data.measurements); vfree(packet); - printk(KERN_ALERT "Failed to allocate major number\n"); + printk(KERN_ALERT "sibyl: failed to allocate major number\n"); return -1; } major_number = MAJOR(dev); @@ -287,7 +285,7 @@ static int __init lkm_init(void) { vfree(packet->data.measurements); vfree(packet); unregister_chrdev_region(MKDEV(major_number, 0), 1); - printk(KERN_ALERT "Failed to create device class\n"); + printk(KERN_ALERT "sibyl: failed to create device class\n"); return PTR_ERR(class); } @@ -299,7 +297,7 @@ static int __init lkm_init(void) { vfree(packet); class_destroy(class); unregister_chrdev_region(MKDEV(major_number, 0), 1); - printk(KERN_ALERT "Failed to create device\n"); + printk(KERN_ALERT "sibyl: failed to create device\n"); return -1; } @@ -312,11 +310,11 @@ static int __init lkm_init(void) { device_destroy(class, MKDEV(major_number, 0)); class_destroy(class); unregister_chrdev_region(MKDEV(major_number, 0), 1); - printk(KERN_ALERT "Failed to add character device\n"); + printk(KERN_ALERT "sibyl: failed to add character device\n"); return -1; } - printk(KERN_INFO "lkm: device created successfully\n"); + printk(KERN_INFO "sibyl: device created successfully\n"); if (gpio_request(GPIO_PIN, "GPIO_PIN") < 0) { vfree(primary_send_buffer); @@ -327,7 +325,7 @@ static int __init lkm_init(void) { device_destroy(class, MKDEV(major_number, 0)); class_destroy(class); unregister_chrdev_region(MKDEV(major_number, 0), 1); - printk(KERN_ALERT "Failed to request GPIO pin\n"); + printk(KERN_ALERT "sibyl: failed to request GPIO pin\n"); return -1; } gpio_direction_output(GPIO_PIN, 1); @@ -342,25 +340,33 @@ static int __init lkm_init(void) { device_destroy(class, MKDEV(major_number, 0)); class_destroy(class); unregister_chrdev_region(MKDEV(major_number, 0), 1); - printk(KERN_ALERT "Failed to create timed thread\n"); + printk(KERN_ALERT "sibyl: failed to create timed thread\n"); return -1; } + printk(KERN_INFO "sibyl: timed thread started successfully\n"); + interval = ktime_set(0, SLOT_INTERVAL_NS); hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); timer.function = timer_callback; hrtimer_start(&timer, interval, HRTIMER_MODE_REL); + printk(KERN_INFO "sibyl: hrtimer started successfully\n"); + return 0; } -static void __exit lkm_exit(void) { +static void __exit kmod_exit(void) { if (timed_thread) { kthread_stop(timed_thread); } + printk(KERN_INFO "sibyl: timed thread stopped successfully\n"); + hrtimer_cancel(&timer); + printk(KERN_INFO "sibyl: hrtimer cancelled successfully\n"); + mutex_destroy(&send_buffer_mutex); vfree(primary_send_buffer); @@ -371,13 +377,13 @@ static void __exit lkm_exit(void) { device_destroy(class, MKDEV(major_number, 0)); class_destroy(class); unregister_chrdev_region(MKDEV(major_number, 0), 1); - printk(KERN_INFO "lkm: device removed successfully\n"); + printk(KERN_INFO "sibyl: device removed successfully\n"); gpio_set_value(GPIO_PIN, 0); gpio_free(GPIO_PIN); } -module_init(lkm_init); -module_exit(lkm_exit); +module_init(kmod_init); +module_exit(kmod_exit); MODULE_LICENSE("GPL");