From mboxrd@z Thu Jan 1 00:00:00 1970 From: greg@kroah.com (Greg KH) Date: Wed, 11 Jun 2014 06:29:42 -0700 Subject: non-static init in a basic kernel module In-Reply-To: <5395620D.7050507@penguintechs.org> References: <5395620D.7050507@penguintechs.org> Message-ID: <20140611132942.GA27236@kroah.com> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org On Mon, Jun 09, 2014 at 12:28:13AM -0700, Warren Turkal wrote: > Hey, > > I was writing a basic hello world module. I am using Ubuntu, so I > installed linux-headers package that corresponded to my kernel. It's > strange because all of the examples that I saw (including from modules > in the kernel itself) show things like the following for the init function: > > static int netcat_init(void) > { > ... > return 0; > } > > module_init(netcat_init); > > However, I was not able to get it to work with "static". My > hello_world_init function looks like the following: > > int __init hello_world_init(void) > { > ... > return 0; > } > > module_init(hello_world_init); > > The command that is used to make the kernel module is the one suggested > in Documentation/kbuild/modules.txt. It looks like this: > make -C /lib/modules/`uname -r`/build M=$PWD > > Does anyone know why the "static" version would not work? What exactly were the errors you got?