linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: cros_ec_keyb: Add back missing mask for event_type
@ 2019-08-13  9:38 Fei Shao
  2019-08-13  9:47 ` Nicolas Boichat
  0 siblings, 1 reply; 3+ messages in thread
From: Fei Shao @ 2019-08-13  9:38 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Brian Norris, Fei Shao, Dmitry Torokhov, linux-kernel, Ting Shen,
	Guenter Roeck, linux-input, Enric Balletbo i Serra, Benson Leung

In the previous patch we didn't mask out event_type in case statement,
so switches are always picked instead of buttons, which results in
ChromeOS devices misbehaving when power button is pressed.
This patch adds back the missing mask.

Fixes: d096aa3eb604 ("Input: cros_ec_keyb: mask out extra flags in event_type")
Signed-off-by: Fei Shao <fshao@chromium.org>
---
 drivers/input/keyboard/cros_ec_keyb.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c
index 38cb6d82d8fe..bef7bee6f05e 100644
--- a/drivers/input/keyboard/cros_ec_keyb.c
+++ b/drivers/input/keyboard/cros_ec_keyb.c
@@ -226,6 +226,8 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
 {
 	struct cros_ec_keyb *ckdev = container_of(nb, struct cros_ec_keyb,
 						  notifier);
+	uint8_t mkbp_event_type = ckdev->ec->event_data.event_type &
+				  EC_MKBP_EVENT_TYPE_MASK;
 	u32 val;
 	unsigned int ev_type;

@@ -237,7 +239,7 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
 	if (queued_during_suspend && !device_may_wakeup(ckdev->dev))
 		return NOTIFY_OK;

-	switch (ckdev->ec->event_data.event_type & EC_MKBP_EVENT_TYPE_MASK) {
+	switch (mkbp_event_type) {
 	case EC_MKBP_EVENT_KEY_MATRIX:
 		pm_wakeup_event(ckdev->dev, 0);

@@ -264,7 +266,7 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
 	case EC_MKBP_EVENT_SWITCH:
 		pm_wakeup_event(ckdev->dev, 0);

-		if (ckdev->ec->event_data.event_type == EC_MKBP_EVENT_BUTTON) {
+		if (mkbp_event_type == EC_MKBP_EVENT_BUTTON) {
 			val = get_unaligned_le32(
 					&ckdev->ec->event_data.data.buttons);
 			ev_type = EV_KEY;
--
2.23.0.rc1.153.gdeed80330f-goog

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] Input: cros_ec_keyb: Add back missing mask for event_type
  2019-08-13  9:38 [PATCH] Input: cros_ec_keyb: Add back missing mask for event_type Fei Shao
@ 2019-08-13  9:47 ` Nicolas Boichat
  2019-08-14 22:06   ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Boichat @ 2019-08-13  9:47 UTC (permalink / raw)
  To: Fei Shao
  Cc: Brian Norris, Dmitry Torokhov, lkml, Ting Shen, Guenter Roeck,
	open list:HID CORE LAYER, Enric Balletbo i Serra, Benson Leung,
	linux-arm Mailing List

On Tue, Aug 13, 2019 at 5:38 PM Fei Shao <fshao@chromium.org> wrote:
>
> In the previous patch we didn't mask out event_type in case statement,
> so switches are always picked instead of buttons, which results in
> ChromeOS devices misbehaving when power button is pressed.
> This patch adds back the missing mask.
>
> Fixes: d096aa3eb604 ("Input: cros_ec_keyb: mask out extra flags in event_type")
> Signed-off-by: Fei Shao <fshao@chromium.org>

Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>

