* help for kernel initcall section (init.h)
@ 2011-08-21 3:54 Pintu Agarwal
2011-08-22 9:08 ` Américo Wang
0 siblings, 1 reply; 3+ messages in thread
From: Pintu Agarwal @ 2011-08-21 3:54 UTC (permalink / raw)
To: linux-kernel
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
Right now this cannot be done, as macro cannot exists inside a macro statement.
If any body have any alternative or better idea of doing this please help.
In gernal, how can I take decision during compile time itself and decide which initcall to be used instead of calling all of them.
Thanks, Regards.
Pintu
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: help for kernel initcall section (init.h)
2011-08-21 3:54 help for kernel initcall section (init.h) Pintu Agarwal
@ 2011-08-22 9:08 ` Américo Wang
2011-08-22 14:17 ` Pintu Agarwal
0 siblings, 1 reply; 3+ messages in thread
From: Américo Wang @ 2011-08-22 9:08 UTC (permalink / raw)
To: Pintu Agarwal; +Cc: linux-kernel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 2403 bytes --]
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
?
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: help for kernel initcall section (init.h)
2011-08-22 9:08 ` Américo Wang
@ 2011-08-22 14:17 ` Pintu Agarwal
0 siblings, 0 replies; 3+ messages in thread
From: Pintu Agarwal @ 2011-08-22 14:17 UTC (permalink / raw)
To: Américo Wang; +Cc: linux-kernel
----- Original Message -----
> From: Américo Wang <xiyou.wangcong@gmail.com>
> To: Pintu Agarwal <pintu_agarwal@yahoo.com>
> Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
> Sent: Monday, 22 August 2011 2:38 PM
> Subject: Re: help for kernel initcall section (init.h)
>
> 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
>
> ?
>
No the requirement is not to do like this.
This requires defining 2 set of init calls, one for normal and one for charger init call.
We do not want to define separate init calls for charger.
We just want to take a decision during compile time to determine which initcalls should be used during charger mode.
Thus we need compile time comparison in macro which helps us in determining whether _this__ init call should be added in charger.init section or not.
Thus we can do as follows:-
------------------------------------------------------------------------------------------------------------------------------------
#define __define_initcall(level,fn,id) static initcall_t __initcall_##fn##id __used __attribute__ ((__section__(".initcall" level ".init"))) = fn \
#ifdef CHARGER_MODE \
static initcall_t __charger_initcall_##fn##id __used __attribute__ ((__section__(".charger.initcall" level ".init"))) = fn \
#endif
#define device_initcall(fn) __define_initcall("6", fn, 6, 1)
#define __initcall(fn) device_initcall(fn)
#define module_init(x) __initcall(x);
#define early_initcall(fn) module_init(fn)
------------------------------------------------------------------------------------------------------------------------------------
Basically we need something like:
#define __define_initcall(....) \
/* polupate init section */ \
#ifdef CHARGER_MODE \
/* polupate charger.init section also */ \
#elif ANOTHER_MODE \
/* polupate another.init section also */ \
#elif ....
.............
.............
#endif
Is it possible to do "#if or #ifdef" inside "#define" ?????
Basically, we need to populate each.init section based on some compile time condition.
How can we do that????
Thanks,
Pintu
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-08-22 14:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-21 3:54 help for kernel initcall section (init.h) Pintu Agarwal
2011-08-22 9:08 ` Américo Wang
2011-08-22 14:17 ` Pintu Agarwal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®