Re: Non-__init functions calling __init functions

From: Andrzej Krzysztofowicz (ankry@green.mif.pg.gda.pl)
Date: Fri Mar 21 2003 - 04:10:11 EST


> Andrzej Krzysztofowicz wrote:
>
> > Not always possible.
> >
> > __init A() {
> > ...
> > }
> >
> > __exit B() {
> > ...
> > }
> >
> > C() {
> > ...
> > A();
> > ...
> > #ifdef MODULE
> > B();
> > #endif
> > ...
> > }
> >
> > C cannot be marked __init for #define MODULE case. Even if it is called only
> > by some __init code. I can imagine other similar situations.
>
> I thought that in the case of modules, __init is a noop? At least, that's what
> this page says

Currently - yes.
But I heard about patches that make __init usefull in modular case.
Why break them ?

> http://www.netfilter.org/unreliable-guides/kernel-hacking/routines-init.html
>
> So if MODULE is defined, it doesn't matter if C is labelled as __init or not,
> and if it is not defined, it *should* be labelled as __init since it is itself
> calling __init code.

Safely the following can be added:

+ #ifndef MODULE
+ __init
+ #endif
  C() {

But I heard that our policy is avoiding extra #ifdefs if possible...

AFAIR, some __init functions were called (in 2.4 scsi code; I didn't check
newer code) indirectly, by pointers to them, from non __init code. It is
more dificult to detect such cases.

-- 
=======================================================================
  Andrzej M. Krzysztofowicz               ankry@mif.pg.gda.pl
  phone (48)(58) 347 14 61
Faculty of Applied Phys. & Math.,   Gdansk University of Technology
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Mar 23 2003 - 22:00:35 EST