Skip to contentSkip to conversation

cros_ec: Handling EC_CMD_GET_NEXT_EVENT

PATCH New Heinrich Schuchardt 3 participants 5 messages Nov 9, 2020 – Nov 15, 2020

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

PATCH 1/1 cros_ec: Handling EC_CMD_GET_NEXT_EVENT

With commit 690079767803 ("cros_ec: Support keyboard scanning with EC_CMD_GET_NEXT_EVENT") check_for_keys() tries to read keyboard strokes using EC_CMD_GET_NEXT_EVENT. But the sandbox driver does not understand this command. We need to reply with -EC_RES_INVALID_COMMAND to force check_for_keys() to fall back to use EC_CMD_MKBP_STATE. Currently the driver prints

    ** Unknown EC command 0x67

in this case. With the patch the message is suppressed.

In a future patch we should upgrade the sandbox driver to provide EC_CMD_GET_NEXT_EVENT support.

Fixes 690079767803 ("cros_ec: Support keyboard scanning with EC_CMD_GET_NEXT_EVENT")

---
process_cmd() should always return an appropriate negative enum ec_status in case of an error and not simply -1. But fixing the return values is beyond the scope of this patch.

---
 drivers/misc/cros_ec_sandbox.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/misc/cros_ec_sandbox.c +10 -0
