Skip to contentSkip to conversation

drivers/hid/hid-nintendo.c:371:13: error: initializer element is not constant

PATCH Applied kernel test robot 4 participants 4 messages Dec 14, 2023 – Dec 18, 2023

Subsystems (3)
lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   48e8992e33abf054bcc0bb2e77b2d43bb899212e
commit: 94f18bb19945915fcdfd1903841020ef1b6af44a [6722/7300] HID: nintendo: add support for nso controllers
config: x86_64-randconfig-016-20231214 (https://download.01.org/0day-ci/archive/20231214/[email protected]/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231214/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/hid/hid-nintendo.c:371:13: error: initializer element is not constant
     { BTN_TL,  JC_BTN_L, },
                ^~~~~~~~
   drivers/hid/hid-nintendo.c:371:13: note: (near initialization for 'left_joycon_button_mappings[0].bit')
   drivers/hid/hid-nintendo.c:372:14: error: initializer element is not constant
     { BTN_TL2,  JC_BTN_ZL, },
                 ^~~~~~~~~
   drivers/hid/hid-nintendo.c:372:14: note: (near initialization for 'left_joycon_button_mappings[1].bit')
   drivers/hid/hid-nintendo.c:373:17: error: initializer element is not constant
     { BTN_SELECT,  JC_BTN_MINUS, },
                    ^~~~~~~~~~~~
   drivers/hid/hid-nintendo.c:373:17: note: (near initialization for 'left_joycon_button_mappings[2].bit')
   drivers/hid/hid-nintendo.c:374:17: error: initializer element is not constant
     { BTN_THUMBL,  JC_BTN_LSTICK, },
                    ^~~~~~~~~~~~~
   drivers/hid/hid-nintendo.c:374:17: note: (near initialization for 'left_joycon_button_mappings[3].bit')
   drivers/hid/hid-nintendo.c:375:18: error: initializer element is not constant
     { BTN_DPAD_UP,  JC_BTN_UP, },
                     ^~~~~~~~~
   drivers/hid/hid-nintendo.c:375:18: note: (near initialization for 'left_joycon_button_mappings[4].bit')
   drivers/hid/hid-nintendo.c:376:19: error: initializer element is not constant
     { BTN_DPAD_DOWN, JC_BTN_DOWN, },
                      ^~~~~~~~~~~
   drivers/hid/hid-nintendo.c:376:19: note: (near initialization for 'left_joycon_button_mappings[5].bit')
   drivers/hid/hid-nintendo.c:377:19: error: initializer element is not constant
     { BTN_DPAD_LEFT, JC_BTN_LEFT, },
                      ^~~~~~~~~~~
   drivers/hid/hid-nintendo.c:377:19: note: (near initialization for 'left_joycon_button_mappings[6].bit')
   drivers/hid/hid-nintendo.c:378:20: error: initializer element is not constant
     { BTN_DPAD_RIGHT, JC_BTN_RIGHT, },
                       ^~~~~~~~~~~~
   drivers/hid/hid-nintendo.c:378:20: note: (near initialization for 'left_joycon_button_mappings[7].bit')
   drivers/hid/hid-nintendo.c:379:12: error: initializer element is not constant
     { BTN_Z,  JC_BTN_CAP, },
               ^~~~~~~~~~
   drivers/hid/hid-nintendo.c:379:12: note: (near initialization for 'left_joycon_button_mappings[8].bit')
   drivers/hid/hid-nintendo.c:388:12: error: initializer element is not constant
     { BTN_TR, JC_BTN_SL_L, },
               ^~~~~~~~~~~
   drivers/hid/hid-nintendo.c:388:12: note: (near initialization for 'left_joycon_s_button_mappings[0].bit')
   drivers/hid/hid-nintendo.c:389:13: error: initializer element is not constant
     { BTN_TR2, JC_BTN_SR_L, },
                ^~~~~~~~~~~
   drivers/hid/hid-nintendo.c:389:13: note: (near initialization for 'left_joycon_s_button_mappings[1].bit')
   drivers/hid/hid-nintendo.c:394:14: error: initializer element is not constant
     { BTN_EAST, JC_BTN_A, },
                 ^~~~~~~~
   drivers/hid/hid-nintendo.c:394:14: note: (near initialization for 'right_joycon_button_mappings[0].bit')
   drivers/hid/hid-nintendo.c:395:15: error: initializer element is not constant
     { BTN_SOUTH, JC_BTN_B, },
                  ^~~~~~~~
   drivers/hid/hid-nintendo.c:395:15: note: (near initialization for 'right_joycon_button_mappings[1].bit')
   drivers/hid/hid-nintendo.c:396:15: error: initializer element is not constant
     { BTN_NORTH, JC_BTN_X, },
                  ^~~~~~~~
   drivers/hid/hid-nintendo.c:396:15: note: (near initialization for 'right_joycon_button_mappings[2].bit')
   drivers/hid/hid-nintendo.c:397:14: error: initializer element is not constant
     { BTN_WEST, JC_BTN_Y, },
                 ^~~~~~~~
   drivers/hid/hid-nintendo.c:397:14: note: (near initialization for 'right_joycon_button_mappings[3].bit')
   drivers/hid/hid-nintendo.c:398:12: error: initializer element is not constant
     { BTN_TR, JC_BTN_R, },
               ^~~~~~~~
   drivers/hid/hid-nintendo.c:398:12: note: (near initialization for 'right_joycon_button_mappings[4].bit')
   drivers/hid/hid-nintendo.c:399:13: error: initializer element is not constant
     { BTN_TR2, JC_BTN_ZR, },
                ^~~~~~~~~
   drivers/hid/hid-nintendo.c:399:13: note: (near initialization for 'right_joycon_button_mappings[5].bit')
   drivers/hid/hid-nintendo.c:400:15: error: initializer element is not constant
     { BTN_START, JC_BTN_PLUS, },
                  ^~~~~~~~~~~
   drivers/hid/hid-nintendo.c:400:15: note: (near initialization for 'right_joycon_button_mappings[6].bit')
   drivers/hid/hid-nintendo.c:401:16: error: initializer element is not constant
     { BTN_THUMBR, JC_BTN_RSTICK, },
                   ^~~~~~~~~~~~~
   drivers/hid/hid-nintendo.c:401:16: note: (near initialization for 'right_joycon_button_mappings[7].bit')
   drivers/hid/hid-nintendo.c:402:14: error: initializer element is not constant
     { BTN_MODE, JC_BTN_HOME, },
                 ^~~~~~~~~~~
   drivers/hid/hid-nintendo.c:402:14: note: (near initialization for 'right_joycon_button_mappings[8].bit')
   drivers/hid/hid-nintendo.c:411:12: error: initializer element is not constant
     { BTN_TL, JC_BTN_SL_R, },
               ^~~~~~~~~~~
   drivers/hid/hid-nintendo.c:411:12: note: (near initialization for 'right_joycon_s_button_mappings[0].bit')
   drivers/hid/hid-nintendo.c:412:13: error: initializer element is not constant
     { BTN_TL2, JC_BTN_SR_R, },
                ^~~~~~~~~~~
   drivers/hid/hid-nintendo.c:412:13: note: (near initialization for 'right_joycon_s_button_mappings[1].bit')
   drivers/hid/hid-nintendo.c:417:14: error: initializer element is not constant
     { BTN_EAST, JC_BTN_A, },
                 ^~~~~~~~
   drivers/hid/hid-nintendo.c:417:14: note: (near initialization for 'procon_button_mappings[0].bit')
   drivers/hid/hid-nintendo.c:418:15: error: initializer element is not constant
     { BTN_SOUTH, JC_BTN_B, },
                  ^~~~~~~~
   drivers/hid/hid-nintendo.c:418:15: note: (near initialization for 'procon_button_mappings[1].bit')
   drivers/hid/hid-nintendo.c:419:15: error: initializer element is not constant
     { BTN_NORTH, JC_BTN_X, },
                  ^~~~~~~~

drivers/hid/hid-nintendo.c:419:15: note: (near initialization for 'procon_button_mappings[2].bit') drivers/hid/hid-nintendo.c:420:14: error: initializer element is not constant

vim +371 drivers/hid/hid-nintendo.c

366
367 /*
368 * D-pad is configured as buttons for the left Joy-Con only!
369 */
370 static const struct joycon_ctlr_button_mapping left_joycon_button_mappings[] = {

 > 371		{ BTN_TL,		JC_BTN_L,	},

372 { BTN_TL2, JC_BTN_ZL, },
373 { BTN_SELECT, JC_BTN_MINUS, },
374 { BTN_THUMBL, JC_BTN_LSTICK, },
375 { BTN_DPAD_UP, JC_BTN_UP, },
376 { BTN_DPAD_DOWN, JC_BTN_DOWN, },
377 { BTN_DPAD_LEFT, JC_BTN_LEFT, },
378 { BTN_DPAD_RIGHT, JC_BTN_RIGHT, },
379 { BTN_Z, JC_BTN_CAP, },
380 { /* sentinel */ },
381 };
382

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#1 lore raw

PATCH 1/1 HID: nintendo: fix initializer element is not constant error

With gcc-7 builds, an error happens with the controller button values being defined as const. Change to a define.

---
 drivers/hid/hid-nintendo.c | 44 +++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 22 deletions(-)
drivers/hid/hid-nintendo.c +22 -22
index 47af111ef3a2..2987083785f9 100644
@@ -336,28 +336,28 @@ struct joycon_imu_cal {
  * All the controller's button values are stored in a u32.
  * They can be accessed with bitwise ANDs.
  */
-static const u32 JC_BTN_Y	= BIT(0);
-static const u32 JC_BTN_X	= BIT(1);
-static const u32 JC_BTN_B	= BIT(2);
-static const u32 JC_BTN_A	= BIT(3);
-static const u32 JC_BTN_SR_R	= BIT(4);
-static const u32 JC_BTN_SL_R	= BIT(5);
-static const u32 JC_BTN_R	= BIT(6);
-static const u32 JC_BTN_ZR	= BIT(7);
-static const u32 JC_BTN_MINUS	= BIT(8);
-static const u32 JC_BTN_PLUS	= BIT(9);
-static const u32 JC_BTN_RSTICK	= BIT(10);
-static const u32 JC_BTN_LSTICK	= BIT(11);
-static const u32 JC_BTN_HOME	= BIT(12);
-static const u32 JC_BTN_CAP	= BIT(13); /* capture button */
-static const u32 JC_BTN_DOWN	= BIT(16);
-static const u32 JC_BTN_UP	= BIT(17);
-static const u32 JC_BTN_RIGHT	= BIT(18);
-static const u32 JC_BTN_LEFT	= BIT(19);
-static const u32 JC_BTN_SR_L	= BIT(20);
-static const u32 JC_BTN_SL_L	= BIT(21);
-static const u32 JC_BTN_L	= BIT(22);
-static const u32 JC_BTN_ZL	= BIT(23);
+#define JC_BTN_Y	 BIT(0)
+#define JC_BTN_X	 BIT(1)
+#define JC_BTN_B	 BIT(2)
+#define JC_BTN_A	 BIT(3)
+#define JC_BTN_SR_R	 BIT(4)
+#define JC_BTN_SL_R	 BIT(5)
+#define JC_BTN_R	 BIT(6)
+#define JC_BTN_ZR	 BIT(7)
+#define JC_BTN_MINUS	 BIT(8)
+#define JC_BTN_PLUS	 BIT(9)
+#define JC_BTN_RSTICK	 BIT(10)
+#define JC_BTN_LSTICK	 BIT(11)
+#define JC_BTN_HOME	 BIT(12)
+#define JC_BTN_CAP	 BIT(13) /* capture button */
+#define JC_BTN_DOWN	 BIT(16)
+#define JC_BTN_UP	 BIT(17)
+#define JC_BTN_RIGHT	 BIT(18)
+#define JC_BTN_LEFT	 BIT(19)
+#define JC_BTN_SR_L	 BIT(20)
+#define JC_BTN_SL_L	 BIT(21)
+#define JC_BTN_L	 BIT(22)
+#define JC_BTN_ZL	 BIT(23)
 
 struct joycon_ctlr_button_mapping {
 	u32 code;
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 1/1
#2 lore raw

Re: [PATCH] HID: nintendo: fix initializer element is not constant error

Hi Ryan,

Quoted 68 lines · Ryan McClelland

With gcc-7 builds, an error happens with the controller button values being defined as const. Change to a define.

---
 drivers/hid/hid-nintendo.c | 44 +++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 22 deletions(-)
drivers/hid/hid-nintendo.c +22 -23
index 47af111ef3a2..2987083785f9 100644
@@ -336,28 +336,28 @@ struct joycon_imu_cal {
  * All the controller's button values are stored in a u32.
  * They can be accessed with bitwise ANDs.
  */
-static const u32 JC_BTN_Y      = BIT(0);
-static const u32 JC_BTN_X      = BIT(1);
-static const u32 JC_BTN_B      = BIT(2);
-static const u32 JC_BTN_A      = BIT(3);
-static const u32 JC_BTN_SR_R   = BIT(4);
-static const u32 JC_BTN_SL_R   = BIT(5);
-static const u32 JC_BTN_R      = BIT(6);
-static const u32 JC_BTN_ZR     = BIT(7);
-static const u32 JC_BTN_MINUS  = BIT(8);
-static const u32 JC_BTN_PLUS   = BIT(9);
-static const u32 JC_BTN_RSTICK = BIT(10);
-static const u32 JC_BTN_LSTICK = BIT(11);
-static const u32 JC_BTN_HOME   = BIT(12);
-static const u32 JC_BTN_CAP    = BIT(13); /* capture button */
-static const u32 JC_BTN_DOWN   = BIT(16);
-static const u32 JC_BTN_UP     = BIT(17);
-static const u32 JC_BTN_RIGHT  = BIT(18);
-static const u32 JC_BTN_LEFT   = BIT(19);
-static const u32 JC_BTN_SR_L   = BIT(20);
-static const u32 JC_BTN_SL_L   = BIT(21);
-static const u32 JC_BTN_L      = BIT(22);
-static const u32 JC_BTN_ZL     = BIT(23);
+#define JC_BTN_Y        BIT(0)
+#define JC_BTN_X        BIT(1)
+#define JC_BTN_B        BIT(2)
+#define JC_BTN_A        BIT(3)
+#define JC_BTN_SR_R     BIT(4)
+#define JC_BTN_SL_R     BIT(5)
+#define JC_BTN_R        BIT(6)
+#define JC_BTN_ZR       BIT(7)
+#define JC_BTN_MINUS    BIT(8)
+#define JC_BTN_PLUS     BIT(9)
+#define JC_BTN_RSTICK   BIT(10)
+#define JC_BTN_LSTICK   BIT(11)
+#define JC_BTN_HOME     BIT(12)
+#define JC_BTN_CAP      BIT(13) /* capture button */
+#define JC_BTN_DOWN     BIT(16)
+#define JC_BTN_UP       BIT(17)
+#define JC_BTN_RIGHT    BIT(18)
+#define JC_BTN_LEFT     BIT(19)
+#define JC_BTN_SR_L     BIT(20)
+#define JC_BTN_SL_L     BIT(21)
+#define JC_BTN_L        BIT(22)
+#define JC_BTN_ZL       BIT(23)
 
 struct joycon_ctlr_button_mapping {
        u32 code;
--
Quoted 2 lines

2.25.1

Thanks for the quick fix.

-Daniel

Applied
#3 lore raw

Re: [PATCH] HID: nintendo: fix initializer element is not constant error

In reply to Ryan McClelland
Quoted 7 lines · Ryan McClelland

With gcc-7 builds, an error happens with the controller button values being defined as const. Change to a define.

Applied, thanks.

Signature · 2 lines
Jiri Kosina
SUSE Labs