Re: Device Initialization.

Pawel S. Veselov (vps@unicorn.niimm.spb.su)
Tue, 19 Aug 1997 22:16:20 +0400 (MSD)


Hello, Andi!

On 19 Aug 1997, Andi Kleen wrote:

>"Pawel S. Veselov" <vps@unicorn.niimm.spb.su> writes:
>
>> > I've looked at kernel sources, and I can't find a place where to
>> >put a code to automatically initialize my device at startup... Where's it?
>>
>> Use:
>> __initfunc(int your_init(<init args>))
>> {
>> ...
>> }
>>
>> Init args are often "void" or "unsigned long kmem_start"
>>
>> This is described in <linux/init.h>
>
>Be careful, __initfunc only means that the code is freed after the
>kernel initialization. You still have to add a call to the function
>somewhere else. One place for this is init/main.c:start_kernel() for
>general functions, drivers/net/Space.c for network drivers, drivers/char/mem.c
>for character devices, fs/filesystems.c for filesystems etc.

Ah, sorry. Developing a driver, I made it under misc devices, so placed init
into the misc.c.

And when modules are enabled and device can be compiled as module and chosen
to be compiled as module, init() call should be placed in init_module() and
<linux/module.h> should be #included.

Bye.

--
Your boyfriend takes chocolate from strangers.

--
    With best of best regards, Pawel S. Veselov (aka Black Angel)
       internet : vps@unicorn.niimm.spb.su ( mail,finger,talk )
                  fidonet : 2:5030/5.412
                schoolnet : 21:9000/412
                 Web page : http://www.niimm.spb.su/~vps/