diff options
author | Tomasz Michalec <tm@semihalf.com> | 2021-12-01 15:08:12 +0100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-12-03 06:45:34 +0000 |
commit | 2049c3f715ab4f60fcde66172c9c0ff93af1d893 (patch) | |
tree | 49bdb6abcb8a401ce1a2515056a0e9bd25e1c9fb /include | |
parent | b30c15a73448eed93c6d6997a033d706c0541b50 (diff) | |
download | chrome-ec-2049c3f715ab4f60fcde66172c9c0ff93af1d893.tar.gz |
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 <tm@semihalf.com>
Change-Id: I31021db3790dfa3e0ad15128daf455d14a9c071c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3310858
Tested-by: Tomasz Michalec <tmichalec@google.com>
Commit-Queue: Tomasz Michalec <tmichalec@google.com>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/host_command.h | 28 |
1 files changed, 22 insertions, 6 deletions
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 */ |