Skip to contentSkip to conversation

ARM: clps711x: mark clps711x_compat as const

PATCH Applied Arnd Bergmann 3 participants 8 messages Feb 20, 2018 – Feb 23, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

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
index ee1f83b1a332..4c89a8e9a2e3 100644
@@ -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
#1 lore raw

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
index aff6994950ba..4e1d8270537c 100644
@@ -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
maintainer
#2 lore raw

Re: [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_name was put in __initconst but 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 __initconst const 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

#3 lore raw

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_name was put in __initconst but 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 __initconst const 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.

Quoted 2 lines

I think the correct fix is to remove the __initconst from orion_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

#4 lore raw

PATCH 3/3 ARM: davinci: mark spi_board_info arrays as const

In reply to Arnd Bergmann

Building 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
index e457f299cd44..d6b11907380c 100644
@@ -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
index be997243447b..fad9a5611a5d 100644
@@ -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
index e75741fb2c1d..e3780986d2a3 100644
@@ -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
author Applied
#5 lore raw

Re: [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_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'

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 struct platform_device_info dm646x_edma_device __initconst = {

This marks them const as well, as was originally intended.

I applied this to the fixes branch now.

Arnd

Acked-by
#6 lore raw

Re: [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_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 = {

Quoted 5 lines
Quoted 3 lines

This marks them const as well, as was originally intended.

I applied this to the fixes branch now.

Thanks Arnd. FWIW now:

Regards,
Sekhar

author Applied
#7 lore raw
In reply to Arnd Bergmann
Quoted 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.

Applied to the fixes branch now.

Arnd