Skip to content
Snippets Groups Projects
Commit dbe6d44c authored by Leon Bohnwagner's avatar Leon Bohnwagner :crab:
Browse files

feat: update kernel module logging

parent c4046057
Branches
No related tags found
No related merge requests found
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
* *
* This file provides the implementation of the functions declared in * This file provides the implementation of the functions declared in
* userspace_comm.h. * userspace_comm.h.
*
*/ */
#include "../include/userspace_comm.h" #include "../include/userspace_comm.h"
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
* *
* This file provides the implementation of the functions declared in * This file provides the implementation of the functions declared in
* receive.h. * receive.h.
*
*/ */
#include "../include/receive.h" #include "../include/receive.h"
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
* *
* This file provides the implementation of the functions declared in * This file provides the implementation of the functions declared in
* send.h. * send.h.
*
*/ */
#include "../include/send.h" #include "../include/send.h"
......
...@@ -146,7 +146,7 @@ static ssize_t device_write(struct file *filp, const char *input, size_t length, ...@@ -146,7 +146,7 @@ static ssize_t device_write(struct file *filp, const char *input, size_t length,
} }
if (temp_data.count >= MAX_MEASUREMENTS) { 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; return -EFAULT;
} }
...@@ -197,8 +197,6 @@ static inline void send_byte(uint8_t byte) { ...@@ -197,8 +197,6 @@ static inline void send_byte(uint8_t byte) {
} }
static void send_buffer(void) { static void send_buffer(void) {
printk(KERN_INFO "Send %zu bytes\n", primary_send_buffer_size);
unsigned long flags; unsigned long flags;
local_irq_save(flags); local_irq_save(flags);
...@@ -226,7 +224,7 @@ static int timed_thread_fn(void *args) { ...@@ -226,7 +224,7 @@ static int timed_thread_fn(void *args) {
return 0; return 0;
} }
static int __init lkm_init(void) { static int __init kmod_init(void) {
dev_t dev; dev_t dev;
mutex_init(&send_buffer_mutex); mutex_init(&send_buffer_mutex);
...@@ -275,7 +273,7 @@ static int __init lkm_init(void) { ...@@ -275,7 +273,7 @@ static int __init lkm_init(void) {
vfree(secondary_send_buffer); vfree(secondary_send_buffer);
vfree(packet->data.measurements); vfree(packet->data.measurements);
vfree(packet); vfree(packet);
printk(KERN_ALERT "Failed to allocate major number\n"); printk(KERN_ALERT "sibyl: failed to allocate major number\n");
return -1; return -1;
} }
major_number = MAJOR(dev); major_number = MAJOR(dev);
...@@ -287,7 +285,7 @@ static int __init lkm_init(void) { ...@@ -287,7 +285,7 @@ static int __init lkm_init(void) {
vfree(packet->data.measurements); vfree(packet->data.measurements);
vfree(packet); vfree(packet);
unregister_chrdev_region(MKDEV(major_number, 0), 1); 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); return PTR_ERR(class);
} }
...@@ -299,7 +297,7 @@ static int __init lkm_init(void) { ...@@ -299,7 +297,7 @@ static int __init lkm_init(void) {
vfree(packet); vfree(packet);
class_destroy(class); class_destroy(class);
unregister_chrdev_region(MKDEV(major_number, 0), 1); 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; return -1;
} }
...@@ -312,11 +310,11 @@ static int __init lkm_init(void) { ...@@ -312,11 +310,11 @@ static int __init lkm_init(void) {
device_destroy(class, MKDEV(major_number, 0)); device_destroy(class, MKDEV(major_number, 0));
class_destroy(class); class_destroy(class);
unregister_chrdev_region(MKDEV(major_number, 0), 1); 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; 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) { if (gpio_request(GPIO_PIN, "GPIO_PIN") < 0) {
vfree(primary_send_buffer); vfree(primary_send_buffer);
...@@ -327,7 +325,7 @@ static int __init lkm_init(void) { ...@@ -327,7 +325,7 @@ static int __init lkm_init(void) {
device_destroy(class, MKDEV(major_number, 0)); device_destroy(class, MKDEV(major_number, 0));
class_destroy(class); class_destroy(class);
unregister_chrdev_region(MKDEV(major_number, 0), 1); 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; return -1;
} }
gpio_direction_output(GPIO_PIN, 1); gpio_direction_output(GPIO_PIN, 1);
...@@ -342,25 +340,33 @@ static int __init lkm_init(void) { ...@@ -342,25 +340,33 @@ static int __init lkm_init(void) {
device_destroy(class, MKDEV(major_number, 0)); device_destroy(class, MKDEV(major_number, 0));
class_destroy(class); class_destroy(class);
unregister_chrdev_region(MKDEV(major_number, 0), 1); 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; return -1;
} }
printk(KERN_INFO "sibyl: timed thread started successfully\n");
interval = ktime_set(0, SLOT_INTERVAL_NS); interval = ktime_set(0, SLOT_INTERVAL_NS);
hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
timer.function = timer_callback; timer.function = timer_callback;
hrtimer_start(&timer, interval, HRTIMER_MODE_REL); hrtimer_start(&timer, interval, HRTIMER_MODE_REL);
printk(KERN_INFO "sibyl: hrtimer started successfully\n");
return 0; return 0;
} }
static void __exit lkm_exit(void) { static void __exit kmod_exit(void) {
if (timed_thread) { if (timed_thread) {
kthread_stop(timed_thread); kthread_stop(timed_thread);
} }
printk(KERN_INFO "sibyl: timed thread stopped successfully\n");
hrtimer_cancel(&timer); hrtimer_cancel(&timer);
printk(KERN_INFO "sibyl: hrtimer cancelled successfully\n");
mutex_destroy(&send_buffer_mutex); mutex_destroy(&send_buffer_mutex);
vfree(primary_send_buffer); vfree(primary_send_buffer);
...@@ -371,13 +377,13 @@ static void __exit lkm_exit(void) { ...@@ -371,13 +377,13 @@ static void __exit lkm_exit(void) {
device_destroy(class, MKDEV(major_number, 0)); device_destroy(class, MKDEV(major_number, 0));
class_destroy(class); class_destroy(class);
unregister_chrdev_region(MKDEV(major_number, 0), 1); 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_set_value(GPIO_PIN, 0);
gpio_free(GPIO_PIN); gpio_free(GPIO_PIN);
} }
module_init(lkm_init); module_init(kmod_init);
module_exit(lkm_exit); module_exit(kmod_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment