mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pintu Agarwal <pintu_agarwal@yahoo.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: help for kernel initcall section (init.h)
Date: Sat, 20 Aug 2011 20:54:08 -0700 (PDT)	[thread overview]
Message-ID: <1313898848.75462.YahooMailNeo@web162014.mail.bf1.yahoo.com> (raw)

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

             reply	other threads:[~2011-08-21  3:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-21  3:54 Pintu Agarwal [this message]
2011-08-22  9:08 ` Américo Wang
2011-08-22 14:17   ` Pintu Agarwal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1313898848.75462.YahooMailNeo@web162014.mail.bf1.yahoo.com \
    --to=pintu_agarwal@yahoo.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®