Messages in this thread | ![/](/images/icornerl.gif) | | Date | Mon, 22 Aug 2011 17:08:46 +0800 | Subject | Re: help for kernel initcall section (init.h) | From | Américo Wang <> |
| |
On Sun, Aug 21, 2011 at 11:54 AM, Pintu Agarwal <pintu_agarwal@yahoo.com> wrote: > Hi, > > I need some help in modifying initcall section in init.h. > > That is : > > #define __define_initcall(level,fn,id) \ > static initcall_t __initcall_##fn##id __used \ > __attribute__((__section__(".initcall" level ".init"))) = fn > > I have to create two different kinds (and later more) of init section and use one of them based on some condition. > For example, I have one init section for normal mode and one init section for charger mode. > During charger mode, I do not have to execute all the initcall so a charger.initcall is create with lesser init function. > The charger initcall section is as follows: > #define __define_charger_initcall(level,fn,id) \ > static initcall_t __charger_initcall_##fn##id __used \ > __attribute__((__section__(".charger.initcall" level ".init"))) = fn > > > Now the problem is that during compile time both of them needs to be polulated based on CHARGER_MODE is enabled or disabled. > How can this decision be taken during compile time under the macro "__define_initcall" ?? > > Something like : > > #define __define_initcall(level,fn,id) \ > static initcall_t __initcall_##fn##id __used \ > __attribute__((__section__(".initcall" level ".init"))) = fn \ > #if defined(CHARGER_MODE) \ > static initcall_t __charger_initcall_##fn##id __used \ > __attribute__((__section__(".charger.initcall" level ".init"))) = fn \ > #endif
Hi,
Why not
X_initcall(foo_initcall); #ifdef CHARGER_MODE X_initcall(foo_charger_initcall); #endif
?
| ![\](/images/icornerr.gif) |