Re: Incompatibility of "const" and __xxxinitdata?

From: Sam Ravnborg
Date: Sat Feb 02 2008 - 13:48:31 EST


On Sat, Feb 02, 2008 at 11:20:44PM +0800, Peter Teoh wrote:
> In include/linux/init.h, it is documented that all __xxxinitdata
> declaration must not have constant, as show below:
>
> *
> * 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".
> */
>
> In this same init.h is also documented the preferred way of
> typecasting the variable with __initdata.
>
> But searching through the source codes, I have found many instances of:
>
> 1. constant occuring in the __xxxinitdata pattern, and
> 2. non-conformance of the variable declaration according to the
> codingstyle recommended.

Only very recently we had a tag to annotate const data in addition
to the __initdata tag.
The reason for two tags are that gcc does not allow to mix const
and non-const data in the same section.

So in the cases you list below there are most certainly no other
__initdata annotations or at least not to non-const data.

If you go forward and fix up this stuff do so in adequate steps.
So you for example do not mix net drivers with usb drivers
in the same patch.

And if fix it up then use the recommended style for the
annotation.
Improved documentation in init.h is also welcome!

Sam
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/