5

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>

?

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
boffin
  • 639
  • 2
  • 13
  • 26

2 Answers2

7

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

Preet Sangha
  • 64,563
  • 18
  • 145
  • 216
6

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.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Se7so
  • 61
  • 1
  • 6