usb_update: check touchpad_info size at build time

Current protocol will not work if touchpad_info is more than 50 bytes.
Assert this constrain at build time.

BRANCH=none
BUG=b:70482333
TEST=make BOARD=hammer
Signed-off-by: Wei-Han Chen <stimim@chromium.org>

Change-Id: I9bf163f77f14c7d475fc8a2f422ce596dc89c61e
Reviewed-on: https://chromium-review.googlesource.com/958893
Commit-Ready: Wei-Han Chen <stimim@chromium.org>
Tested-by: Wei-Han Chen <stimim@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
This commit is contained in:
Wei-Han Chen
2018-03-12 20:11:23 +08:00
committed by chrome-bot
parent 9a8e4226c3
commit aab7366187

View File

@@ -8,6 +8,7 @@
#include <stddef.h>
#include "compile_time_macros.h"
/*
* This file contains structures used to facilitate EC firmware updates
@@ -217,6 +218,14 @@ struct touchpad_info {
} elan;
} __packed;
/*
* The response message must not exceed 64 bytes.
* And our protocol has a 14 bytes header.
* So the size of `struct touchpad_info` must be less
* than or equal to 50 bytes
*/
BUILD_ASSERT(sizeof(struct touchpad_info) <= 50);
void fw_update_command_handler(void *body,
size_t cmd_size,
size_t *response_size);