All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: drivers/hid/hid-nintendo.c:616:16: warning: Value stored to 'msecs' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
Date: Wed, 17 Nov 2021 09:14:37 +0800	[thread overview]
Message-ID: <202111170931.dfCeaRsD-lkp@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 25389 bytes --]

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: "Daniel J. Ogorchock" <djogorchock@gmail.com>
CC: Jiri Kosina <jkosina@suse.cz>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   8ab774587903771821b59471cc723bba6d893942
commit: c4eae84feff3e68c2f385aa10faea4a96791e7ad HID: nintendo: add rumble support
date:   3 weeks ago
:::::: branch date: 2 days ago
:::::: commit date: 3 weeks ago
config: riscv-randconfig-c006-20211104 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 847a6807332b13f43704327c2d30103ec0347c77)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c4eae84feff3e68c2f385aa10faea4a96791e7ad
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout c4eae84feff3e68c2f385aa10faea4a96791e7ad
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)
                                    ^
   kernel/torture.c:342:2: note: Assuming 'cpu' is >= 'nr_cpu_ids'
           for_each_online_cpu(cpu)
           ^
   include/linux/cpumask.h:789:36: note: expanded from macro 'for_each_online_cpu'
   #define for_each_online_cpu(cpu)   for_each_cpu((cpu), cpu_online_mask)
                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/cpumask.h:243:3: note: expanded from macro 'for_each_cpu'
                   (cpu) < nr_cpu_ids;)
                   ^~~~~~~~~~~~~~~~~~
   kernel/torture.c:342:2: note: Loop condition is false. Execution continues on line 344
           for_each_online_cpu(cpu)
           ^
   include/linux/cpumask.h:789:36: note: expanded from macro 'for_each_online_cpu'
   #define for_each_online_cpu(cpu)   for_each_cpu((cpu), cpu_online_mask)
                                      ^
   include/linux/cpumask.h:241:2: note: expanded from macro 'for_each_cpu'
           for ((cpu) = -1;                                \
           ^
   kernel/torture.c:344:2: note: Taking true branch
           WARN_ON(maxcpu < 0);
           ^
   include/asm-generic/bug.h:122:2: note: expanded from macro 'WARN_ON'
           if (unlikely(__ret_warn_on))                                    \
           ^
   kernel/torture.c:344:2: note: Loop condition is false.  Exiting loop
           WARN_ON(maxcpu < 0);
           ^
   include/asm-generic/bug.h:123:3: note: expanded from macro 'WARN_ON'
                   __WARN();                                               \
                   ^
   include/asm-generic/bug.h:96:19: note: expanded from macro '__WARN'
   #define __WARN()                __WARN_FLAGS(BUGFLAG_TAINT(TAINT_WARN))
                                   ^
   arch/riscv/include/asm/bug.h:79:29: note: expanded from macro '__WARN_FLAGS'
   #define __WARN_FLAGS(flags) __BUG_FLAGS(BUGFLAG_WARNING|(flags))
                               ^
   arch/riscv/include/asm/bug.h:53:32: note: expanded from macro '__BUG_FLAGS'
   #define __BUG_FLAGS(flags)                                      \
                                                                   ^
   kernel/torture.c:346:6: note: 'maxcpu' is not equal to 0
           if (maxcpu == 0) {
               ^~~~~~
   kernel/torture.c:346:2: note: Taking false branch
           if (maxcpu == 0) {
           ^
   kernel/torture.c:351:6: note: Assuming 'onoff_holdoff' is <= 0
           if (onoff_holdoff > 0) {
               ^~~~~~~~~~~~~~~~~
   kernel/torture.c:351:2: note: Taking false branch
           if (onoff_holdoff > 0) {
           ^
   kernel/torture.c:356:10: note: Calling 'torture_must_stop'
           while (!torture_must_stop()) {
                   ^~~~~~~~~~~~~~~~~~~
   kernel/torture.c:889:9: note: Left side of '||' is false
           return torture_must_stop_irq() || kthread_should_stop();
                  ^
   kernel/torture.c:889:36: note: Value assigned to 'disable_onoff_at_boot', which participates in a condition later
           return torture_must_stop_irq() || kthread_should_stop();
                                             ^~~~~~~~~~~~~~~~~~~~~
   kernel/torture.c:889:2: note: Returning value, which participates in a condition later
           return torture_must_stop_irq() || kthread_should_stop();
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/torture.c:356:10: note: Returning from 'torture_must_stop'
           while (!torture_must_stop()) {
                   ^~~~~~~~~~~~~~~~~~~
   kernel/torture.c:356:9: note: Assuming the condition is true
           while (!torture_must_stop()) {
                  ^~~~~~~~~~~~~~~~~~~~
   kernel/torture.c:356:2: note: Loop condition is true.  Entering loop body
           while (!torture_must_stop()) {
           ^
   kernel/torture.c:357:7: note: Assuming 'disable_onoff_at_boot' is false
                   if (disable_onoff_at_boot && !rcu_inkernel_boot_has_ended()) {
                       ^~~~~~~~~~~~~~~~~~~~~
   kernel/torture.c:357:29: note: Left side of '&&' is false
                   if (disable_onoff_at_boot && !rcu_inkernel_boot_has_ended()) {
                                             ^
   kernel/torture.c:361:38: note: Division by zero
                   cpu = (torture_random(&rand) >> 4) % (maxcpu + 1);
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   10 warnings generated.
   Suppressed 10 warnings (10 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   46 warnings generated.
>> drivers/hid/hid-nintendo.c:616:16: warning: Value stored to 'msecs' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           unsigned long msecs = jiffies_to_msecs(jiffies);
                         ^~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hid/hid-nintendo.c:616:16: note: Value stored to 'msecs' during its initialization is never read
           unsigned long msecs = jiffies_to_msecs(jiffies);
                         ^~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~
   Suppressed 45 warnings (7 in non-user code, 38 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   8 warnings generated.
   include/linux/hid.h:1007:9: warning: Access to field 'name' results in a dereference of a null pointer (loaded from variable 'input') [clang-analyzer-core.NullDereference]
                                       input->name, c, type);
                                       ^
   drivers/hid/hid-petalynx.c:41:6: note: Assuming the condition is true
           if ((usage->hid & HID_USAGE_PAGE) == HID_UP_LOGIVENDOR) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hid/hid-petalynx.c:41:2: note: Taking true branch
           if ((usage->hid & HID_USAGE_PAGE) == HID_UP_LOGIVENDOR) {
           ^
   drivers/hid/hid-petalynx.c:42:3: note: Control jumps to 'case 90:'  at line 43
                   switch (usage->hid & HID_USAGE) {
                   ^
   drivers/hid/hid-petalynx.c:43:15: note: Calling 'hid_map_usage_clear'
                   case 0x05a: pl_map_key_clear(KEY_TEXT);         break;
                               ^
   drivers/hid/hid-petalynx.c:35:29: note: expanded from macro 'pl_map_key_clear'
   #define pl_map_key_clear(c)     hid_map_usage_clear(hi, usage, bit, max, \
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/hid.h:1035:2: note: Calling 'hid_map_usage'
           hid_map_usage(hidinput, usage, bit, max, type, c);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/hid.h:982:2: note: 'input' initialized here
           struct input_dev *input = hidinput->input;
           ^~~~~~~~~~~~~~~~~~~~~~~
   include/linux/hid.h:986:2: note: Control jumps to 'case 1:'  at line 995
           switch (type) {
           ^
   include/linux/hid.h:998:3: note:  Execution continues on line 1005
                   break;
                   ^
   include/linux/hid.h:1005:15: note: 'c' is <= 'limit'
           if (unlikely(c > limit || !bmap)) {
                        ^
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   include/linux/hid.h:1005:15: note: Left side of '||' is false
           if (unlikely(c > limit || !bmap)) {
                        ^
   include/linux/hid.h:1005:28: note: Assuming 'bmap' is null
           if (unlikely(c > limit || !bmap)) {
                                     ^
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   include/linux/hid.h:1005:28: note: Assuming pointer value is null
           if (unlikely(c > limit || !bmap)) {
                                     ^
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   include/linux/hid.h:1005:2: note: Taking true branch
           if (unlikely(c > limit || !bmap)) {
           ^
   include/linux/hid.h:1006:3: note: Assuming the condition is true
                   pr_warn_ratelimited("%s: Invalid code %d type %d\n",
                   ^
   include/linux/printk.h:656:2: note: expanded from macro 'pr_warn_ratelimited'
           printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/printk.h:639:6: note: expanded from macro 'printk_ratelimited'
           if (__ratelimit(&_rs))                                          \
               ^~~~~~~~~~~~~~~~~
   include/linux/ratelimit_types.h:41:28: note: expanded from macro '__ratelimit'
   #define __ratelimit(state) ___ratelimit(state, __func__)
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/hid.h:1006:3: note: Taking true branch
                   pr_warn_ratelimited("%s: Invalid code %d type %d\n",
                   ^
   include/linux/printk.h:656:2: note: expanded from macro 'pr_warn_ratelimited'
           printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
           ^
   include/linux/printk.h:639:2: note: expanded from macro 'printk_ratelimited'
           if (__ratelimit(&_rs))                                          \
           ^
   include/linux/hid.h:1006:3: note: Left side of '&&' is true
                   pr_warn_ratelimited("%s: Invalid code %d type %d\n",
                   ^
   include/linux/printk.h:656:2: note: expanded from macro 'pr_warn_ratelimited'
           printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
           ^
   include/linux/printk.h:640:3: note: expanded from macro 'printk_ratelimited'
                   printk(fmt, ##__VA_ARGS__);                             \
                   ^
   include/linux/printk.h:446:26: note: expanded from macro 'printk'
   #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)

vim +/msecs +616 drivers/hid/hid-nintendo.c

2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  607  
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  608  static void joycon_parse_report(struct joycon_ctlr *ctlr,
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  609  				struct joycon_input_report *rep)
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  610  {
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  611  	struct input_dev *dev = ctlr->input;
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  612  	unsigned long flags;
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  613  	u8 tmp;
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  614  	u32 btns;
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  615  	u32 id = ctlr->hdev->product;
c4eae84feff3e6 Daniel J. Ogorchock 2021-09-11 @616  	unsigned long msecs = jiffies_to_msecs(jiffies);
c4eae84feff3e6 Daniel J. Ogorchock 2021-09-11  617  
c4eae84feff3e6 Daniel J. Ogorchock 2021-09-11  618  	spin_lock_irqsave(&ctlr->lock, flags);
c4eae84feff3e6 Daniel J. Ogorchock 2021-09-11  619  	if (IS_ENABLED(CONFIG_NINTENDO_FF) && rep->vibrator_report &&
c4eae84feff3e6 Daniel J. Ogorchock 2021-09-11  620  	    (msecs - ctlr->rumble_msecs) >= JC_RUMBLE_PERIOD_MS)
c4eae84feff3e6 Daniel J. Ogorchock 2021-09-11  621  		queue_work(ctlr->rumble_queue, &ctlr->rumble_worker);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  622  
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  623  	/* Parse the battery status */
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  624  	tmp = rep->bat_con;
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  625  	ctlr->host_powered = tmp & BIT(0);
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  626  	ctlr->battery_charging = tmp & BIT(4);
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  627  	tmp = tmp >> 5;
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  628  	switch (tmp) {
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  629  	case 0: /* empty */
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  630  		ctlr->battery_capacity = POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL;
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  631  		break;
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  632  	case 1: /* low */
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  633  		ctlr->battery_capacity = POWER_SUPPLY_CAPACITY_LEVEL_LOW;
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  634  		break;
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  635  	case 2: /* medium */
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  636  		ctlr->battery_capacity = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL;
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  637  		break;
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  638  	case 3: /* high */
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  639  		ctlr->battery_capacity = POWER_SUPPLY_CAPACITY_LEVEL_HIGH;
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  640  		break;
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  641  	case 4: /* full */
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  642  		ctlr->battery_capacity = POWER_SUPPLY_CAPACITY_LEVEL_FULL;
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  643  		break;
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  644  	default:
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  645  		ctlr->battery_capacity = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN;
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  646  		hid_warn(ctlr->hdev, "Invalid battery status\n");
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  647  		break;
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  648  	}
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  649  	spin_unlock_irqrestore(&ctlr->lock, flags);
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  650  
08ebba5c270350 Daniel J. Ogorchock 2021-09-11  651  	/* Parse the buttons and sticks */
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  652  	btns = hid_field_extract(ctlr->hdev, rep->button_status, 0, 24);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  653  
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  654  	if (id != USB_DEVICE_ID_NINTENDO_JOYCONR) {
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  655  		u16 raw_x;
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  656  		u16 raw_y;
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  657  		s32 x;
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  658  		s32 y;
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  659  
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  660  		/* get raw stick values */
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  661  		raw_x = hid_field_extract(ctlr->hdev, rep->left_stick, 0, 12);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  662  		raw_y = hid_field_extract(ctlr->hdev,
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  663  					  rep->left_stick + 1, 4, 12);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  664  		/* map the stick values */
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  665  		x = joycon_map_stick_val(&ctlr->left_stick_cal_x, raw_x);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  666  		y = -joycon_map_stick_val(&ctlr->left_stick_cal_y, raw_y);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  667  		/* report sticks */
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  668  		input_report_abs(dev, ABS_X, x);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  669  		input_report_abs(dev, ABS_Y, y);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  670  
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  671  		/* report buttons */
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  672  		input_report_key(dev, BTN_TL, btns & JC_BTN_L);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  673  		input_report_key(dev, BTN_TL2, btns & JC_BTN_ZL);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  674  		input_report_key(dev, BTN_SELECT, btns & JC_BTN_MINUS);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  675  		input_report_key(dev, BTN_THUMBL, btns & JC_BTN_LSTICK);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  676  		input_report_key(dev, BTN_Z, btns & JC_BTN_CAP);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  677  
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  678  		if (id != USB_DEVICE_ID_NINTENDO_PROCON) {
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  679  			/* Report the S buttons as the non-existent triggers */
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  680  			input_report_key(dev, BTN_TR, btns & JC_BTN_SL_L);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  681  			input_report_key(dev, BTN_TR2, btns & JC_BTN_SR_L);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  682  
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  683  			/* Report d-pad as digital buttons for the joy-cons */
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  684  			input_report_key(dev, BTN_DPAD_DOWN,
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  685  					 btns & JC_BTN_DOWN);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  686  			input_report_key(dev, BTN_DPAD_UP, btns & JC_BTN_UP);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  687  			input_report_key(dev, BTN_DPAD_RIGHT,
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  688  					 btns & JC_BTN_RIGHT);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  689  			input_report_key(dev, BTN_DPAD_LEFT,
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  690  					 btns & JC_BTN_LEFT);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  691  		} else {
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  692  			int hatx = 0;
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  693  			int haty = 0;
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  694  
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  695  			/* d-pad x */
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  696  			if (btns & JC_BTN_LEFT)
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  697  				hatx = -1;
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  698  			else if (btns & JC_BTN_RIGHT)
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  699  				hatx = 1;
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  700  			input_report_abs(dev, ABS_HAT0X, hatx);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  701  
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  702  			/* d-pad y */
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  703  			if (btns & JC_BTN_UP)
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  704  				haty = -1;
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  705  			else if (btns & JC_BTN_DOWN)
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  706  				haty = 1;
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  707  			input_report_abs(dev, ABS_HAT0Y, haty);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  708  		}
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  709  	}
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  710  	if (id != USB_DEVICE_ID_NINTENDO_JOYCONL) {
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  711  		u16 raw_x;
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  712  		u16 raw_y;
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  713  		s32 x;
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  714  		s32 y;
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  715  
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  716  		/* get raw stick values */
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  717  		raw_x = hid_field_extract(ctlr->hdev, rep->right_stick, 0, 12);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  718  		raw_y = hid_field_extract(ctlr->hdev,
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  719  					  rep->right_stick + 1, 4, 12);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  720  		/* map stick values */
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  721  		x = joycon_map_stick_val(&ctlr->right_stick_cal_x, raw_x);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  722  		y = -joycon_map_stick_val(&ctlr->right_stick_cal_y, raw_y);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  723  		/* report sticks */
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  724  		input_report_abs(dev, ABS_RX, x);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  725  		input_report_abs(dev, ABS_RY, y);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  726  
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  727  		/* report buttons */
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  728  		input_report_key(dev, BTN_TR, btns & JC_BTN_R);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  729  		input_report_key(dev, BTN_TR2, btns & JC_BTN_ZR);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  730  		if (id != USB_DEVICE_ID_NINTENDO_PROCON) {
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  731  			/* Report the S buttons as the non-existent triggers */
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  732  			input_report_key(dev, BTN_TL, btns & JC_BTN_SL_R);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  733  			input_report_key(dev, BTN_TL2, btns & JC_BTN_SR_R);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  734  		}
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  735  		input_report_key(dev, BTN_START, btns & JC_BTN_PLUS);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  736  		input_report_key(dev, BTN_THUMBR, btns & JC_BTN_RSTICK);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  737  		input_report_key(dev, BTN_MODE, btns & JC_BTN_HOME);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  738  		input_report_key(dev, BTN_WEST, btns & JC_BTN_Y);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  739  		input_report_key(dev, BTN_NORTH, btns & JC_BTN_X);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  740  		input_report_key(dev, BTN_EAST, btns & JC_BTN_A);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  741  		input_report_key(dev, BTN_SOUTH, btns & JC_BTN_B);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  742  	}
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  743  
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  744  	input_sync(dev);
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  745  }
2af16c1f846bd6 Daniel J. Ogorchock 2021-09-11  746  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 37497 bytes --]

                 reply	other threads:[~2021-11-17  1:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202111170931.dfCeaRsD-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=kbuild@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.