Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: pxa27x-keypad - fix generating scancode

The number of columns of pxa27x-keypad used by various boards is not fixed.
When building keymap with call to:

matrix_keypad_build_keymap(keymap_data, NULL,
pdata->matrix_key_rows,
pdata->matrix_key_cols,
keypad->keycodes, input_dev);

it will internally calculate needed row shift and use it to fill the
keymap. Therefore when calculating the "scancode" we should no longer use
constant row shift but also calculate it from number of columns.

Signed-off-by: Chao Xie <chao.xie@marvell.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Chao Xie and committed by
Dmitry Torokhov
c5ec1948 ba77341c

+6 -1
+6 -1
drivers/input/keyboard/pxa27x_keypad.c
··· 111 111 unsigned short keycodes[MAX_KEYPAD_KEYS]; 112 112 int rotary_rel_code[2]; 113 113 114 + unsigned int row_shift; 115 + 114 116 /* state row bits of each column scan */ 115 117 uint32_t matrix_key_state[MAX_MATRIX_KEY_COLS]; 116 118 uint32_t direct_key_state; ··· 469 467 if ((bits_changed & (1 << row)) == 0) 470 468 continue; 471 469 472 - code = MATRIX_SCAN_CODE(row, col, MATRIX_ROW_SHIFT); 470 + code = MATRIX_SCAN_CODE(row, col, keypad->row_shift); 471 + 473 472 input_event(input_dev, EV_MSC, MSC_SCAN, code); 474 473 input_report_key(input_dev, keypad->keycodes[code], 475 474 new_state[col] & (1 << row)); ··· 804 801 dev_err(&pdev->dev, "failed to build keycode\n"); 805 802 goto failed_put_clk; 806 803 } 804 + 805 + keypad->row_shift = get_count_order(pdata->matrix_key_cols); 807 806 808 807 if ((pdata->enable_rotary0 && keypad->rotary_rel_code[0] != -1) || 809 808 (pdata->enable_rotary1 && keypad->rotary_rel_code[1] != -1)) {