Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing parameter to a kernel module

I have some custom hardware that uses a kernel module called foo.ko. This has to be insmod from the Linux kernel.

Is there is a way to pass a parameter to the kernel module during insmod, something like:

insmod foo.ko <parameter>

?

like image 371
boffin Avatar asked Dec 21 '22 20:12

boffin


2 Answers

Name the parameters like this:

insmod foo.ko mystring="bebop" mybyte=255 

From Passing Command Line Arguments to a Module : The Linux Kernel Module Programming Guide

like image 184
Preet Sangha Avatar answered Dec 26 '22 12:12

Preet Sangha


You can set any needed parameters at load time this way:

insmod param_name=param_value

and set it in your source code this way:

module_param(param_name, param_type, permission);

param types supported:

int -> integer value
charp -> character pointer
....

Permission is a mask like S_IRUGO, you may need to check moduleparam.h.

like image 39
Se7so Avatar answered Dec 26 '22 11:12

Se7so