Skip to contentSkip to conversation

platform/x86: intel-vbtn: Report switch events when event wakes device

PATCH In review Mathew King 4 participants 4 messages May 20, 2019 – May 24, 2019 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 platform/x86: intel-vbtn: Report switch events when event wakes device

When a switch event, such as tablet mode/laptop mode or docked/undocked, wakes a device make sure that the value of the swich is reported. Without when a device is put in tablet mode from laptop mode when it is suspended or vice versa the device will wake up but mode will be incorrect.

Tested by suspending a device in laptop mode and putting it in tablet mode, the device resumes and is in tablet mode. When suspending the device in tablet mode and putting it in laptop mode the device resumes and is in laptop mode.

---
Changes in v2:
- Added comment explaining why switch events are reported
- Format so that checkpatch is happy

---
 drivers/platform/x86/intel-vbtn.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/platform/x86/intel-vbtn.c +14 -2
index 06cd7e818ed5..a0d0cecff55f 100644
@@ -76,12 +76,24 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
 	struct platform_device *device = context;
 	struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev);
 	unsigned int val = !(event & 1); /* Even=press, Odd=release */
-	const struct key_entry *ke_rel;
+	const struct key_entry *ke, *ke_rel;
 	bool autorelease;
 
 	if (priv->wakeup_mode) {
-		if (sparse_keymap_entry_from_scancode(priv->input_dev, event)) {
+		ke = sparse_keymap_entry_from_scancode(priv->input_dev, event);
+		if (ke) {
 			pm_wakeup_hard_event(&device->dev);
+
+			/*
+			 * Switch events like tablet mode will wake the device
+			 * and report the new switch position to the input
+			 * subsystem.
+			 */
+			if (ke->type == KE_SW)
+				sparse_keymap_report_event(priv->input_dev,
+							   event,
+							   val,
+							   0);
 			return;
 		}
 		goto out_unknown;
Signature · 1 line
2.21.0.1020.gf2820cf01a-goog
Reviewed-by on v2 1/1
#1 lore raw
Quoted 35 lines · Mathew King

When a switch event, such as tablet mode/laptop mode or docked/undocked, wakes a device make sure that the value of the swich is reported. Without when a device is put in tablet mode from laptop mode when it is suspended or vice versa the device will wake up but mode will be incorrect.

Tested by suspending a device in laptop mode and putting it in tablet mode, the device resumes and is in tablet mode. When suspending the device in tablet mode and putting it in laptop mode the device resumes and is in laptop mode.

---
Changes in v2:
- Added comment explaining why switch events are reported
- Format so that checkpatch is happy

---
 drivers/platform/x86/intel-vbtn.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/platform/x86/intel-vbtn.c +1 -1
index 06cd7e818ed5..a0d0cecff55f 100644
@@ -76,12 +76,24 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
        struct platform_device *device = context;
        struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev);
        unsigned int val = !(event & 1); /* Even=press, Odd=release */
-       const struct key_entry *ke_rel;
+       const struct key_entry *ke, *ke_rel;
        bool autorelease;
 
        if (priv->wakeup_mode) {

drivers/platform/x86/intel-vbtn.c static void notify_handler(acpi_handle handle, u32 event, void *context) · line 91

Quoted 10 lines
drivers/platform/x86/intel-vbtn.c +8 -1
-               if (sparse_keymap_entry_from_scancode(priv->input_dev, event)) {
+               ke = sparse_keymap_entry_from_scancode(priv->input_dev, event);
+               if (ke) {
                        pm_wakeup_hard_event(&device->dev);
+
+                       /*
+                        * Switch events like tablet mode will wake the device
+                        * and report the new switch position to the input
+                        * subsystem.
+                        */

Thanks for adding the comment; This looks good to me.

Quoted 11 lines
drivers/platform/x86/intel-vbtn.c +5 -1
+                       if (ke->type == KE_SW)
+                               sparse_keymap_report_event(priv->input_dev,
+                                                          event,
+                                                          val,
+                                                          0);
                        return;
                }
                goto out_unknown;
--

2.21.0.1020.gf2820cf01a-goog

Reviewed-by
#2 lore raw
Quoted 74 lines

-----Original Message-----
From: Jett Rink <[email protected]>
Sent: Tuesday, May 21, 2019 8:37 AM
To: Mathew King
Cc: linux-kernel; AceLan Kao; Andy Shevchenko; Darren Hart; platform-driver- [email protected]; Limonciello, Mario
Subject: Re: [PATCH v2] platform/x86: intel-vbtn: Report switch events when event wakes device

[EXTERNAL EMAIL]

drivers/platform/x86/intel-vbtn.c static void notify_handler(acpi_handle handle, u32

Quoted 27 lines · Mathew King

When a switch event, such as tablet mode/laptop mode or docked/undocked, wakes a device make sure that the value of the swich is reported. Without when a device is put in tablet mode from laptop mode when it is suspended or vice versa the device will wake up but mode will be incorrect.

Tested by suspending a device in laptop mode and putting it in tablet mode, the device resumes and is in tablet mode. When suspending the device in tablet mode and putting it in laptop mode the device resumes and is in laptop mode.

---
Changes in v2:
- Added comment explaining why switch events are reported
- Format so that checkpatch is happy

---
 drivers/platform/x86/intel-vbtn.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/platform/x86/intel-vbtn.c +0 -0
index 06cd7e818ed5..a0d0cecff55f 100644
@@ -76,12 +76,24 @@ static void notify_handler(acpi_handle handle, u32

event, void *context)

Quoted 8 lines
drivers/platform/x86/intel-vbtn.c +1 -1
        struct platform_device *device = context;
        struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev);
        unsigned int val = !(event & 1); /* Even=press, Odd=release */
-       const struct key_entry *ke_rel;
+       const struct key_entry *ke, *ke_rel;
        bool autorelease;
 
        if (priv->wakeup_mode) {

drivers/platform/x86/intel-vbtn.c static void notify_handler(acpi_handle handle, u32 event, void *context) · line 91

Quoted 10 lines
drivers/platform/x86/intel-vbtn.c +8 -1
-               if (sparse_keymap_entry_from_scancode(priv->input_dev, event)) {
+               ke = sparse_keymap_entry_from_scancode(priv->input_dev, event);
+               if (ke) {
                        pm_wakeup_hard_event(&device->dev);
+
+                       /*
+                        * Switch events like tablet mode will wake the device
+                        * and report the new switch position to the input
+                        * subsystem.
+                        */

Thanks for adding the comment; This looks good to me.

Quoted 11 lines
drivers/platform/x86/intel-vbtn.c +5 -1
+                       if (ke->type == KE_SW)
+                               sparse_keymap_report_event(priv->input_dev,
+                                                          event,
+                                                          val,
+                                                          0);
                        return;
                }
                goto out_unknown;
--

2.21.0.1020.gf2820cf01a-goog

Quoted 1 line
#3 lore raw
Quoted 11 lines · On Tue, May 21, 2019 at 4:43 PM <[email protected]> wrote:
Quoted 11 lines

-----Original Message-----
From: Jett Rink <[email protected]>
Sent: Tuesday, May 21, 2019 8:37 AM
To: Mathew King
Cc: linux-kernel; AceLan Kao; Andy Shevchenko; Darren Hart; platform-driver- [email protected]; Limonciello, Mario
Subject: Re: [PATCH v2] platform/x86: intel-vbtn: Report switch events when event wakes device

Pushed to my review and testing queue, thanks!

Quoted 67 lines
Quoted 64 lines

[EXTERNAL EMAIL]

drivers/platform/x86/intel-vbtn.c static void notify_handler(acpi_handle handle, u32

Quoted 27 lines · Mathew King

When a switch event, such as tablet mode/laptop mode or docked/undocked, wakes a device make sure that the value of the swich is reported. Without when a device is put in tablet mode from laptop mode when it is suspended or vice versa the device will wake up but mode will be incorrect.

Tested by suspending a device in laptop mode and putting it in tablet mode, the device resumes and is in tablet mode. When suspending the device in tablet mode and putting it in laptop mode the device resumes and is in laptop mode.

---
Changes in v2:
- Added comment explaining why switch events are reported
- Format so that checkpatch is happy

---
 drivers/platform/x86/intel-vbtn.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/platform/x86/intel-vbtn.c +0 -0
index 06cd7e818ed5..a0d0cecff55f 100644
@@ -76,12 +76,24 @@ static void notify_handler(acpi_handle handle, u32

event, void *context)

Quoted 8 lines
drivers/platform/x86/intel-vbtn.c +1 -1
        struct platform_device *device = context;
        struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev);
        unsigned int val = !(event & 1); /* Even=press, Odd=release */
-       const struct key_entry *ke_rel;
+       const struct key_entry *ke, *ke_rel;
        bool autorelease;
 
        if (priv->wakeup_mode) {

drivers/platform/x86/intel-vbtn.c static void notify_handler(acpi_handle handle, u32 event, void *context) · line 91

Quoted 10 lines
drivers/platform/x86/intel-vbtn.c +8 -1
-               if (sparse_keymap_entry_from_scancode(priv->input_dev, event)) {
+               ke = sparse_keymap_entry_from_scancode(priv->input_dev, event);
+               if (ke) {
                        pm_wakeup_hard_event(&device->dev);
+
+                       /*
+                        * Switch events like tablet mode will wake the device
+                        * and report the new switch position to the input
+                        * subsystem.
+                        */

Thanks for adding the comment; This looks good to me.

Quoted 11 lines
drivers/platform/x86/intel-vbtn.c +5 -1
+                       if (ke->type == KE_SW)
+                               sparse_keymap_report_event(priv->input_dev,
+                                                          event,
+                                                          val,
+                                                          0);
                        return;
                }
                goto out_unknown;
--

2.21.0.1020.gf2820cf01a-goog

Quoted 1 line
Signature · 2 lines
With Best Regards,
Andy Shevchenko