From 2049c3f715ab4f60fcde66172c9c0ff93af1d893 Mon Sep 17 00:00:00 2001 From: Tomasz Michalec Date: Wed, 1 Dec 2021 15:08:12 +0100 Subject: zephyr: drivers: Extend BUILD_HOST_COMMAND macro Now BUILD_HOST_COMMAND macro accepts params argument to setup parameters of host command. New variants of BUILD_HOST_COMMAND are added: - BUILD_HOST_COMMAND_RESPONSE - BUILD_HOST_COMMAND_PARAMS - BUILD_HOST_COMMAND_SIMPLE They allow to declare host command with only response, params or neither. The response_size field is intentionally set to 0, because this is default value. Command returning data should update this field. BUG=none BRANCH=none TEST=make configure --test zephyr/test/drivers Signed-off-by: Tomasz Michalec Change-Id: I31021db3790dfa3e0ad15128daf455d14a9c071c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3310858 Tested-by: Tomasz Michalec Commit-Queue: Tomasz Michalec Reviewed-by: Jack Rosenthal --- include/host_command.h | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/host_command.h b/include/host_command.h index 8a66776ce9..74f68f9891 100644 --- a/include/host_command.h +++ b/include/host_command.h @@ -358,13 +358,29 @@ stub_send_response_callback(struct host_cmd_handler_args *args) ARG_UNUSED(args); } -#define BUILD_HOST_COMMAND(CMD, VERSION, RESPONSE) \ - { \ - .command = (CMD), .version = (VERSION), \ - .send_response = stub_send_response_callback, \ - .response = &(RESPONSE), .response_max = sizeof(RESPONSE), \ - .response_size = sizeof(RESPONSE) \ +#define BUILD_HOST_COMMAND(CMD, VERSION, RESPONSE, PARAMS) \ + { \ + .command = (CMD), .version = (VERSION), \ + .send_response = stub_send_response_callback, \ + .response_size = 0, \ + COND_CODE_0(IS_EMPTY(RESPONSE), \ + (.response = &(RESPONSE), \ + .response_max = sizeof(RESPONSE)), \ + (.response = NULL, .response_max = 0)), \ + COND_CODE_0(IS_EMPTY(PARAMS), \ + (.params = &(PARAMS), \ + .params_size = sizeof(PARAMS)), \ + (.params = NULL, .params_size = 0)) \ } + +#define BUILD_HOST_COMMAND_RESPONSE(CMD, VERSION, RESPONSE) \ + BUILD_HOST_COMMAND(CMD, VERSION, RESPONSE, EMPTY) + +#define BUILD_HOST_COMMAND_PARAMS(CMD, VERSION, PARAMS) \ + BUILD_HOST_COMMAND(CMD, VERSION, EMPTY, PARAMS) + +#define BUILD_HOST_COMMAND_SIMPLE(CMD, VERSION) \ + BUILD_HOST_COMMAND(CMD, VERSION, EMPTY, EMPTY) #endif /* CONFIG_ZTEST */ #endif /* __CROS_EC_HOST_COMMAND_H */ -- cgit v1.2.1