ARM: clps711x: mark clps711x_compat as const
Subsystems (4)
PATCH 1/3 ARM: clps711x: mark clps711x_compat as const
The array of string pointers is put in __initconst, and the strings themselves are marke 'const' but the the pointers are not, which caused a warning when built with LTO:
arch/arm/mach-clps711x/board-dt.c:72:20: error: 'clps711x_compat' causes a section type conflict with 'feroceon_ids'
static const char *clps711x_compat[] __initconst = {
This marks the array itself const as well, which was certainly the intention originally.
--- arch/arm/mach-clps711x/board-dt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-clps711x/board-dt.c +1 -1
@@ -69,7 +69,7 @@ static void clps711x_restart(enum reboot_mode mode, const char *cmd)soft_restart (0 ); } -static const char *clps711x_compat[]__initconst = { +static const char *const clps711x_compat[]__initconst = {"cirrus,ep7209" ,NULL };
Signature · 1 line
2.9.0
PATCH 2/3 ARM: orion: mark orion_ge00_mvmdio_bus_name as const
A section type mismatch warning shows up when building with LTO, since orion_ge00_mvmdio_bus_name was put in __initconst but not marked const itself:
include/linux/of.h: In function 'spear_setup_of_timer':arch/arm/mach-spear/time.c:207:34: error: 'timer_of_match' causes a section type conflict with 'orion_ge00_mvmdio_bus_name'
static const struct of_device_id timer_of_match[] __initconst = {
^
arch/arm/plat-orion/common.c:475:32: note: 'orion_ge00_mvmdio_bus_name' was declared here
static __initconst const char *orion_ge00_mvmdio_bus_name = "orion-mii";
^This marks it const as well.
--- arch/arm/plat-orion/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/plat-orion/common.c +1 -1
@@ -472,7 +472,7 @@ void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data,/***************************************************************************** * Ethernet switch ****************************************************************************/ -static __initconst const char *orion_ge00_mvmdio_bus_name ="orion-mii" ; +static __initconst const char *const orion_ge00_mvmdio_bus_name ="orion-mii" ;static __initdata struct mdio_board_info orion_ge00_switch_board_info;
Signature · 1 line
2.9.0
Andrew Lunn
maintainerRe: [PATCH 2/3] ARM: orion: mark orion_ge00_mvmdio_bus_name as const
Quoted 4 lines · Arnd Bergmann
A section type mismatch warning shows up when building with LTO, since
orion_ge00_mvmdio_bus_namewas put in__initconstbut not marked const itself:
Quoted 8 lines
include/linux/of.h: In function 'spear_setup_of_timer':arch/arm/mach-spear/time.c:207:34: error: 'timer_of_match' causes a section type conflict with 'orion_ge00_mvmdio_bus_name'static const struct of_device_id timer_of_match[] __initconst = { ^
arch/arm/plat-orion/common.c:475:32: note: 'orion_ge00_mvmdio_bus_name' was declared here
static__initconstconst char*orion_ge00_mvmdio_bus_name= "orion-mii";This marks it const as well.
Hi Arnd
I'm not sure this is the correct fix. orion_ge00_mvmdio_bus_name is assigned to orion_ge00_switch_board_info->bus_id. This is then passed to mdiobus_register_board_info() which makes a copy of orion_ge00_switch_board_info and adds it to its linked list. The original orion_ge00_switch_board_info will get freed since it is __initdata, but the copy still has a pointer to orion_ge00_mvmdio_bus_name, which also gets freed.
I think the correct fix is to remove the __initconst from orion_ge00_mvmdio_bus_name. Marking it const is however valid.
Andrew
Re: [PATCH 2/3] ARM: orion: mark orion_ge00_mvmdio_bus_name as const
Quoted 24 lines · Andrew Lunn
Quoted 4 lines · Arnd Bergmann
A section type mismatch warning shows up when building with LTO, since
orion_ge00_mvmdio_bus_namewas put in__initconstbut not marked const itself:Quoted 8 lines
include/linux/of.h: In function 'spear_setup_of_timer':arch/arm/mach-spear/time.c:207:34: error: 'timer_of_match' causes a section type conflict with 'orion_ge00_mvmdio_bus_name'static const struct of_device_id timer_of_match[] __initconst = { ^
arch/arm/plat-orion/common.c:475:32: note: 'orion_ge00_mvmdio_bus_name' was declared here
static__initconstconst char*orion_ge00_mvmdio_bus_name= "orion-mii";This marks it const as well.
Hi Arnd
I'm not sure this is the correct fix.
orion_ge00_mvmdio_bus_nameis assigned toorion_ge00_switch_board_info->bus_id. This is then passed tomdiobus_register_board_info()which makes a copy oforion_ge00_switch_board_infoand adds it to its linked list. The originalorion_ge00_switch_board_infowill get freed since it is__initdata, but the copy still has a pointer toorion_ge00_mvmdio_bus_name, which also gets freed.
Quoted 2 lines
I think the correct fix is to remove the
__initconstfromorion_ge00_mvmdio_bus_name. Marking it const is however valid.
I looked at it some more and agree with your analysis, thanks for your review!
I also checked the only other user of mdiobus_register_board_info(), and made sure it does not have this problem.
I've prepared a new patch now, will send that after some more testing.
Arnd
PATCH 3/3 ARM: davinci: mark spi_board_info arrays as const
In reply to Arnd BergmannBuilding with LTO revealed that three spi_board_info arrays are marked __initconst, but not const:
arch/arm/mach-davinci/board-dm365-evm.c: In function 'dm365_evm_init':arch/arm/mach-davinci/board-dm365-evm.c:729:30: error: 'dm365_evm_spi_info' causes a section type conflict with 'dm646x_edma_device'
static struct spi_board_info dm365_evm_spi_info[] __initconst = {
^arch/arm/mach-davinci/dm646x.c:603:42: note: 'dm646x_edma_device' was declared here
static const struct platform_device_info dm646x_edma_device __initconst = {
This marks them const as well, as was originally intended.
--- arch/arm/mach-davinci/board-dm355-evm.c | 2 +- arch/arm/mach-davinci/board-dm355-leopard.c | 2 +- arch/arm/mach-davinci/board-dm365-evm.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-davinci/board-dm355-evm.c +1 -1
@@ -368,7 +368,7 @@ static struct spi_eeprom at25640a = { .flags = EE_ADDR2, }; -static struct spi_board_info dm355_evm_spi_info[]__initconst = { +static const struct spi_board_info dm355_evm_spi_info[]__initconst = { { .modalias ="at25" , .platform_data = &at25640a,
arch/arm/mach-davinci/board-dm355-leopard.c +1 -1
@@ -217,7 +217,7 @@ static struct spi_eeprom at25640a = { .flags = EE_ADDR2, }; -static struct spi_board_info dm355_leopard_spi_info[]__initconst = { +static const struct spi_board_info dm355_leopard_spi_info[]__initconst = { { .modalias ="at25" , .platform_data = &at25640a,
arch/arm/mach-davinci/board-dm365-evm.c +1 -1
@@ -726,7 +726,7 @@ static struct spi_eeprom at25640 = { .flags = EE_ADDR2, }; -static struct spi_board_info dm365_evm_spi_info[]__initconst = { +static const struct spi_board_info dm365_evm_spi_info[]__initconst = { { .modalias ="at25" , .platform_data = &at25640,
Signature · 1 line
2.9.0
Arnd Bergmann
AppliedRe: [PATCH 3/3] ARM: davinci: mark spi_board_info arrays as const
Quoted 5 lines · Arnd Bergmann
Building with LTO revealed that three
spi_board_infoarrays are marked__initconst, but not const:
arch/arm/mach-davinci/board-dm365-evm.c: In function 'dm365_evm_init':arch/arm/mach-davinci/board-dm365-evm.c:729:30: error: 'dm365_evm_spi_info' causes a section type conflict with 'dm646x_edma_device'
Quoted 8 lines
static struct spi_board_info dm365_evm_spi_info[] __initconst = { ^
arch/arm/mach-davinci/dm646x.c:603:42: note: 'dm646x_edma_device' was declared here
static const structplatform_device_infodm646x_edma_device__initconst= {This marks them const as well, as was originally intended.
Signed-off-by Arnd Bergmann <[email protected]>
I applied this to the fixes branch now.
Arnd
Sekhar Nori
Acked-byRe: [PATCH 3/3] ARM: davinci: mark spi_board_info arrays as const
Quoted 11 lines · Arnd Bergmann
Quoted 10 lines · Arnd Bergmann
Building with LTO revealed that three
spi_board_infoarrays are marked__initconst, but not const:
arch/arm/mach-davinci/board-dm365-evm.c: In function 'dm365_evm_init':arch/arm/mach-davinci/board-dm365-evm.c:729:30: error: 'dm365_evm_spi_info' causes a section type conflict with 'dm646x_edma_device'static struct spi_board_info dm365_evm_spi_info[] __initconst = { ^
arch/arm/mach-davinci/dm646x.c:603:42: note: 'dm646x_edma_device' was declared here
static const structplatform_device_infodm646x_edma_device__initconst= {
Quoted 5 lines
Quoted 3 lines
This marks them const as well, as was originally intended.
Signed-off-by Arnd Bergmann <[email protected]>I applied this to the fixes branch now.
Thanks Arnd. FWIW now:
Regards,
Sekhar
Arnd Bergmann
AppliedQuoted 11 lines · Arnd Bergmann
The array of string pointers is put in
__initconst, and the strings themselves are marke 'const' but the the pointers are not, which caused a warning when built with LTO:
arch/arm/mach-clps711x/board-dt.c:72:20: error: 'clps711x_compat' causes a section type conflict with 'feroceon_ids'
static const char *clps711x_compat[]__initconst= {This marks the array itself const as well, which was certainly the intention originally.
Signed-off-by Arnd Bergmann <[email protected]>
Applied to the fixes branch now.
Arnd