All of lore.kernel.org
 help / color / mirror / Atom feed
* re: [PATCH] OMAP: Add keypad driver
@ 2016-01-07  9:37 Dan Carpenter
  2016-01-07 18:54 ` Dmitry Torokhov
  0 siblings, 1 reply; 9+ messages in thread
From: Dan Carpenter @ 2016-01-07  9:37 UTC (permalink / raw)
  To: Komal Shah; +Cc: linux-input

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] OMAP: Add keypad driver
  2016-01-07  9:37 [PATCH] OMAP: Add keypad driver Dan Carpenter
@ 2016-01-07 18:54 ` Dmitry Torokhov
  2016-01-07 20:13   ` Tony Lindgren
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Torokhov @ 2016-01-07 18:54 UTC (permalink / raw)
  To: Dan Carpenter, Tony Lindgren
  Cc: Komal Shah, linux-input, Janusz Krzysztofik, Aaro Koskinen

On Thu, Jan 7, 2016 at 1:37 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 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.

>
> 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.

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.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] OMAP: Add keypad driver
  2016-01-07 18:54 ` Dmitry Torokhov
@ 2016-01-07 20:13   ` Tony Lindgren
  2016-01-07 23:22     ` Dmitry Torokhov
  0 siblings, 1 reply; 9+ messages in thread
From: Tony Lindgren @ 2016-01-07 20:13 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Dan Carpenter, Komal Shah, linux-input, Janusz Krzysztofik,
	Aaro Koskinen, linux-omap

Hi,

* Dmitry Torokhov <dmitry.torokhov@gmail.com> [160107 10:54]:
> On Thu, Jan 7, 2016 at 1:37 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > 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.
> 
> >
> > drivers/input/keyboard/omap-keypad.c
...
> >    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: 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?

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] OMAP: Add keypad driver
  2016-01-07 20:13   ` Tony Lindgren
@ 2016-01-07 23:22     ` Dmitry Torokhov
  2016-01-08  0:08       ` Koskinen, Aaro (Nokia - FI/Espoo)
                         ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2016-01-07 23:22 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Dan Carpenter, Komal Shah, linux-input, Janusz Krzysztofik,
	Aaro Koskinen, linux-omap

On Thu, Jan 07, 2016 at 12:13:17PM -0800, Tony Lindgren wrote:
> Hi,
> 
> * Dmitry Torokhov <dmitry.torokhov@gmail.com> [160107 10:54]:
> > On Thu, Jan 7, 2016 at 1:37 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > > 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.
> > 
> > >
> > > drivers/input/keyboard/omap-keypad.c
> ...
> > >    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: 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?
> 
> 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?

-- 
Dmitry


Input: omap-keypad - remove dead check

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>

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 <dan.carpenter@oracle.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/keyboard/omap-keypad.c |    8 --------
 1 file changed, 8 deletions(-)

diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c
index 75ad666..e0d72c8 100644
--- a/drivers/input/keyboard/omap-keypad.c
+++ b/drivers/input/keyboard/omap-keypad.c
@@ -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))

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* RE: [PATCH] OMAP: Add keypad driver
  2016-01-07 23:22     ` Dmitry Torokhov
@ 2016-01-08  0:08       ` Koskinen, Aaro (Nokia - FI/Espoo)
  2016-01-08  0:13         ` Tony Lindgren
  2016-01-08  0:10       ` Tony Lindgren
  2016-01-08  1:41       ` Janusz Krzysztofik
  2 siblings, 1 reply; 9+ messages in thread
From: Koskinen, Aaro (Nokia - FI/Espoo) @ 2016-01-08  0:08 UTC (permalink / raw)
  To: EXT Dmitry Torokhov, Tony Lindgren
  Cc: Dan Carpenter, Komal Shah, linux-input, Janusz Krzysztofik, linux-omap

Hi,

> From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>
> 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 <dan.carpenter@oracle.com>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Acked-by: Aaro Koskinen <aaro.koskinen@nokia.com>

> ---
>  drivers/input/keyboard/omap-keypad.c |    8 --------
>  1 file changed, 8 deletions(-)
>
> diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c
> index 75ad666..e0d72c8 100644
> --- a/drivers/input/keyboard/omap-keypad.c
> +++ b/drivers/input/keyboard/omap-keypad.c
> @@ -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))

Thanks,

A.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] OMAP: Add keypad driver
  2016-01-07 23:22     ` Dmitry Torokhov
  2016-01-08  0:08       ` Koskinen, Aaro (Nokia - FI/Espoo)
@ 2016-01-08  0:10       ` Tony Lindgren
  2016-01-08  1:41       ` Janusz Krzysztofik
  2 siblings, 0 replies; 9+ messages in thread
From: Tony Lindgren @ 2016-01-08  0:10 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Dan Carpenter, Komal Shah, linux-input, Janusz Krzysztofik,
	Aaro Koskinen, linux-omap

* Dmitry Torokhov <dmitry.torokhov@gmail.com> [160107 15:23]:
> On Thu, Jan 07, 2016 at 12:13:17PM -0800, Tony Lindgren wrote:
> > 
> > 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 <tony@atomide.com>

I've also corrected Aaro's email address, he may have some keyboard
input too.

Regards,

Tony


