All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adrian Bunk <bunk@kernel.org>
To: kernel-janitors@vger.kernel.org
Subject: Re: const __initdata?
Date: Sat, 01 Dec 2007 00:20:55 +0000	[thread overview]
Message-ID: <20071201002055.GQ29463@stusta.de> (raw)
In-Reply-To: <alpine.LFD.0.9999.0711290227150.25822@localhost.localdomain>

On Thu, Nov 29, 2007 at 08:53:03AM -0800, Randy Dunlap wrote:
> On Thu, 29 Nov 2007 02:28:43 -0500 (EST) Robert P. J. Day wrote:
> 
> > 
> >   from include/linux/init.h:
> > 
> >  * For initialized data:
> >  * You should insert __initdata between the variable name and equal
> >  * sign followed by value, e.g.:
> >  *
> >  * static int init_variable __initdata = 0;
> >  * static char linux_logo[] __initdata = { 0x32, 0x36, ... };
> >  *
> >  * Don't forget to initialize data not at file scope, i.e. within a function,
> >  * as gcc otherwise puts the data into the bss section and not into the init
> >  * section.
> >  *
> >  * Also note, that this data cannot be "const".
> > 
> > you mean, like this in drivers/hwmon/w83627ehf.c:
> > 
> > /* w83627ehf_find() looks for a '627 in the Super-I/O config space */
> > static int __init w83627ehf_find(int sioaddr, unsigned short *addr,
> >                                  struct w83627ehf_sio_data *sio_data)
> > {
> >         static const char __initdata sio_name_W83627EHF[] = "W83627EHF";
> >         static const char __initdata sio_name_W83627EHG[] = "W83627EHG";
> >         static const char __initdata sio_name_W83627DHG[] = "W83627DHG";
> > 	...
> > 
> > or am i misreading that?
> 
> We have certainly seen problems with const __initdata being put
> into a read-only section instead of the .init.data section, but
> with gcc 4.2.1, I see these 3 __initdata items being placed into
> the .init.data section no matter where I put "const" on the data
> declaration line.  Maybe the problem has been fixed (relatively
> recently).

No, the difference is most likely related to the fact that these 
variables are inside a function, and "static" on variables inside a 
function does something different from "static" on variables outside
any function...

> ~Randy

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


      parent reply	other threads:[~2007-12-01  0:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-29  7:28 const __initdata? Robert P. J. Day
2007-11-29 16:53 ` Randy Dunlap
2007-11-30 17:08 ` Robert P. J. Day
2007-11-30 17:22 ` Randy Dunlap
2007-12-01  0:20 ` Adrian Bunk [this message]

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=20071201002055.GQ29463@stusta.de \
    --to=bunk@kernel.org \
    --cc=kernel-janitors@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.