> ---
>  drivers/input/keyboard/cros_ec_keyb.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c
> index 38cb6d82d8fe..bef7bee6f05e 100644
> --- a/drivers/input/keyboard/cros_ec_keyb.c
> +++ b/drivers/input/keyboard/cros_ec_keyb.c
> @@ -226,6 +226,8 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
>  {
>         struct cros_ec_keyb *ckdev = container_of(nb, struct cros_ec_keyb,
>                                                   notifier);
> +       uint8_t mkbp_event_type = ckdev->ec->event_data.event_type &
> +                                 EC_MKBP_EVENT_TYPE_MASK;
>         u32 val;
>         unsigned int ev_type;
>
> @@ -237,7 +239,7 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
>         if (queued_during_suspend && !device_may_wakeup(ckdev->dev))
>                 return NOTIFY_OK;
>
> -       switch (ckdev->ec->event_data.event_type & EC_MKBP_EVENT_TYPE_MASK) {
> +       switch (mkbp_event_type) {
>         case EC_MKBP_EVENT_KEY_MATRIX:
>                 pm_wakeup_event(ckdev->dev, 0);
>
> @@ -264,7 +266,7 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
>         case EC_MKBP_EVENT_SWITCH:
>                 pm_wakeup_event(ckdev->dev, 0);
>
> -               if (ckdev->ec->event_data.event_type == EC_MKBP_EVENT_BUTTON) {
> +               if (mkbp_event_type == EC_MKBP_EVENT_BUTTON) {
>                         val = get_unaligned_le32(
>                                         &ckdev->ec->event_data.data.buttons);
>                         ev_type = EV_KEY;
> --
> 2.23.0.rc1.153.gdeed80330f-goog

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] Input: cros_ec_keyb: Add back missing mask for event_type
  2019-08-13  9:47 ` Nicolas Boichat
@ 2019-08-14 22:06   ` Dmitry Torokhov
  0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2019-08-14 22:06 UTC (permalink / raw)
  To: Nicolas Boichat
  Cc: Fei Shao, Brian Norris, lkml, Ting Shen, Guenter Roeck,
	open list:HID CORE LAYER, Enric Balletbo i Serra, Benson Leung,
	linux-arm Mailing List

On Tue, Aug 13, 2019 at 05:47:22PM +0800, Nicolas Boichat wrote:
> On Tue, Aug 13, 2019 at 5:38 PM Fei Shao <fshao@chromium.org> wrote:
> >
> > In the previous patch we didn't mask out event_type in case statement,
> > so switches are always picked instead of buttons, which results in
> > ChromeOS devices misbehaving when power button is pressed.
> > This patch adds back the missing mask.
> >
> > Fixes: d096aa3eb604 ("Input: cros_ec_keyb: mask out extra flags in event_type")
> > Signed-off-by: Fei Shao <fshao@chromium.org>
> 
> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>

Applied, thank you.

> 
> > ---
> >  drivers/input/keyboard/cros_ec_keyb.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c
> > index 38cb6d82d8fe..bef7bee6f05e 100644
> > --- a/drivers/input/keyboard/cros_ec_keyb.c
> > +++ b/drivers/input/keyboard/cros_ec_keyb.c
> > @@ -226,6 +226,8 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
> >  {
> >         struct cros_ec_keyb *ckdev = container_of(nb, struct cros_ec_keyb,
> >                                                   notifier);
> > +       uint8_t mkbp_event_type = ckdev->ec->event_data.event_type &
> > +                                 EC_MKBP_EVENT_TYPE_MASK;
> >         u32 val;
> >         unsigned int ev_type;
> >
> > @@ -237,7 +239,7 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
> >         if (queued_during_suspend && !device_may_wakeup(ckdev->dev))
> >                 return NOTIFY_OK;
> >
> > -       switch (ckdev->ec->event_data.event_type & EC_MKBP_EVENT_TYPE_MASK) {
> > +       switch (mkbp_event_type) {
> >         case EC_MKBP_EVENT_KEY_MATRIX:
> >                 pm_wakeup_event(ckdev->dev, 0);
> >
> > @@ -264,7 +266,7 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
> >         case EC_MKBP_EVENT_SWITCH:
> >                 pm_wakeup_event(ckdev->dev, 0);
> >
> > -               if (ckdev->ec->event_data.event_type == EC_MKBP_EVENT_BUTTON) {
> > +               if (mkbp_event_type == EC_MKBP_EVENT_BUTTON) {
> >                         val = get_unaligned_le32(
> >                                         &ckdev->ec->event_data.data.buttons);
> >                         ev_type = EV_KEY;
> > --
> > 2.23.0.rc1.153.gdeed80330f-goog

-- 
Dmitry

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-08-14 22:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-13  9:38 [PATCH] Input: cros_ec_keyb: Add back missing mask for event_type Fei Shao
2019-08-13  9:47 ` Nicolas Boichat
2019-08-14 22:06   ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).