> Input: omap-keypad - remove dead check
> 
> From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> 
> 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 <dan.carpenter@oracle.com>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/input/keyboard/omap-keypad.c |    8 --------
>  1 file changed, 8 deletions(-)
> 
> diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c
> index 75ad666..e0d72c8 100644
> --- a/drivers/input/keyboard/omap-keypad.c
> +++ b/drivers/input/keyboard/omap-keypad.c
> @@ -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))

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] OMAP: Add keypad driver
  2016-01-08  0:08       ` Koskinen, Aaro (Nokia - FI/Espoo)
@ 2016-01-08  0:13         ` Tony Lindgren
  0 siblings, 0 replies; 9+ messages in thread
From: Tony Lindgren @ 2016-01-08  0:13 UTC (permalink / raw)
  To: Koskinen, Aaro (Nokia - FI/Espoo)
  Cc: EXT Dmitry Torokhov, Dan Carpenter, Komal Shah, linux-input,
	Janusz Krzysztofik, linux-omap

* Koskinen, Aaro (Nokia - FI/Espoo) <aaro.koskinen@nokia.com> [160107 16:08]:
> Hi,
> 
> > From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> >
> > 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 <dan.carpenter@oracle.com>
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> 
> Acked-by: Aaro Koskinen <aaro.koskinen@nokia.com>

Heh sorry I mis-corrected your email in my reply, old habit you know :)

Tony

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] OMAP: Add keypad driver
  2016-01-07 23:22     ` Dmitry Torokhov
  2016-01-08  0:08       ` Koskinen, Aaro (Nokia - FI/Espoo)
  2016-01-08  0:10       ` Tony Lindgren
@ 2016-01-08  1:41       ` Janusz Krzysztofik
  2016-01-08  6:38         ` Dmitry Torokhov
  2 siblings, 1 reply; 9+ messages in thread
From: Janusz Krzysztofik @ 2016-01-08  1:41 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Tony Lindgren, Dan Carpenter, Komal Shah, linux-input,
	Aaro Koskinen, linux-omap

On Thu, 7 Jan 2016 15:22:28 Dmitry Torokhov wrote:
> On Thu, Jan 07, 2016 at 12:13:17PM -0800, Tony Lindgren wrote:
> > * Dmitry Torokhov <dmitry.torokhov@gmail.com> [160107 10:54]:
> > > On Thu, Jan 7, 2016 at 1:37 AM, Dan Carpenter 
<dan.carpenter@oracle.com> wrote:
> > > ...
> > > >    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: 
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?
> > 
> > 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?
> 
> --
> Dmitry
> 
> 
> Input: omap-keypad - remove dead check
> 
> From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> 
> 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 <dan.carpenter@oracle.com>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> 
>  drivers/input/keyboard/omap-keypad.c |    8 --------
>  1 file changed, 8 deletions(-)
> 
> diff --git a/drivers/input/keyboard/omap-keypad.c
> b/drivers/input/keyboard/omap-keypad.c index 75ad666..e0d72c8 100644
> --- a/drivers/input/keyboard/omap-keypad.c
> +++ b/drivers/input/keyboard/omap-keypad.c
> @@ -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;

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

> -                               continue;
> -                       }
> 
>                         if (!(kp_cur_group == (key & GROUP_MASK) ||                         
>                               kp_cur_group == -1))

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] OMAP: Add keypad driver
  2016-01-08  1:41       ` Janusz Krzysztofik
@ 2016-01-08  6:38         ` Dmitry Torokhov
  0 siblings, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2016-01-08  6:38 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Tony Lindgren, Dan Carpenter, Komal Shah, linux-input,
	Aaro Koskinen, linux-omap

On Fri, Jan 08, 2016 at 02:41:00AM +0100, Janusz Krzysztofik wrote:
> On Thu, 7 Jan 2016 15:22:28 Dmitry Torokhov wrote:
> > On Thu, Jan 07, 2016 at 12:13:17PM -0800, Tony Lindgren wrote:
> > > * Dmitry Torokhov <dmitry.torokhov@gmail.com> [160107 10:54]:
> > > > On Thu, Jan 7, 2016 at 1:37 AM, Dan Carpenter 
> <dan.carpenter@oracle.com> wrote:
> > > > ...
> > > > >    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: 
> 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?
> > > 
> > > 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?
> > 
> > --
> > Dmitry
> > 
> > 
> > Input: omap-keypad - remove dead check
> > 
> > From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > 
> > 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 <dan.carpenter@oracle.com>
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> > 
> >  drivers/input/keyboard/omap-keypad.c |    8 --------
> >  1 file changed, 8 deletions(-)
> > 
> > diff --git a/drivers/input/keyboard/omap-keypad.c
> > b/drivers/input/keyboard/omap-keypad.c index 75ad666..e0d72c8 100644
> > --- a/drivers/input/keyboard/omap-keypad.c
> > +++ b/drivers/input/keyboard/omap-keypad.c
> > @@ -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;
> 
> 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().

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.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-01-08  6:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-07  9:37 [PATCH] OMAP: Add keypad driver Dan Carpenter
2016-01-07 18:54 ` Dmitry Torokhov
2016-01-07 20:13   ` Tony Lindgren
2016-01-07 23:22     ` Dmitry Torokhov
2016-01-08  0:08       ` Koskinen, Aaro (Nokia - FI/Espoo)
2016-01-08  0:13         ` Tony Lindgren
2016-01-08  0:10       ` Tony Lindgren
2016-01-08  1:41       ` Janusz Krzysztofik
2016-01-08  6:38         ` Dmitry Torokhov

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.