Re: help for kernel initcall section (init.h)

From: AmÃrico Wang
Date: Mon Aug 22 2011 - 05:08:52 EST


On Sun, Aug 21, 2011 at 11:54 AM, Pintu Agarwal <pintu_agarwal@xxxxxxxxx> 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

?
¢éì®&Þ~º&¶¬–+-±éÝ¥Šw®žË±Êâmébžìdz¹Þ)í…æèw*jg¬±¨¶‰šŽŠÝj/êäz¹ÞŠà2ŠÞ¨è­Ú&¢)ß«a¶Úþø®G«éh®æj:+v‰¨Šwè†Ù>Wš±êÞiÛaxPjØm¶Ÿÿà -»+ƒùdš_