EmbLogic's Blog

Passing Command Line Arguments to a Module

Driver Modules can take command line arguments, but not with the argc/argv you might be used to.

To allow arguments to be passed to your module, declare the variables that will take the values of the command line arguments as global and then use the module_param() macro, (defined in linux/moduleparam.h) to set the mechanism up. At runtime, insmod will fill the variables with any command line arguments that are given, like ./insmod mymodule.ko myvariable=5


RCS file: header.h,v
Working file: header.h
head: 1.1
branch:
locks: strict
raghav: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
including linux/moduleparam.h
—————————-
revision 1.1    locked by: raghav;
date: 2014/02/21 03:49:24;  author: raghav;  state: Exp;
Initial revision
=============================================================================

RCS file: entry.c,v
Working file: entry.c
head: 1.1
branch:
locks: strict
raghav: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
included module_param()
—————————-
revision 1.1    locked by: raghav;
date: 2014/02/21 03:52:45;  author: raghav;  state: Exp;
Initial revision
=============================================================================

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>