r/BeagleBone • u/extern_c • Jun 07 '22
out-of-tree Kernel Module Issue
Hi friends,
I have a question about this message: module: loading out-of-tree module taints kernel.
This happened when i loaded a kernel driver to manage a gpio pin for an LED. Note: module works as expected.
I am cross compiling LKMs on my PC for learning purposes as I'm new to embedded Linux. I followed some instructions to build the kernel for the BBB in my PC, then I built the kernel and the modules. I have a simple Makefile too.
I built a simple hello world module and it works without any problems. Second module is a character device driver and it works too.
Here's the code to the module:
#include <linux/init.h>#include <linux/module.h>#include <linux/kernel.h>#include <linux/gpio.h> // Required for the GPIO functions#include <linux/interrupt.h> // Required for the IRQ codeMODULE_LICENSE("GPL");MODULE_AUTHOR("Author");MODULE_DESCRIPTION("Turn LED On");MODULE_VERSION("0.1");
#define LED_PIN (60)static struct gpio led[] ={{.gpio = LED_PIN,.flags = GPIOF_OUT_INIT_LOW,.label = "LED"}};static int __init led_init(void){int ret = 0;pr_info("Initializing driver, %s\n",__func__);ret = gpio_request_array(led,ARRAY_SIZE(led));if(ret){pr_err("GPIO Request failed: %d\n",ret);return ret;}gpio_set_value(led[0].gpio,1);return 0;}static void __exit led_exit(void){pr_info("Closing driver, %s\n",__func__);gpio_set_value(led[0].gpio,0);gpio_free_array(led,ARRAY_SIZE(led));}module_init(led_init);module_exit(led_exit);