Skip to contentSkip to conversation

constify gpio_led

PATCH Superseded Arvind Yadav 4 participants 18 messages Dec 20, 2017 – Dec 25, 2017

Subsystems (12)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover constify gpio_led

gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by <linux/leds.h>. So mark the non-const structs as const.

Arvind Yadav (11):
[PATCH 01/11] MIPS: Alchemy: constify gpio_led [PATCH 02/11] MIPS: AR7: constify gpio_led [PATCH 03/11] MIPS: TXX9: constify gpio_led [PATCH 04/11] x86: geode: constify gpio_led [PATCH 05/11] sh: mach-rsk: rsk7203: constify gpio_led [PATCH 06/11] ARM: davinci: constify gpio_led [PATCH 07/11] ARM: ixp4xx: constify gpio_led [PATCH 08/11] ARM: OMAP1: constify gpio_led [PATCH 09/11] ARM: orion5x: constify gpio_led [PATCH 10/11] ARM: s3c24xx: constify gpio_led [PATCH 11/11] ARM: pxa: constify gpio_led

 arch/arm/mach-davinci/board-neuros-osd2.c |  2 +-
 arch/arm/mach-ixp4xx/dsmg600-setup.c      |  2 +-
 arch/arm/mach-ixp4xx/nas100d-setup.c      |  2 +-
 arch/arm/mach-ixp4xx/omixp-setup.c        |  2 +-
 arch/arm/mach-omap1/board-h2.c            |  2 +-
 arch/arm/mach-omap1/board-h3.c            |  2 +-
 arch/arm/mach-omap1/board-htcherald.c     |  2 +-
 arch/arm/mach-omap1/board-osk.c           |  4 ++--
 arch/arm/mach-orion5x/board-d2net.c       |  2 +-
 arch/arm/mach-orion5x/dns323-setup.c      |  2 +-
 arch/arm/mach-orion5x/ls_hgl-setup.c      |  2 +-
 arch/arm/mach-orion5x/mv2120-setup.c      |  2 +-
 arch/arm/mach-orion5x/net2big-setup.c     |  2 +-
 arch/arm/mach-orion5x/rd88f5182-setup.c   |  2 +-
 arch/arm/mach-orion5x/ts409-setup.c       |  2 +-
 arch/arm/mach-orion5x/wrt350n-v2-setup.c  |  2 +-
 arch/arm/mach-pxa/balloon3.c              |  4 ++--
 arch/arm/mach-pxa/corgi.c                 |  2 +-
 arch/arm/mach-pxa/csb701.c                |  2 +-
 arch/arm/mach-pxa/magician.c              |  2 +-
 arch/arm/mach-pxa/mioa701.c               |  2 +-
 arch/arm/mach-pxa/palmld.c                |  2 +-
 arch/arm/mach-pxa/palmz72.c               |  2 +-
 arch/arm/mach-pxa/pcm027.c                |  2 +-
 arch/arm/mach-pxa/raumfeld.c              |  4 ++--
 arch/arm/mach-pxa/spitz.c                 |  2 +-
 arch/arm/mach-pxa/stargate2.c             |  2 +-
 arch/arm/mach-pxa/tosa.c                  |  2 +-
 arch/arm/mach-pxa/trizeps4.c              |  2 +-
 arch/arm/mach-pxa/zeus.c                  |  2 +-
 arch/arm/mach-s3c24xx/mach-h1940.c        |  2 +-
 arch/arm/mach-s3c24xx/mach-rx1950.c       |  2 +-
 arch/arm/mach-s3c64xx/mach-hmt.c          |  2 +-
 arch/arm/mach-s3c64xx/mach-smartq5.c      |  2 +-
 arch/arm/mach-s3c64xx/mach-smartq7.c      |  2 +-
 arch/arm/mach-s3c64xx/mach-smdk6410.c     |  2 +-
 arch/mips/alchemy/board-gpr.c             |  2 +-
 arch/mips/alchemy/board-mtx1.c            |  2 +-
 arch/mips/ar7/platform.c                  | 14 +++++++-------
 arch/mips/txx9/rbtx4927/setup.c           |  2 +-
 arch/sh/boards/mach-rsk/devices-rsk7203.c |  2 +-
 arch/x86/platform/geode/alix.c            |  2 +-
 arch/x86/platform/geode/geos.c            |  2 +-
 arch/x86/platform/geode/net5501.c         |  2 +-
 44 files changed, 53 insertions(+), 53 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/11 MIPS: Alchemy: constify gpio_led

gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by <linux/leds.h>. So mark the non-const structs as const.

---
 arch/mips/alchemy/board-gpr.c  | 2 +-
 arch/mips/alchemy/board-mtx1.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/mips/alchemy/board-gpr.c +1 -1
index 328d697..fcc5826 100644
@@ -190,7 +190,7 @@ void __init board_setup(void)
 /*
  * LEDs
  */
