boffin
boffin

Reputation: 669

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>

?

Upvotes: 6

Views: 22352

Answers (2)

Se7so
Se7so

Reputation: 61

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.

Upvotes: 6

Preet Sangha
Preet Sangha

Reputation: 65506

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

Upvotes: 8

Related Questions