Skip to contentSkip to conversation

input: keyboard: imx_sc_key: Only take the valid data from SCU firmware as key state

PATCH Applied Anson Huang 2 participants 2 messages Dec 13, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 input: keyboard: imx_sc_key: Only take the valid data from SCU firmware as key state

When reading key state from SCU, the response data from SCU firmware is 4 bytes due to MU message protocol, but ONLY the first byte is the key state, other 3 bytes could be some dirty data, so we should ONLY take the first byte as key state to avoid reporting incorrect state.

---
 drivers/input/keyboard/imx_sc_key.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/input/keyboard/imx_sc_key.c +7 -1
index 5379952..9f809ae 100644
@@ -78,7 +78,13 @@ static void imx_sc_check_for_events(struct work_struct *work)
 		return;
 	}
 
-	state = (bool)msg.state;
+	/*
+	 * The response data from SCU firmware is 4 bytes,
+	 * but ONLY the first byte is the key state, other
+	 * 3 bytes could be some dirty data, so we should
+	 * ONLY take the first byte as key state.
+	 */
+	state = (bool)(msg.state & 0xff);
 
 	if (state ^ priv->keystate) {
 		priv->keystate = state;
Signature · 1 line
2.7.4
maintainer Applied
#1 lore raw
Quoted 6 lines · Anson Huang

When reading key state from SCU, the response data from SCU firmware is 4 bytes due to MU message protocol, but ONLY the first byte is the key state, other 3 bytes could be some dirty data, so we should ONLY take the first byte as key state to avoid reporting incorrect state.

Applied, thank you.

Quoted 26 lines
---
 drivers/input/keyboard/imx_sc_key.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/input/keyboard/imx_sc_key.c +7 -1
index 5379952..9f809ae 100644
@@ -78,7 +78,13 @@ static void imx_sc_check_for_events(struct work_struct *work)
 		return;
 	}
 
-	state = (bool)msg.state;
+	/*
+	 * The response data from SCU firmware is 4 bytes,
+	 * but ONLY the first byte is the key state, other
+	 * 3 bytes could be some dirty data, so we should
+	 * ONLY take the first byte as key state.
+	 */
+	state = (bool)(msg.state & 0xff);
 
 	if (state ^ priv->keystate) {
 		priv->keystate = state;
Signature · 1 line
2.7.4
Signature · 1 line
Dmitry