Declare the parameter name, type and permission you want to pass in the driver module module_param(variable name, type, permissions); #include <linux/init.h> #include <linux/module.h> static char *p_name = "Usr"; module_param(p_name, charp, S_IRUGO); MODULE_PARM_DESC(p_name, "This is a char * string."); static int __init hi_init(void) { printk(KERN_INFO "Hi enter %s\n",p_name); return 0; } module_init(hi_init); static void __exit hi_exit(void) { printk(KERN_INFO "Hi exit %s\n ",p_name); } module_exit(hi_exit); MODULE_AUTHOR("libra13179"); MODULE_LICENSE("GPL v2"); KVERS = $(shell uname -r) # Kernel modules obj-m += hi.o # Specify flags for the module compilation. #EXTRA_CFLAGS=-g -O0 build: kernel_modules kernel_modules: make -C /lib/modules/$(KVERS)/build M=$(CURDIR) modules # @echo $(KVERS) clean: make -C /lib/modules/$(KVERS)/build M=$(CURDIR) clean If not set, the default value is used. root@lin-virtual-machine:/home/lin/hi# insmod ./hi.ko root@lin-virtual-machine:/home/lin/hi# cat /var/log/syslog | grep Hi ... Jul 25 15:11:38 lin-virtual-machine kernel: [ 203.238178] Hi enter Usr ... When using settings root@lin-virtual-machine:/home/lin/hi# insmod hi.ko p_name='God' After loading the module, a module folder will be generated under /sys/modules, and there will be a parameters folder under the folder. It contains the file node named after the parameter name, which stores the value we set, for example, in p_name
The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Additional instructions for using getters and actions in Vuex
>>: A detailed guide to custom directives in Vue
Correspondence between flutter and css in shadow ...
Install MySQL 8.0 docker run -p 63306:3306 -e MYS...
As the demand for front-end pages continues to in...
Recently, during the development process, the MyS...
Table of contents Overview Four examples Example ...
1. Unzip the zip package to the installation dire...
Table of contents VARCHAR and CHAR Types Conclusi...
The main configuration file of Nginx is nginx.con...
This article example shares the specific code of ...
background: I have done a project before, which r...
After clicking the a tag in the page, you want to ...
What should I do if MySQL fails to connect to the...
Method 1: Use the SET PASSWORD command mysql> ...
In the past, almost every website had a sitemap p...
Preface The basic principle of MySQL master-slave...