-static struct gpio_led gpr_gpio_leds[] = {
+static const struct gpio_led gpr_gpio_leds[] __initconst = {
 	{	/* green */
 		.name			= "gpr:green",
 		.gpio			= 4,
arch/mips/alchemy/board-mtx1.c +1 -1
index 85bb756..59aa96a 100644
@@ -145,7 +145,7 @@ void __init board_setup(void)
 	.resource = mtx1_wdt_res,
 };
 
-static struct gpio_led default_leds[] = {
+static const struct gpio_led default_leds[] __initconst = {
 	{
 		.name	= "mtx1:green",
 		.gpio = 211,
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/11 MIPS: AR7: constify gpio_led

In reply to Arvind Yadav

gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by <linux/leds.h>. So mark the non-const structs as const.

---
 arch/mips/ar7/platform.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
arch/mips/ar7/platform.c +7 -7
index 4674f1e..343a897 100644
@@ -346,7 +346,7 @@ static void __init cpmac_get_mac(int instance, unsigned char *dev_addr)
 /*****************************************************************************
  * LEDs
  ****************************************************************************/
-static struct gpio_led default_leds[] = {
+static const struct gpio_led default_leds[] __initconst = {
 	{
 		.name			= "status",
 		.gpio			= 8,
@@ -354,12 +354,12 @@ static void __init cpmac_get_mac(int instance, unsigned char *dev_addr)
 	},
 };
 
-static struct gpio_led titan_leds[] = {
+static const struct gpio_led titan_leds[] __initconst = {
 	{ .name = "status", .gpio = 8, .active_low = 1, },
 	{ .name = "wifi", .gpio = 13, .active_low = 1, },
 };
 
-static struct gpio_led dsl502t_leds[] = {
+static const  struct gpio_led dsl502t_leds[] __initconst = {
 	{
 		.name			= "status",
 		.gpio			= 9,
@@ -377,7 +377,7 @@ static void __init cpmac_get_mac(int instance, unsigned char *dev_addr)
 	},
 };
 
-static struct gpio_led dg834g_leds[] = {
+static const struct gpio_led dg834g_leds[] __initconst = {
 	{
 		.name			= "ppp",
 		.gpio			= 6,
@@ -406,7 +406,7 @@ static void __init cpmac_get_mac(int instance, unsigned char *dev_addr)
 	},
 };
 
-static struct gpio_led fb_sl_leds[] = {
+static const struct gpio_led fb_sl_leds[] __initconst = {
 	{
 		.name			= "1",
 		.gpio			= 7,
@@ -433,7 +433,7 @@ static void __init cpmac_get_mac(int instance, unsigned char *dev_addr)
 	},
 };
 
-static struct gpio_led fb_fon_leds[] = {
+static const struct gpio_led fb_fon_leds[] __initconst = {
 	{
 		.name			= "1",
 		.gpio			= 8,
@@ -459,7 +459,7 @@ static void __init cpmac_get_mac(int instance, unsigned char *dev_addr)
 	},
 };
 
-static struct gpio_led gt701_leds[] = {
+static const struct gpio_led gt701_leds[] __initconst = {
 	{
 		.name			= "inet:green",
 		.gpio			= 13,
Signature · 1 line
1.9.1
#3 lore raw

PATCH 3/11 MIPS: TXX9: constify gpio_led

In reply to Arvind Yadav

gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by <linux/leds.h>. So mark the non-const structs as const.

---
 arch/mips/txx9/rbtx4927/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/txx9/rbtx4927/setup.c +1 -1
index f5b367e..31955c1 100644
@@ -319,7 +319,7 @@ static void __init rbtx4927_mtd_init(void)
 
 static void __init rbtx4927_gpioled_init(void)
 {
-	static struct gpio_led leds[] = {
+	static const struct gpio_led leds[] = {
 		{ .name = "gpioled:green:0", .gpio = 0, .active_low = 1, },
 		{ .name = "gpioled:green:1", .gpio = 1, .active_low = 1, },
 	};
Signature · 1 line
1.9.1
#4 lore raw

PATCH 4/11 x86: geode: constify gpio_led

In reply to Arvind Yadav

gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by <linux/leds.h>. So mark the non-const structs as const.

---
 arch/x86/platform/geode/alix.c    | 2 +-
 arch/x86/platform/geode/geos.c    | 2 +-
 arch/x86/platform/geode/net5501.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/platform/geode/alix.c +1 -1
index 1865c19..9626367 100644
@@ -71,7 +71,7 @@
 	}
 };
 
-static struct gpio_led alix_leds[] = {
+static const struct gpio_led alix_leds[] __initconst = {
 	{
 		.name = "alix:1",
 		.gpio = 6,
arch/x86/platform/geode/geos.c +1 -1
index 4fcdb91..119cfdc 100644
@@ -54,7 +54,7 @@
 	}
 };
 
-static struct gpio_led geos_leds[] = {
+static const struct gpio_led geos_leds[] __initconst = {
 	{
 		.name = "geos:1",
 		.gpio = 6,
arch/x86/platform/geode/net5501.c +1 -1
index a2f6b98..ba604cc 100644
@@ -57,7 +57,7 @@
 	}
 };
 
-static struct gpio_led net5501_leds[] = {
+static const struct gpio_led net5501_leds[] __initconst = {
 	{
 		.name = "net5501:1",
 		.gpio = 6,
Signature · 1 line
1.9.1
#5 lore raw

Re: [PATCH 04/11] x86: geode: constify gpio_led

Thank you for the patch! Perhaps something to improve:

Hi Arvind,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on arm-soc/for-next]
[also build test WARNING on v4.15-rc4 next-20171222]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Arvind-Yadav/constify-gpio_led/20171223-142117
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc.git for-next
config: i386-randconfig-s1-201751 (attached as .config)
compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

>> WARNING: vmlinux.o(.data+0x16554): Section mismatch in reference from the variable geos_leds_data to the variable .init.rodata:geos_leds

The variable geos_leds_data references
the variable __initconst geos_leds
If the reference is valid then annotate the
variable with or __refdata (see linux/init.h) or name the variable:

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#6 lore raw

PATCH 5/11 sh: mach-rsk: rsk7203: constify gpio_led

In reply to Arvind Yadav

gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by <linux/leds.h>. So mark the non-const structs as const.

---
 arch/sh/boards/mach-rsk/devices-rsk7203.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sh/boards/mach-rsk/devices-rsk7203.c +1 -1
index a8089f7..5d32f1b 100644
@@ -50,7 +50,7 @@
 	},
 };
 
-static struct gpio_led rsk7203_gpio_leds[] = {
+static const struct gpio_led rsk7203_gpio_leds[] __initconst = {
 	{
 		.name			= "green",
 		.gpio			= GPIO_PE10,
Signature · 1 line
1.9.1
#7 lore raw

PATCH 6/11 ARM: davinci: constify gpio_led

In reply to Arvind Yadav

gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by <linux/leds.h>. So mark the non-const structs as const.

---
 arch/arm/mach-davinci/board-neuros-osd2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-davinci/board-neuros-osd2.c +1 -1
index 0c02aaa..6a42a94 100644
@@ -128,7 +128,7 @@
 	.num_resources = 0,
 };
 
-static struct gpio_led ntosd2_leds[] = {
+static const struct gpio_led ntosd2_leds[] __initconst = {
 	{ .name = "led1_green", .gpio = GPIO(10), },
 	{ .name = "led1_red",   .gpio = GPIO(11), },
 	{ .name = "led2_green", .gpio = GPIO(12), },
Signature · 1 line
1.9.1
#8 lore raw

Re: [PATCH 06/11] ARM: davinci: constify gpio_led

Quoted 6 lines · Arvind Yadav

gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by <linux/leds.h>. So mark the non-const structs as const.

This causes a new section mismatch warning

WARNING: vmlinux.o(.data+0x16d7c): Section mismatch in reference from the variable ntosd2_leds_data to the (unknown reference) .init.rodata:(unknown) The variable ntosd2_leds_data references
the (unknown reference) __initconst (unknown)
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console

Thanks,
Sekhar

#9 lore raw

PATCH 7/11 ARM: ixp4xx: constify gpio_led

In reply to Arvind Yadav

gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by <linux/leds.h>. So mark the non-const structs as const.

---
 arch/arm/mach-ixp4xx/dsmg600-setup.c | 2 +-
 arch/arm/mach-ixp4xx/nas100d-setup.c | 2 +-
 arch/arm/mach-ixp4xx/omixp-setup.c   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-ixp4xx/dsmg600-setup.c +1 -1
index 0f5c999..74892a8 100644
@@ -93,7 +93,7 @@
 	},
 };
 
-static struct gpio_led dsmg600_led_pins[] = {
+static const struct gpio_led dsmg600_led_pins[] __initconst = {
 	{
 		.name		= "dsmg600:green:power",
 		.gpio		= DSMG600_LED_PWR_GPIO,
arch/arm/mach-ixp4xx/nas100d-setup.c +1 -1
index 76dfff0..dee33d7 100644
@@ -72,7 +72,7 @@
 	},
 };
 
-static struct gpio_led nas100d_led_pins[] = {
+static const struct gpio_led nas100d_led_pins[] __initconst = {
 	{
 		.name		= "nas100d:green:wlan",
 		.gpio		= NAS100D_LED_WLAN_GPIO,
arch/arm/mach-ixp4xx/omixp-setup.c +1 -1
index 2d494b4..54acf23 100644
@@ -152,7 +152,7 @@
 	.resource		= omixp_uart_resources,
 };
 
-static struct gpio_led mic256_led_pins[] = {
+static const struct gpio_led mic256_led_pins[] __initconst = {
 	{
 		.name		= "LED-A",
 		.gpio		= 7,
Signature · 1 line
1.9.1
#10 lore raw

PATCH 8/11 ARM: OMAP1: constify gpio_led

In reply to Arvind Yadav

gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by <linux/leds.h>. So mark the non-const structs as const.

---
 arch/arm/mach-omap1/board-h2.c        | 2 +-
 arch/arm/mach-omap1/board-h3.c        | 2 +-
 arch/arm/mach-omap1/board-htcherald.c | 2 +-
 arch/arm/mach-omap1/board-osk.c       | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)
arch/arm/mach-omap1/board-h2.c +1 -1
index ab51f85..43f95e5 100644
@@ -274,7 +274,7 @@ static int h2_nand_dev_ready(struct mtd_info *mtd)
 	.resource	= h2_kp_resources,
 };
 
-static struct gpio_led h2_gpio_led_pins[] = {
+static const struct gpio_led h2_gpio_led_pins[] __initconst = {
 	{
 		.name		= "h2:red",
 		.default_trigger = "heartbeat",
arch/arm/mach-omap1/board-h3.c +1 -1
index ad339f5..957edb5 100644
@@ -326,7 +326,7 @@ static void __init h3_init_smc91x(void)
 	},
 };
 
-static struct gpio_led h3_gpio_led_pins[] = {
+static const struct gpio_led h3_gpio_led_pins[] __initconst = {
 	{
 		.name		= "h3:red",
 		.default_trigger = "heartbeat",
arch/arm/mach-omap1/board-htcherald.c +1 -1
index 67d4669..627b5e3 100644
@@ -292,7 +292,7 @@
 };
 
 /* LEDs for the Herald.  These connect to the HTCPLD GPIO device. */
-static struct gpio_led gpio_leds[] = {
+static const struct gpio_led gpio_leds[] __initconst = {
 	{"dpad",        NULL, HTCPLD_GPIO_LED_DPAD,        0, 0, LEDS_GPIO_DEFSTATE_OFF},
 	{"kbd",         NULL, HTCPLD_GPIO_LED_KBD,         0, 0, LEDS_GPIO_DEFSTATE_OFF},
 	{"vibrate",     NULL, HTCPLD_GPIO_LED_VIBRATE,     0, 0, LEDS_GPIO_DEFSTATE_OFF},
arch/arm/mach-omap1/board-osk.c +2 -2
index c66372e..4216b50 100644
@@ -167,7 +167,7 @@
 	&osk5912_cf_device,
 };
 
-static struct gpio_led tps_leds[] = {
+static const struct gpio_led tps_leds[] __initconst = {
 	/* NOTE:  D9 and D2 have hardware blink support.
 	 * Also, D9 requires non-battery power.
 	 */
@@ -385,7 +385,7 @@ static void __init osk_init_cf(void)
 	.id		= -1,
 };
 
-static struct gpio_led mistral_gpio_led_pins[] = {
+static const struct gpio_led mistral_gpio_led_pins[] __initconst = {
 	{
 		.name		= "mistral:red",
 		.default_trigger = "heartbeat",
Signature · 1 line
1.9.1
#11 lore raw

PATCH 9/11 ARM: orion5x: constify gpio_led

In reply to Arvind Yadav

gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by <linux/leds.h>. So mark the non-const structs as const.

---
 arch/arm/mach-orion5x/board-d2net.c      | 2 +-
 arch/arm/mach-orion5x/dns323-setup.c     | 2 +-
 arch/arm/mach-orion5x/ls_hgl-setup.c     | 2 +-
 arch/arm/mach-orion5x/mv2120-setup.c     | 2 +-
 arch/arm/mach-orion5x/net2big-setup.c    | 2 +-
 arch/arm/mach-orion5x/rd88f5182-setup.c  | 2 +-
 arch/arm/mach-orion5x/ts409-setup.c      | 2 +-
 arch/arm/mach-orion5x/wrt350n-v2-setup.c | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)
arch/arm/mach-orion5x/board-d2net.c +1 -1
index a89376a..8791a22 100644
@@ -54,7 +54,7 @@
 #define D2NET_GPIO_BLUE_LED_BLINK_CTRL	16
 #define D2NET_GPIO_BLUE_LED_OFF		23
 
-static struct gpio_led d2net_leds[] = {
+static const struct gpio_led d2net_leds[] __initconst = {
 	{
 		.name = "d2net:blue:sata",
 		.default_trigger = "default-on",
arch/arm/mach-orion5x/dns323-setup.c +1 -1
index cd483bf..70eb340 100644
@@ -221,7 +221,7 @@ static int __init dns323_read_mac_addr(void)
 };
 
 
-static struct gpio_led dns323c_leds[] = {
+static const struct gpio_led dns323c_leds[] __initconst = {
 	{
 		.name = "power:blue",
 		.gpio = DNS323C_GPIO_LED_POWER,
arch/arm/mach-orion5x/ls_hgl-setup.c +1 -1
index 47ba6e0..f5410e0 100644
@@ -86,7 +86,7 @@
 #define LS_HGL_GPIO_LED_PWR     0
 
 
-static struct gpio_led ls_hgl_led_pins[] = {
+static const struct gpio_led ls_hgl_led_pins[] __initconst = {
 	{
 		.name	   = "alarm:red",
 		.gpio	   = LS_HGL_GPIO_LED_ALARM,
arch/arm/mach-orion5x/mv2120-setup.c +1 -1
index 2bf8ec7..957095a 100644
@@ -136,7 +136,7 @@
 	.irq	= 0,
 };
 
-static struct gpio_led mv2120_led_pins[] = {
+static const struct gpio_led mv2120_led_pins[] __initconst = {
 	{
 		.name			= "mv2120:blue:health",
 		.gpio			= 0,
arch/arm/mach-orion5x/net2big-setup.c +1 -1
index bf6be4c..f8ca382 100644
@@ -214,7 +214,7 @@ static void __init net2big_sata_power_init(void)
 #define NET2BIG_GPIO_SATA0_BLUE_LED	17
 #define NET2BIG_GPIO_SATA1_BLUE_LED	13
 
-static struct gpio_led net2big_leds[] = {
+static const struct gpio_led net2big_leds[] __initconst = {
 	{
 		.name = "net2big:red:power",
 		.gpio = NET2BIG_GPIO_PWR_RED_LED,
arch/arm/mach-orion5x/rd88f5182-setup.c +1 -1
index fe3e67c..6376ae1 100644
@@ -83,7 +83,7 @@
 
 #define RD88F5182_GPIO_LED		0
 
-static struct gpio_led rd88f5182_gpio_led_pins[] = {
+static const struct gpio_led rd88f5182_gpio_led_pins[] __initconst = {
 	{
 		.name		= "rd88f5182:cpu",
 		.default_trigger = "cpu0",
arch/arm/mach-orion5x/ts409-setup.c +1 -1
index a77613b..6d88d2f 100644
@@ -169,7 +169,7 @@ static int __init qnap_ts409_pci_init(void)
  * LEDs attached to GPIO
  ****************************************************************************/
 
-static struct gpio_led ts409_led_pins[] = {
+static const struct gpio_led ts409_led_pins[] __initconst = {
 	{
 		.name		= "ts409:red:sata1",
 		.gpio		= 4,
arch/arm/mach-orion5x/wrt350n-v2-setup.c +1 -1
index 9250bb2..40adfd8 100644
@@ -29,7 +29,7 @@
 /*
  * LEDs attached to GPIO
  */
-static struct gpio_led wrt350n_v2_led_pins[] = {
+static const struct gpio_led wrt350n_v2_led_pins[] __initconst = {
 	{
 		.name		= "wrt350nv2:green:power",
 		.gpio		= 0,
Signature · 1 line
1.9.1
#12 lore raw

PATCH 10/11 ARM: s3c24xx: constify gpio_led

In reply to Arvind Yadav

gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by <linux/leds.h>. So mark the non-const structs as const.

---
 arch/arm/mach-s3c24xx/mach-h1940.c    | 2 +-
 arch/arm/mach-s3c24xx/mach-rx1950.c   | 2 +-
 arch/arm/mach-s3c64xx/mach-hmt.c      | 2 +-
 arch/arm/mach-s3c64xx/mach-smartq5.c  | 2 +-
 arch/arm/mach-s3c64xx/mach-smartq7.c  | 2 +-
 arch/arm/mach-s3c64xx/mach-smdk6410.c | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)
arch/arm/mach-s3c24xx/mach-h1940.c +1 -1
index 7ed7861..333f951 100644
@@ -413,7 +413,7 @@ int h1940_led_blink_set(struct gpio_desc *desc, int state,
 }
 EXPORT_SYMBOL(h1940_led_blink_set);
 
-static struct gpio_led h1940_leds_desc[] = {
+static const struct gpio_led h1940_leds_desc[] __initconst = {
 	{
 		.name			= "Green",
 		.default_trigger	= "main-battery-full",
arch/arm/mach-s3c24xx/mach-rx1950.c +1 -1
index e86ad6a..f8cb057 100644
@@ -295,7 +295,7 @@ static int rx1950_led_blink_set(struct gpio_desc *desc, int state,
 	return 0;
 }
 
-static struct gpio_led rx1950_leds_desc[] = {
+static const struct gpio_led rx1950_leds_desc[] __initconst = {
 	{
 		.name			= "Green",
 		.default_trigger	= "main-battery-full",
arch/arm/mach-s3c64xx/mach-hmt.c +1 -1
index 59b5531..6688129 100644
@@ -207,7 +207,7 @@ static void hmt_bl_exit(struct device *dev)
 	.ecc_mode       = NAND_ECC_SOFT,
 };
 
-static struct gpio_led hmt_leds[] = {
+static const struct gpio_led hmt_leds[] __initconst = {
 	{ /* left function keys */
 		.name			= "left:blue",
 		.gpio			= S3C64XX_GPO(12),
arch/arm/mach-s3c64xx/mach-smartq5.c +1 -1
index 0972b6c..fc0bf33 100644
@@ -35,7 +35,7 @@
 #include "common.h"
 #include "mach-smartq.h"
 
-static struct gpio_led smartq5_leds[] = {
+static const struct gpio_led smartq5_leds[] __initconst = {
 	{
 		.name			= "smartq5:green",
 		.active_low		= 1,
arch/arm/mach-s3c64xx/mach-smartq7.c +1 -1
index 51ac1c6..016e03b 100644
@@ -35,7 +35,7 @@
 #include "common.h"
 #include "mach-smartq.h"
 
-static struct gpio_led smartq7_leds[] = {
+static const struct gpio_led smartq7_leds[] __initconst = {
 	{
 		.name			= "smartq7:red",
 		.active_low		= 1,
arch/arm/mach-s3c64xx/mach-smdk6410.c +1 -1
index 92ec8c3..6752dc5 100644
@@ -497,7 +497,7 @@ static int __init smdk6410_wm8350_init(struct wm8350 *wm8350)
 #endif
 
 #ifdef CONFIG_SMDK6410_WM1192_EV1
-static struct gpio_led wm1192_pmic_leds[] = {
+static const struct gpio_led wm1192_pmic_leds[] __initconst = {
 	{
 		.name = "PMIC:red:power",
 		.gpio = GPIO_BOARD_START + 3,
Signature · 1 line
1.9.1
#13 lore raw

PATCH 11/11 ARM: pxa: constify gpio_led

In reply to Arvind Yadav

gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by <linux/leds.h>. So mark the non-const structs as const.

---
 arch/arm/mach-pxa/balloon3.c  | 4 ++--
 arch/arm/mach-pxa/corgi.c     | 2 +-
 arch/arm/mach-pxa/csb701.c    | 2 +-
 arch/arm/mach-pxa/magician.c  | 2 +-
 arch/arm/mach-pxa/mioa701.c   | 2 +-
 arch/arm/mach-pxa/palmld.c    | 2 +-
 arch/arm/mach-pxa/palmz72.c   | 2 +-
 arch/arm/mach-pxa/pcm027.c    | 2 +-
 arch/arm/mach-pxa/raumfeld.c  | 4 ++--
 arch/arm/mach-pxa/spitz.c     | 2 +-
 arch/arm/mach-pxa/stargate2.c | 2 +-
 arch/arm/mach-pxa/tosa.c      | 2 +-
 arch/arm/mach-pxa/trizeps4.c  | 2 +-
 arch/arm/mach-pxa/zeus.c      | 2 +-
 14 files changed, 16 insertions(+), 16 deletions(-)
arch/arm/mach-pxa/balloon3.c +2 -2
index d6d92f3..4413829 100644
@@ -387,7 +387,7 @@ static inline void balloon3_uhc_init(void) {}
 	GPIO10_GPIO,	/* Heartbeat LED */
 };
 
-struct gpio_led balloon3_gpio_leds[] = {
+struct const gpio_led balloon3_gpio_leds[] __initconst = {
 	{
 		.name			= "balloon3:green:idle",
 		.default_trigger	= "heartbeat",
@@ -414,7 +414,7 @@ struct gpio_led balloon3_gpio_leds[] = {
 	}
 };
 
-struct gpio_led balloon3_pcf_gpio_leds[] = {
+const struct gpio_led balloon3_pcf_gpio_leds[] __initconst = {
 	{
 		.name			= "balloon3:green:led0",
 		.gpio			= BALLOON3_PCF_GPIO_LED0,
arch/arm/mach-pxa/corgi.c +1 -1
index 7270f0db..b0e0d3b 100644
@@ -450,7 +450,7 @@ struct platform_device corgiscoop_device = {
 /*
  * Corgi LEDs
  */
-static struct gpio_led corgi_gpio_leds[] = {
+static const struct gpio_led corgi_gpio_leds[] __initconst = {
 	{
 		.name			= "corgi:amber:charge",
 		.default_trigger	= "sharpsl-charge",
arch/arm/mach-pxa/csb701.c +1 -1
index 527c9fd..ff52892 100644
@@ -24,7 +24,7 @@
 	.nbuttons = ARRAY_SIZE(csb701_buttons),
 };
 
-static struct gpio_led csb701_leds[] = {
+static const struct gpio_led csb701_leds[] __initconst = {
 	{
 		.name	= "csb701:yellow:heartbeat",
 		.default_trigger = "heartbeat",
arch/arm/mach-pxa/magician.c +1 -1
index 7f3566c..505d1e3 100644
@@ -424,7 +424,7 @@ static void magician_backlight_exit(struct device *dev)
  * GPIO LEDs, Phone keys backlight, vibra
  */
 
-static struct gpio_led gpio_leds[] = {
+static const struct gpio_led gpio_leds[] __initconst = {
 	{
 		.name = "magician::vibra",
 		.default_trigger = "none",
arch/arm/mach-pxa/mioa701.c +1 -1
index 8a5d049..e3d2248 100644
@@ -274,7 +274,7 @@ static void mioa701_lcd_power(int on, struct fb_var_screeninfo *si)
  */
 #define ONE_LED(_gpio, _name) \
 { .gpio = (_gpio), .name = (_name), .active_low = true }
-static struct gpio_led gpio_leds[] = {
+static const struct gpio_led gpio_leds[] __initconst = {
 	ONE_LED(GPIO10_LED_nCharging, "mioa701:charging"),
 	ONE_LED(GPIO97_LED_nBlue, "mioa701:blue"),
 	ONE_LED(GPIO98_LED_nOrange, "mioa701:orange"),
arch/arm/mach-pxa/palmld.c +1 -1
index 980f284..37239f4 100644
@@ -246,7 +246,7 @@ static inline void palmld_keys_init(void) {}
  * LEDs
  ******************************************************************************/
 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
-struct gpio_led gpio_leds[] = {
+struct const gpio_led gpio_leds[] __initconst = {
 {
 	.name			= "palmld:green:led",
 	.default_trigger	= "none",
arch/arm/mach-pxa/palmz72.c +1 -1
index 5877e54..acacadb 100644
@@ -182,7 +182,7 @@ static inline void palmz72_kpc_init(void) {}
  * LEDs
  ******************************************************************************/
 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
-static struct gpio_led gpio_leds[] = {
+static const struct gpio_led gpio_leds[] __initconst = {
 	{
 		.name			= "palmz72:green:led",
 		.default_trigger	= "none",
arch/arm/mach-pxa/pcm027.c +1 -1
index ccca9f7..face4c8 100644
@@ -177,7 +177,7 @@
 
 #ifdef CONFIG_LEDS_GPIO
 
-static struct gpio_led pcm027_led[] = {
+static const struct gpio_led pcm027_led[] __initconst = {
 	{
 		.name = "led0:red",	/* FIXME */
 		.gpio = PCM027_LED_CPU
arch/arm/mach-pxa/raumfeld.c +2 -2
index 9d662fe..633c74d 100644
@@ -468,7 +468,7 @@
  * GPIO LEDs
  */
 
-static struct gpio_led raumfeld_leds[] = {
+static const struct gpio_led raumfeld_leds[] __initconst = {
 	{
 		.name		= "raumfeld:1",
 		.gpio		= GPIO_LED1,
@@ -558,7 +558,7 @@ static void __init raumfeld_w1_init(void)
 };
 
 /* LT3593 controlled backlight */
-static struct gpio_led raumfeld_lt3593_led = {
+static const struct gpio_led raumfeld_lt3593_led __initconst = {
 	.name		= "backlight",
 	.gpio		= mfp_to_gpio(MFP_PIN_GPIO17),
 	.default_state	= LEDS_GPIO_DEFSTATE_ON,
arch/arm/mach-pxa/spitz.c +1 -1
index 67d66c7..d24be35 100644
@@ -456,7 +456,7 @@ static inline void spitz_keys_init(void) {}
  * LEDs
  ******************************************************************************/
 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
-static struct gpio_led spitz_gpio_leds[] = {
+static const struct gpio_led spitz_gpio_leds[] __initconst = {
 	{
 		.name			= "spitz:amber:charge",
 		.default_trigger	= "sharpsl-charge",
arch/arm/mach-pxa/stargate2.c +1 -1
index 6b7df6f..3704d6c 100644
@@ -441,7 +441,7 @@ static int imote2_mci_get_ro(struct device *dev)
 	.gpio_power = -1,
 };
 
-static struct gpio_led imote2_led_pins[] = {
+static const struct gpio_led imote2_led_pins[] __initconst = {
 	{
 		.name       =  "imote2:red",
 		.gpio       = 103,
arch/arm/mach-pxa/tosa.c +1 -1
index 6a386fd..d306b96 100644
@@ -548,7 +548,7 @@ static void tosa_irda_shutdown(struct device *dev)
 /*
  * Tosa LEDs
  */
-static struct gpio_led tosa_gpio_leds[] = {
+static const struct gpio_led tosa_gpio_leds[] __initconst = {
 	{
 		.name			= "tosa:amber:charge",
 		.default_trigger	= "main-battery-charging",
arch/arm/mach-pxa/trizeps4.c +1 -1
index 3dd13b4..4f95c03 100644
@@ -235,7 +235,7 @@
 /****************************************************************************
  * LED's on GPIO pins of PXA
  ****************************************************************************/
-static struct gpio_led trizeps4_led[] = {
+static const struct gpio_led trizeps4_led[] __initconst = {
 #ifdef STATUS_LEDS_ON_STUART_PINS
 	{
 		.name = "led0:orange:heartbeat",	/* */
arch/arm/mach-pxa/zeus.c +1 -1
index ecbcaee..8ceafd7 100644
@@ -438,7 +438,7 @@ static void __init zeus_init_irq(void)
 };
 
 /* Leds */
-static struct gpio_led zeus_leds[] = {
+static const struct gpio_led zeus_leds[] __initconst = {
 	[0] = {
 		.name		 = "zeus:yellow:1",
 		.default_trigger = "heartbeat",
Signature · 1 line
1.9.1
#14 lore raw

Re: [PATCH 11/11] ARM: pxa: constify gpio_led

Thank you for the patch! Yet something to improve:

Hi Arvind,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on arm-soc/for-next]
[also build test ERROR on v4.15-rc5 next-20171222]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Arvind-Yadav/constify-gpio_led/20171223-142117
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc.git for-next
config: arm-pxa_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm

All error/warnings (new ones prefixed by >>):

>> arch/arm/mach-pxa/balloon3.c:390:8: error: expected '{' before 'const'
    struct const gpio_led balloon3_gpio_leds[] __initconst = {
           ^~~~~
>> arch/arm/mach-pxa/balloon3.c:405:11: error: 'balloon3_gpio_leds' undeclared here (not in a function); did you mean 'balloon3_gpio_led_info'?
     .leds  = balloon3_gpio_leds,
              ^~~~~~~~~~~~~~~~~~
              balloon3_gpio_led_info
   In file included from include/linux/kernel.h:15:0,
                    from include/linux/list.h:9,
                    from include/linux/kobject.h:20,
                    from include/linux/device.h:17,
                    from include/linux/platform_device.h:14,
                    from arch/arm/mach-pxa/balloon3.c:18:
>> include/linux/build_bug.h:30:45: error: bit-field '<anonymous>' width not an integer constant
    #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
                                                ^
   include/linux/compiler-gcc.h:65:28: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
    #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
                               ^~~~~~~~~~~~~~~~~
   include/linux/kernel.h:71:59: note: in expansion of macro '__must_be_array'
    #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
                                                              ^~~~~~~~~~~~~~~
>> arch/arm/mach-pxa/balloon3.c:406:14: note: in expansion of macro 'ARRAY_SIZE'
     .num_leds = ARRAY_SIZE(balloon3_gpio_leds),
                 ^~~~~~~~~~
--
>> arch/arm/mach-pxa/palmld.c:249:8: error: expected '{' before 'const'
    struct const gpio_led gpio_leds[] __initconst = {
           ^~~~~
>> arch/arm/mach-pxa/palmld.c:262:11: error: 'gpio_leds' undeclared here (not in a function); did you mean 'gpio_led'?
     .leds  = gpio_leds,
              ^~~~~~~~~
              gpio_led
   In file included from include/linux/kernel.h:15:0,
                    from include/linux/list.h:9,
                    from include/linux/kobject.h:20,
                    from include/linux/device.h:17,
                    from include/linux/platform_device.h:14,
                    from arch/arm/mach-pxa/palmld.c:17:
>> include/linux/build_bug.h:30:45: error: bit-field '<anonymous>' width not an integer constant
    #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
                                                ^
   include/linux/compiler-gcc.h:65:28: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
    #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
                               ^~~~~~~~~~~~~~~~~
   include/linux/kernel.h:71:59: note: in expansion of macro '__must_be_array'
    #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
                                                              ^~~~~~~~~~~~~~~
>> arch/arm/mach-pxa/palmld.c:263:14: note: in expansion of macro 'ARRAY_SIZE'

.num_leds = ARRAY_SIZE(gpio_leds),
^~~~~~~~~~

vim +390 arch/arm/mach-pxa/balloon3.c

389

 > 390	struct const gpio_led balloon3_gpio_leds[] __initconst = {
   391		{
   392			.name			= "balloon3:green:idle",
   393			.default_trigger	= "heartbeat",
   394			.gpio			= BALLOON3_GPIO_LED_IDLE,
   395			.active_low		= 1,
   396		}, {
   397			.name			= "balloon3:green:nand",
   398			.default_trigger	= "nand-disk",
   399			.gpio			= BALLOON3_GPIO_LED_NAND,
   400			.active_low		= 1,
   401		},
   402	};
   403	
   404	static struct gpio_led_platform_data balloon3_gpio_led_info = {
 > 405		.leds		= balloon3_gpio_leds,
 > 406		.num_leds	= ARRAY_SIZE(balloon3_gpio_leds),

407 };
408

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

author
#15 lore raw

Re: [PATCH 11/11] ARM: pxa: constify gpio_led

Hi,

Sorry for trouble, I will send updated patch.

Quoted 98 lines · kbuild test robot

Hi Arvind,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on arm-soc/for-next]
[also build test ERROR on v4.15-rc5 next-20171222]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Arvind-Yadav/constify-gpio_led/20171223-142117
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc.git for-next
config: arm-pxa_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm

All error/warnings (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

arch/arm/mach-pxa/balloon3.c:390:8: error: expected '{' before 'const'

     struct const gpio_led balloon3_gpio_leds[] __initconst = {
            ^~~~~
Quoted 1 line
Quoted 1 line

arch/arm/mach-pxa/balloon3.c:405:11: error: 'balloon3_gpio_leds' undeclared here (not in a function); did you mean 'balloon3_gpio_led_info'?

.leds = balloon3_gpio_leds,
^~~~~~~~~~~~~~~~~~ balloon3_gpio_led_info
In file included from include/linux/kernel.h:15:0,
from include/linux/list.h:9, from include/linux/kobject.h:20, from include/linux/device.h:17, from include/linux/platform_device.h:14, from arch/arm/mach-pxa/balloon3.c:18:

Quoted 1 line
Quoted 1 line

include/linux/build_bug.h:30:45: error: bit-field '<anonymous>' width not an integer constant

     #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
                                                 ^
    include/linux/compiler-gcc.h:65:28: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
     #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
                                ^~~~~~~~~~~~~~~~~
    include/linux/kernel.h:71:59: note: in expansion of macro '__must_be_array'
     #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
                                                               ^~~~~~~~~~~~~~~
Quoted 1 line
Quoted 1 line

arch/arm/mach-pxa/balloon3.c:406:14: note: in expansion of macro 'ARRAY_SIZE'

.num_leds = ARRAY_SIZE(balloon3_gpio_leds),
^~~~~~~~~~
--

Quoted 1 line
Quoted 1 line

arch/arm/mach-pxa/palmld.c:249:8: error: expected '{' before 'const'

     struct const gpio_led gpio_leds[] __initconst = {
            ^~~~~
Quoted 1 line
Quoted 1 line

arch/arm/mach-pxa/palmld.c:262:11: error: 'gpio_leds' undeclared here (not in a function); did you mean 'gpio_led'?

.leds = gpio_leds,
^~~~~~~~~
gpio_led
In file included from include/linux/kernel.h:15:0,
from include/linux/list.h:9, from include/linux/kobject.h:20, from include/linux/device.h:17, from include/linux/platform_device.h:14, from arch/arm/mach-pxa/palmld.c:17:

Quoted 1 line
Quoted 1 line

include/linux/build_bug.h:30:45: error: bit-field '<anonymous>' width not an integer constant

     #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
                                                 ^
    include/linux/compiler-gcc.h:65:28: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
     #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
                                ^~~~~~~~~~~~~~~~~
    include/linux/kernel.h:71:59: note: in expansion of macro '__must_be_array'
     #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
                                                               ^~~~~~~~~~~~~~~
Quoted 1 line
Quoted 1 line

arch/arm/mach-pxa/palmld.c:263:14: note: in expansion of macro 'ARRAY_SIZE'

.num_leds = ARRAY_SIZE(gpio_leds),
^~~~~~~~~~

vim +390 arch/arm/mach-pxa/balloon3.c

    389	
Quoted 1 line

390 struct const gpio_led balloon3_gpio_leds[] __initconst = {

    391		{
    392			.name			= "balloon3:green:idle",
    393			.default_trigger	= "heartbeat",
    394			.gpio			= BALLOON3_GPIO_LED_IDLE,
    395			.active_low		= 1,
    396		}, {
    397			.name			= "balloon3:green:nand",
    398			.default_trigger	= "nand-disk",
    399			.gpio			= BALLOON3_GPIO_LED_NAND,
    400			.active_low		= 1,
    401		},
    402	};
    403	
    404	static struct gpio_led_platform_data balloon3_gpio_led_info = {
Quoted 2 lines

405 .leds = balloon3_gpio_leds,
406 .num_leds = ARRAY_SIZE(balloon3_gpio_leds),

    407	};
    408	

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#16 lore raw
In reply to Arvind Yadav
Quoted 4 lines · Arvind Yadav

gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by <linux/leds.h>. So mark the non-const structs as const.

Marking the structs as const is fine, but marking them __initconst is not. The GPIO LED driver can be built as a module, which means it can be loaded after the init sections have gone away. If that happens, then we de-reference the pointer to memory that has been freed.

Please re-spin your patch set without the __initconst marking.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up
author
#17 lore raw

Hi Ressell,

Quoted 5 lines · Russell King - ARM Linux
Quoted 4 lines · Arvind Yadav

gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by <linux/leds.h>. So mark the non-const structs as const.

Quoted 7 lines

Marking the structs as const is fine, but marking them __initconst is not. The GPIO LED driver can be built as a module, which means it can be loaded after the init sections have gone away. If that happens, then we de-reference the pointer to memory that has been freed.

Please re-spin your patch set without the __initconst marking.

Thanks for reviewing, As per your comment, I will send updated patch. Which will not include __initconst.

~arvind