OMAP: Add keypad driver
Subsystems (2)
Hello file (standard input) matches,
The patch ad4e09b16ad3: "[PATCH] OMAP: Add keypad driver", leads to the following static checker warning:
drivers/input/keyboard/omap-keypad.c:158 omap_kp_tasklet() warn: 'keycodes[]' is never negative.
drivers/input/keyboard/omap-keypad.c
129 static void omap_kp_tasklet(unsigned long data) 130 {
131 struct omap_kp *omap_kp_data = (struct omap_kp *) data;
132 unsigned short *keycodes = omap_kp_data->input->keycode;
^^^^^^^^^^^^^^^^^^^^^^^^
133 unsigned int row_shift = get_count_order(omap_kp_data->cols);
134 unsigned char new_state[8], changed, key_down = 0;
135 int col, row;
136 int spurious = 0;
137
138 /* check for any changes */
139 omap_kp_scan_keypad(omap_kp_data, new_state);
140
141 /* check for changes and print those */
142 for (col = 0; col < omap_kp_data->cols; col++) {
143 changed = new_state[col] ^ keypad_state[col];
144 key_down |= new_state[col];
145 if (changed == 0)
146 continue;
147
148 for (row = 0; row < omap_kp_data->rows; row++) {
149 int key;
^^^^^^^
150 if (!(changed & (1 << row)))
151 continue;
152 #ifdef NEW_BOARD_LEARNING_MODE
153 printk(KERN_INFO "omap-keypad: key %d-%d %s\n", col,
154 row, (new_state[col] & (1 << row)) ?
155 "pressed" : "released");
156 #else
157 key = keycodes[MATRIX_SCAN_CODE(row, col, row_shift)];
158 if (key < 0) {
^^^^^^^Never true. Not sure what was intended.
159 printk(KERN_WARNING
160 "omap-keypad: Spurious key event %d-%d\n",
161 col, row);
162 /* We scan again after a couple of seconds */ 163 spurious = 1; 164 continue;
165 }
166
167 if (!(kp_cur_group == (key & GROUP_MASK) ||
168 kp_cur_group == -1))
169 continue;
170
regards,
dan carpenter
Dmitry Torokhov
maintainerQuoted 7 lines · Dan Carpenter
Hello file (standard input) matches,
The patch
ad4e09b16ad3: "[PATCH] OMAP: Add keypad driver", leads to the following static checker warning:drivers/input/keyboard/omap-keypad.c:158 omap_kp_tasklet() warn: 'keycodes[]' is never negative.
It looks like you are not resolving commits correctly, the original submission did not have this issue.
Quoted 35 lines
drivers/input/keyboard/omap-keypad.c
129 static voidomap_kp_tasklet(unsigned long data)130 { 131 struct omap_kp *omap_kp_data = (struct omap_kp *) data; 132 unsigned short *keycodes = omap_kp_data->input->keycode; ^^^^^^^^^^^^^^^^^^^^^^^^ 133 unsigned int row_shift = get_count_order(omap_kp_data->cols); 134 unsigned char new_state[8], changed, key_down = 0; 135 int col, row; 136 int spurious = 0; 137 138 /* check for any changes */ 139 omap_kp_scan_keypad(omap_kp_data, new_state); 140 141 /* check for changes and print those */ 142 for (col = 0; col < omap_kp_data->cols; col++) { 143 changed = new_state[col] ^ keypad_state[col]; 144 key_down |= new_state[col]; 145 if (changed == 0) 146 continue; 147 148 for (row = 0; row < omap_kp_data->rows; row++) { 149 int key; ^^^^^^^ 150 if (!(changed & (1 << row))) 151 continue; 152 #ifdef NEW_BOARD_LEARNING_MODE 153 printk(KERN_INFO "omap-keypad: key %d-%d %s\n", col, 154 row, (new_state[col] & (1 << row)) ? 155 "pressed" : "released"); 156 #else 157 key = keycodes[MATRIX_SCAN_CODE(row, col, row_shift)]; 158 if (key < 0) { ^^^^^^^
Quoted 1 line
Never true. Not sure what was intended.
It looks like this check was broken by da1f026b532ce944d74461497dc6d8c16456466e (Keyboard: omap-keypad: use matrix_keypad.h). Previously the driver would expect a list of known keys and would scan it and return -1 if key was not found. Now we have 2 options:
1. Simply remove the check
2. Change the condition to "if (key == KEY_RESERVED)"
I do not really have preference. Tony?
Thanks.
Signature · 1 line
Dmitry
Hi,
Quoted 14 lines · Dmitry Torokhov
Quoted 7 lines · Dan Carpenter
Hello file (standard input) matches,
The patch
ad4e09b16ad3: "[PATCH] OMAP: Add keypad driver", leads to the following static checker warning:drivers/input/keyboard/omap-keypad.c:158 omap_kp_tasklet() warn: 'keycodes[]' is never negative.It looks like you are not resolving commits correctly, the original submission did not have this issue.
Quoted 2 lines
drivers/input/keyboard/omap-keypad.c
...
Quoted 16 lines
Quoted 9 lines
152 #ifdef NEW_BOARD_LEARNING_MODE 153 printk(KERN_INFO "omap-keypad: key %d-%d %s\n", col, 154 row, (new_state[col] & (1 << row)) ? 155 "pressed" : "released"); 156 #else 157 key = keycodes[MATRIX_SCAN_CODE(row, col, row_shift)]; 158 if (key < 0) { ^^^^^^^Never true. Not sure what was intended.
It looks like this check was broken by
da1f026b532ce944d74461497dc6d8c16456466e(Keyboard: omap-keypad: usematrix_keypad.h). Previously the driver would expect a list of known keys and would scan it and return -1 if key was not found. Now we have 2 options:
Quoted 4 lines
1. Simply remove the check
2. Change the condition to "if (key ==KEY_RESERVED)"I do not really have preference. Tony?
Sounds like the check is not needed if it has not been used for past five years, so my preference is option #1 then.
Regards,
Tony
Dmitry Torokhov
maintainerQuoted 34 lines · Tony Lindgren
Hi,
Quoted 14 lines · Dmitry Torokhov
Quoted 7 lines · Dan Carpenter
Hello file (standard input) matches,
The patch
ad4e09b16ad3: "[PATCH] OMAP: Add keypad driver", leads to the following static checker warning:drivers/input/keyboard/omap-keypad.c:158 omap_kp_tasklet() warn: 'keycodes[]' is never negative.It looks like you are not resolving commits correctly, the original submission did not have this issue.
Quoted 2 lines
drivers/input/keyboard/omap-keypad.c...
Quoted 16 lines
Quoted 9 lines
152 #ifdef NEW_BOARD_LEARNING_MODE 153 printk(KERN_INFO "omap-keypad: key %d-%d %s\n", col, 154 row, (new_state[col] & (1 << row)) ? 155 "pressed" : "released"); 156 #else 157 key = keycodes[MATRIX_SCAN_CODE(row, col, row_shift)]; 158 if (key < 0) { ^^^^^^^Never true. Not sure what was intended.
It looks like this check was broken by
da1f026b532ce944d74461497dc6d8c16456466e(Keyboard: omap-keypad: usematrix_keypad.h). Previously the driver would expect a list of known keys and would scan it and return -1 if key was not found. Now we have 2 options:
Quoted 7 lines
Quoted 4 lines
1. Simply remove the check
2. Change the condition to "if (key ==KEY_RESERVED)"I do not really have preference. Tony?
Sounds like the check is not needed if it has not been used for past five years, so my preference is option #1 then.
OK, how about the below then?
Signature · 24 lines
Dmitry Input: omap-keypad - remove dead check From: Dmitry Torokhov <[email protected]> Commit da1f026b532ce944d74461497dc6d8c16456466e ("Keyboard: omap-keypad: use matrix_keypad.h") switched the driver to use matrix keypad infrastructure, which made array of keycodes to be unsigned short, and caused the test for negativity never trigger. This leads to the following static checker warning: drivers/input/keyboard/omap-keypad.c:158 omap_kp_tasklet() warn: 'keycodes[]' is never negative. Given that we did not care about this check for a few years already let's simply remove it. Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]> --- drivers/input/keyboard/omap-keypad.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/input/keyboard/omap-keypad.c +0 -8
@@ -155,14 +155,6 @@ static void omap_kp_tasklet(unsigned long data) "pressed" : "released");#else key = keycodes[MATRIX_SCAN_CODE (row, col, row_shift)]; -if (key <0 ) { -printk (KERN_WARNING -"omap-keypad: Spurious key event %d-%d\n" , - col, row); -/* We scan again after a couple of seconds */ - spurious =1 ; -continue ; - }if (!(kp_cur_group == (key &GROUP_MASK ) || kp_cur_group ==-1 ))
Koskinen, Aaro (Nokia - FI/Espoo)
Acked-byHi,
Quoted 8 lines
From: Dmitry Torokhov <[email protected]>
Commit
da1f026b532ce944d74461497dc6d8c16456466e("Keyboard: omap-keypad:
usematrix_keypad.h") switched the driver to use matrix keypad infrastructure, which made array of keycodes to be unsigned short, and caused the test for negativity never trigger. This leads to the following static checker warning:
Quoted 8 lines
drivers/input/keyboard/omap-keypad.c:158 omap_kp_tasklet() warn: 'keycodes[]' is never negative.Given that we did not care about this check for a few years already let's simply remove it.
Reported-by Dan Carpenter <[email protected]>Signed-off-by Dmitry Torokhov <[email protected]>
Quoted 13 lines
--- drivers/input/keyboard/omap-keypad.c | 8 -------- 1 file changed, 8 deletions(-)drivers/input/keyboard/omap-keypad.c +0
-1@@ -155,14 +155,6 @@ static void omap_kp_tasklet(unsigned long data) "pressed" : "released");#else key = keycodes[MATRIX_SCAN_CODE (row, col, row_shift)]; -if (key <0 ) {
drivers/input/keyboard/omap-keypad.c static void omap_kp_tasklet(unsigned long data) · line 160
Quoted 10 lines
drivers/input/keyboard/omap-keypad.c +0
-7-printk (KERN_WARNING -"omap-keypad: Spurious key event %d-%d\n" , - col, row); -/* We scan again after a couple of seconds */ - spurious =1 ; -continue ; - }if (!(kp_cur_group == (key &GROUP_MASK ) || kp_cur_group ==-1 ))
Thanks,
A.
Quoted 13 lines · Koskinen, Aaro (Nokia - FI/Espoo)
Hi,
Quoted 11 lines
From: Dmitry Torokhov <[email protected]>
Commit
da1f026b532ce944d74461497dc6d8c16456466e("Keyboard: omap-keypad:
usematrix_keypad.h") switched the driver to use matrix keypad infrastructure, which made array of keycodes to be unsigned short, and caused the test for negativity never trigger. This leads to the following static checker warning:drivers/input/keyboard/omap-keypad.c:158 omap_kp_tasklet() warn: 'keycodes[]' is never negative.
Quoted 7 lines
Quoted 5 lines
Given that we did not care about this check for a few years already let's simply remove it.
Reported-by Dan Carpenter <[email protected]>Signed-off-by Dmitry Torokhov <[email protected]>Acked-by Aaro Koskinen <[email protected]>
Heh sorry I mis-corrected your email in my reply, old habit you know :)
Tony
Quoted 6 lines · Dmitry Torokhov
Quoted 3 lines · Tony Lindgren
Sounds like the check is not needed if it has not been used for past five years, so my preference is option #1 then.
OK, how about the below then?
Looks good to me thanks: Acked-by: Tony Lindgren <[email protected]>
I've also corrected Aaro's email address, he may have some keyboard input too.
Regards,
Tony
Quoted 41 lines
Input: omap-keypad - remove dead check
From: Dmitry Torokhov <[email protected]>
Commit
da1f026b532ce944d74461497dc6d8c16456466e("Keyboard: omap-keypad:
usematrix_keypad.h") switched the driver to use matrix keypad infrastructure, which made array of keycodes to be unsigned short, and caused the test for negativity never trigger. This leads to the following static checker warning:drivers/input/keyboard/omap-keypad.c:158 omap_kp_tasklet() warn: 'keycodes[]' is never negative.Given that we did not care about this check for a few years already let's simply remove it.
Reported-by Dan Carpenter <[email protected]>Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/input/keyboard/omap-keypad.c | 8 -------- 1 file changed, 8 deletions(-)drivers/input/keyboard/omap-keypad.c +0
-8@@ -155,14 +155,6 @@ static void omap_kp_tasklet(unsigned long data) "pressed" : "released");#else key = keycodes[MATRIX_SCAN_CODE (row, col, row_shift)]; -if (key <0 ) { -printk (KERN_WARNING -"omap-keypad: Spurious key event %d-%d\n" , - col, row); -/* We scan again after a couple of seconds */ - spurious =1 ; -continue ; - }if (!(kp_cur_group == (key &GROUP_MASK ) || kp_cur_group ==-1 ))
Quoted 3 lines · On Thu, 7 Jan 2016 15:22:28 Dmitry Torokhov wrote:
Quoted 2 lines · Tony Lindgren
Quoted 1 line · Dmitry Torokhov
On Thu, Jan 7, 2016 at 1:37 AM, Dan Carpenter
Quoted 2 lines · <[email protected]> wrote:
Quoted 2 lines
Quoted 2 lines
...
Quoted 1 line
157 key =
keycodes[MATRIX_SCAN_CODE(row, col, row_shift)];
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
158 if (key < 0) { ^^^^^^^Never true. Not sure what was intended.
It looks like this check was broken by
da1f026b532ce944d74461497dc6d8c16456466e(Keyboard: omap-keypad:
use
Quoted 1 line
Quoted 1 line
Quoted 1 line
matrix_keypad.h). Previously the driver would expect a list of
known
Quoted 1 line
Quoted 1 line
Quoted 1 line
keys and would scan it and return -1 if key was not found. Now we
have
Quoted 44 lines
Quoted 9 lines
Quoted 6 lines
2 options:
1. Simply remove the check
2. Change the condition to "if (key ==KEY_RESERVED)"I do not really have preference. Tony?
Sounds like the check is not needed if it has not been used for past five years, so my preference is option #1 then.
OK, how about the below then?
--
DmitryInput: omap-keypad - remove dead check
From: Dmitry Torokhov <[email protected]>
Commit
da1f026b532ce944d74461497dc6d8c16456466e("Keyboard:
omap-keypad: usematrix_keypad.h") switched the driver to use matrix keypad infrastructure, which made array of keycodes to be unsigned short, and caused the test for negativity never trigger. This leads to the following>
static checker warning:drivers/input/keyboard/omap-keypad.c:158 omap_kp_tasklet() warn: 'keycodes[]' is never negative.Given that we did not care about this check for a few years already let's simply remove it.
Reported-by Dan Carpenter <[email protected]>Signed-off-by Dmitry Torokhov <[email protected]>---
drivers/input/keyboard/omap-keypad.c | 8 -------- 1 file changed, 8 deletions(-)(quoted diff) +0
-0
b/drivers/input/keyboard/omap-keypad.cindex 75ad666..e0d72c8 100644
drivers/input/keyboard/omap-keypad.c static void omap_kp_tasklet(unsigned long data) · line 157
Quoted 3 lines
drivers/input/keyboard/omap-keypad.c +0
-0@@ -155,14 +155,6 @@ static void omap_kp_tasklet(unsigned long data) "pressed" : "released");#else key = keycodes[MATRIX_SCAN_CODE(row, col,
row_shift)];
drivers/input/keyboard/omap-keypad.c static void omap_kp_tasklet(unsigned long data)
Quoted 3 lines
drivers/input/keyboard/omap-keypad.c +0
-3- if (key < 0) { - printk(KERN_WARNING - "omap-keypad: Spurious key event
%d-%d\n",
drivers/input/keyboard/omap-keypad.c static void omap_kp_tasklet(unsigned long data) · line 162
Quoted 2 lines
drivers/input/keyboard/omap-keypad.c +0
-2- col, row); -/* We scan again after a couple of
seconds */
drivers/input/keyboard/omap-keypad.c static void omap_kp_tasklet(unsigned long data) · line 163
Quoted 1 line
drivers/input/keyboard/omap-keypad.c +0
-1- spurious =1 ;
Hi,
That code was written before I played with it so I'm not really sure about its purpose, but it looks to me like something intended as a debouncer.
Since that was the only place where the spurious variable could be modified, I think we should also remove the now unreachable code that manipulates delay based on spurious value several lines below, as well as declaration and initialization of spurious at the beginning of omap_kp_tasklet().
Thanks,
Janusz
Quoted 5 lines
drivers/input/keyboard/omap-keypad.c +0
-2-continue ; - }if (!(kp_cur_group == (key &GROUP_MASK ) || kp_cur_group ==-1 ))
Dmitry Torokhov
maintainerQuoted 82 lines · Janusz Krzysztofik
Quoted 3 lines · On Thu, 7 Jan 2016 15:22:28 Dmitry Torokhov wrote:
Quoted 2 lines · Tony Lindgren
Quoted 1 line · Dmitry Torokhov
On Thu, Jan 7, 2016 at 1:37 AM, Dan Carpenter
Quoted 2 lines · <[email protected]> wrote:
Quoted 2 lines
Quoted 2 lines
...
Quoted 1 line
157 key =
keycodes[MATRIX_SCAN_CODE(row, col,
row_shift)];Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
158 if (key < 0) { ^^^^^^^Never true. Not sure what was intended.
It looks like this check was broken by
da1f026b532ce944d74461497dc6d8c16456466e(Keyboard: omap-keypad:use
Quoted 1 line
Quoted 1 line
Quoted 1 line
matrix_keypad.h). Previously the driver would expect a list ofknown
Quoted 1 line
Quoted 1 line
Quoted 1 line
keys and would scan it and return -1 if key was not found. Now we
have
Quoted 44 lines
Quoted 9 lines
Quoted 6 lines
2 options:
1. Simply remove the check
2. Change the condition to "if (key ==KEY_RESERVED)"I do not really have preference. Tony?
Sounds like the check is not needed if it has not been used for past five years, so my preference is option #1 then.
OK, how about the below then?
--
DmitryInput: omap-keypad - remove dead check
From: Dmitry Torokhov <[email protected]>
Commit
da1f026b532ce944d74461497dc6d8c16456466e("Keyboard:
omap-keypad: usematrix_keypad.h") switched the driver to use matrix keypad infrastructure, which made array of keycodes to be unsigned short, and caused the test for negativity never trigger. This leads to the following>
static checker warning:drivers/input/keyboard/omap-keypad.c:158 omap_kp_tasklet() warn: 'keycodes[]' is never negative.Given that we did not care about this check for a few years already let's simply remove it.
Reported-by Dan Carpenter <[email protected]>Signed-off-by Dmitry Torokhov <[email protected]>---
drivers/input/keyboard/omap-keypad.c | 8 -------- 1 file changed, 8 deletions(-)(quoted diff) +0
-0
b/drivers/input/keyboard/omap-keypad.cindex 75ad666..e0d72c8 100644drivers/input/keyboard/omap-keypad.c static void omap_kp_tasklet(unsigned long data) · line 157
Quoted 3 lines
drivers/input/keyboard/omap-keypad.c +0
-0@@ -155,14 +155,6 @@ static void omap_kp_tasklet(unsigned long data) "pressed" : "released");#else key = keycodes[MATRIX_SCAN_CODE(row, col,
row_shift)];drivers/input/keyboard/omap-keypad.c static void omap_kp_tasklet(unsigned long data)
Quoted 3 lines
drivers/input/keyboard/omap-keypad.c +0
-3- if (key < 0) { - printk(KERN_WARNING - "omap-keypad: Spurious key event%d-%d\n",
drivers/input/keyboard/omap-keypad.c static void omap_kp_tasklet(unsigned long data) · line 162
Quoted 2 lines
drivers/input/keyboard/omap-keypad.c +0
-2- col, row); -/* We scan again after a couple of seconds */
drivers/input/keyboard/omap-keypad.c static void omap_kp_tasklet(unsigned long data) · line 163
Quoted 1 line
drivers/input/keyboard/omap-keypad.c +0
-1- spurious =1 ;Hi,
That code was written before I played with it so I'm not really sure about its purpose, but it looks to me like something intended as a debouncer.
Quoted 5 lines
Since that was the only place where the spurious variable could be modified, I think we should also remove the now unreachable code that manipulates delay based on spurious value several lines below, as well as declaration and initialization of spurious at the beginning of
omap_kp_tasklet().
Yeah, now that I look at it this driver needs some love. The probing is racy, remove is incomplete, etc.
Do any of you guys have hardware that uses it?
Thanks.
Signature · 1 line
Dmitry