1,Module_param参数
例如:module_param(use_acm, bool, 0);
如果我们是模块编译(make modules),则MODULE_PARAM_PREFIX为empty。
在模块传参时,参数名为use_acm,如insmod g_serial.ko use_acm=0
正常编译kernel,MODULE_PARAM_PREFIX为模块名+”.”
如果我们在传参时不知道自己的模块名是什么,可以在自己的驱动中加打印,将MODULE_PARAM_PREFIX打印出来,来确定自己驱动的模块名。
所以这里将serial.c编入kernel,根据driver/usb/gadget/Makefile,如下:
[cpp] view plain copy
在CODE上查看代码片派生到我的代码片
g_serial-y := serial.o
....
obj-$(CONFIG_USB_G_SERIAL) += g_serial.o
最终是生成g_serial.o,模块名为g_serial.ko。.name = g_serial.use_acm。
uboot传递kernel传参时,该参数名为g_serial.use_acm
- void __init parse_early_options(char *cmdline)
- {
- parse_args("early options", cmdline, NULL, 0, 0, 0, do_early_param);
- }