index a191f061b8..ff7f782742 100644
@@ -460,6 +460,16 @@ static int process_cmd(struct ec_state *ec,
 	case EC_CMD_ENTERING_MODE:
 		len = 0;
 		break;
+	case EC_CMD_GET_NEXT_EVENT:
+		/*
+		 * TODO:
+		 * This driver emulates an old keyboard device supporting
+		 * EC_CMD_MKBP_STATE. Current Chrome OS keyboards use
+		 * EC_CMD_GET_NEXT_EVENT. Cf.
+		 * "mkbp: Add support for buttons and switches"
+		 * https://chromium.googlesource.com/chromiumos/platform/ec/+/87a071941b89e3f7fd3eb329b682e60b3fbd6c73
+		 */
+		return -EC_RES_INVALID_COMMAND;
 	default:
 		printf("   ** Unknown EC command %#02x\n", req_hdr->command);
 		return -1;

--
2.28.0

#1 lore raw

PATCH 1/1 cros_ec: Handling EC_CMD_GET_NEXT_EVENT

Quoted 14 lines · Heinrich Schuchardt

With commit 690079767803 ("cros_ec: Support keyboard scanning with EC_CMD_GET_NEXT_EVENT") check_for_keys() tries to read keyboard strokes using EC_CMD_GET_NEXT_EVENT. But the sandbox driver does not understand this command. We need to reply with -EC_RES_INVALID_COMMAND to force check_for_keys() to fall back to use EC_CMD_MKBP_STATE. Currently the driver prints

    ** Unknown EC command 0x67

in this case. With the patch the message is suppressed.

In a future patch we should upgrade the sandbox driver to provide EC_CMD_GET_NEXT_EVENT support.

Quoted 6 lines
Fixes 690079767803 ("cros_ec: Support keyboard scanning with EC_CMD_GET_NEXT_EVENT")

---
process_cmd() should always return an appropriate negative enum ec_status in case of an error and not simply -1. But fixing the return values is beyond the scope of this patch.

(Looks to me like -1 is already == -EC_RES_INVALID_COMMAND from include/ec_commands.h definitions, but I'd agree the latter form should be preferred.)

Quoted 12 lines
---
 drivers/misc/cros_ec_sandbox.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/misc/cros_ec_sandbox.c +0 -0
index a191f061b8..ff7f782742 100644
@@ -460,6 +460,16 @@ static int process_cmd(struct ec_state *ec,
 	case EC_CMD_ENTERING_MODE:
 		len = 0;
 		break;

drivers/misc/cros_ec_sandbox.c static int process_cmd(struct ec_state *ec, · line 472

Quoted 10 lines
drivers/misc/cros_ec_sandbox.c +10 -0
+	case EC_CMD_GET_NEXT_EVENT:
+		/*
+		 * TODO:
+		 * This driver emulates an old keyboard device supporting
+		 * EC_CMD_MKBP_STATE. Current Chrome OS keyboards use
+		 * EC_CMD_GET_NEXT_EVENT. Cf.
+		 * "mkbp: Add support for buttons and switches"
+		 * https://chromium.googlesource.com/chromiumos/platform/ec/+/87a071941b89e3f7fd3eb329b682e60b3fbd6c73
+		 */
+		return -EC_RES_INVALID_COMMAND;

I'll try implementing the TODO, sorry for the fallout.

Quoted 6 lines
drivers/misc/cros_ec_sandbox.c +0 -1
 	default:
 		printf("   ** Unknown EC command %#02x\n", req_hdr->command);
 		return -1;
--

2.28.0

#2 lore raw

PATCH 1/1 cros_ec: Handling EC_CMD_GET_NEXT_EVENT

Quoted 22 lines · Alper Nebi Yasak
Quoted 14 lines · Heinrich Schuchardt

With commit 690079767803 ("cros_ec: Support keyboard scanning with EC_CMD_GET_NEXT_EVENT") check_for_keys() tries to read keyboard strokes using EC_CMD_GET_NEXT_EVENT. But the sandbox driver does not understand this command. We need to reply with -EC_RES_INVALID_COMMAND to force check_for_keys() to fall back to use EC_CMD_MKBP_STATE. Currently the driver prints

    ** Unknown EC command 0x67

in this case. With the patch the message is suppressed.

In a future patch we should upgrade the sandbox driver to provide EC_CMD_GET_NEXT_EVENT support.

Quoted 6 lines
Fixes 690079767803 ("cros_ec: Support keyboard scanning with EC_CMD_GET_NEXT_EVENT")

---
process_cmd() should always return an appropriate negative enum ec_status in case of an error and not simply -1. But fixing the return values is beyond the scope of this patch.

Quoted 3 lines

(Looks to me like -1 is already == -EC_RES_INVALID_COMMAND from include/ec_commands.h definitions, but I'd agree the latter form should be preferred.)

If you look at the complete function, you will find other "return -1;" statements where return codes other than -EC_RES_INVALID_COMMAND make more sense. E.g. after

    printf("** Unknown flash region %d\n", req->region);

it would be reasonable to return EC_RES_INVALID_PARAM.

Best regards

Heinrich

Quoted 32 lines
Quoted 13 lines
---
 drivers/misc/cros_ec_sandbox.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/misc/cros_ec_sandbox.c +0 -0
index a191f061b8..ff7f782742 100644
@@ -460,6 +460,16 @@ static int process_cmd(struct ec_state *ec,
 	case EC_CMD_ENTERING_MODE:
 		len = 0;
 		break;

drivers/misc/cros_ec_sandbox.c static int process_cmd(struct ec_state *ec, · line 472

Quoted 10 lines
drivers/misc/cros_ec_sandbox.c +10 -0
+	case EC_CMD_GET_NEXT_EVENT:
+		/*
+		 * TODO:
+		 * This driver emulates an old keyboard device supporting
+		 * EC_CMD_MKBP_STATE. Current Chrome OS keyboards use
+		 * EC_CMD_GET_NEXT_EVENT. Cf.
+		 * "mkbp: Add support for buttons and switches"
+		 * https://chromium.googlesource.com/chromiumos/platform/ec/+/87a071941b89e3f7fd3eb329b682e60b3fbd6c73
+		 */
+		return -EC_RES_INVALID_COMMAND;

I'll try implementing the TODO, sorry for the fallout.

Quoted 6 lines
drivers/misc/cros_ec_sandbox.c +0 -1
 	default:
 		printf("   ** Unknown EC command %#02x\n", req_hdr->command);
 		return -1;
--

2.28.0

#3 lore raw

PATCH 1/1 cros_ec: Handling EC_CMD_GET_NEXT_EVENT

Hi,

Quoted 32 lines · Heinrich Schuchardt
Quoted 22 lines · Alper Nebi Yasak
Quoted 14 lines · Heinrich Schuchardt

With commit 690079767803 ("cros_ec: Support keyboard scanning with EC_CMD_GET_NEXT_EVENT") check_for_keys() tries to read keyboard strokes using EC_CMD_GET_NEXT_EVENT. But the sandbox driver does not understand this command. We need to reply with -EC_RES_INVALID_COMMAND to force check_for_keys() to fall back to use EC_CMD_MKBP_STATE. Currently the driver prints

    ** Unknown EC command 0x67

in this case. With the patch the message is suppressed.

In a future patch we should upgrade the sandbox driver to provide EC_CMD_GET_NEXT_EVENT support.

Quoted 6 lines
Fixes 690079767803 ("cros_ec: Support keyboard scanning with EC_CMD_GET_NEXT_EVENT")

---
process_cmd() should always return an appropriate negative enum ec_status in case of an error and not simply -1. But fixing the return values is beyond the scope of this patch.

Quoted 3 lines

(Looks to me like -1 is already == -EC_RES_INVALID_COMMAND from include/ec_commands.h definitions, but I'd agree the latter form should be preferred.)

If you look at the complete function, you will find other "return -1;" statements where return codes other than -EC_RES_INVALID_COMMAND make more sense. E.g. after

Quoted 12 lines
    printf("** Unknown flash region %d\n", req->region);

it would be reasonable to return EC_RES_INVALID_PARAM.

Best regards

Heinrich

Quoted 4 lines
Quoted 4 lines
---
 drivers/misc/cros_ec_sandbox.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Shall we take Alper's patch to implement this command?

Regards,
Simon

#4 lore raw

PATCH 1/1 cros_ec: Handling EC_CMD_GET_NEXT_EVENT

Hi,

Quoted 32 lines · Heinrich Schuchardt
Quoted 22 lines · Alper Nebi Yasak
Quoted 14 lines · Heinrich Schuchardt

With commit 690079767803 ("cros_ec: Support keyboard scanning with EC_CMD_GET_NEXT_EVENT") check_for_keys() tries to read keyboard strokes using EC_CMD_GET_NEXT_EVENT. But the sandbox driver does not understand this command. We need to reply with -EC_RES_INVALID_COMMAND to force check_for_keys() to fall back to use EC_CMD_MKBP_STATE. Currently the driver prints

    ** Unknown EC command 0x67

in this case. With the patch the message is suppressed.

In a future patch we should upgrade the sandbox driver to provide EC_CMD_GET_NEXT_EVENT support.

Quoted 6 lines
Fixes 690079767803 ("cros_ec: Support keyboard scanning with EC_CMD_GET_NEXT_EVENT")

---
process_cmd() should always return an appropriate negative enum ec_status in case of an error and not simply -1. But fixing the return values is beyond the scope of this patch.

Quoted 3 lines

(Looks to me like -1 is already == -EC_RES_INVALID_COMMAND from include/ec_commands.h definitions, but I'd agree the latter form should be preferred.)

If you look at the complete function, you will find other "return -1;" statements where return codes other than -EC_RES_INVALID_COMMAND make more sense. E.g. after

Quoted 12 lines
    printf("** Unknown flash region %d\n", req->region);

it would be reasonable to return EC_RES_INVALID_PARAM.

Best regards

Heinrich

Quoted 4 lines
Quoted 4 lines
---
 drivers/misc/cros_ec_sandbox.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Shall we take Alper's patch to implement this command?

Regards,
Simon

Applied to u-boot-dm, thanks!