aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mfd
diff options
context:
space:
mode:
authorJavier Martinez Canillas <javier.martinez@collabora.co.uk>2015-06-09 07:04:42 -0400
committerLee Jones <lee.jones@linaro.org>2015-06-15 08:18:19 -0400
commita841178445bb72a3d566b4e6ab9d19e9b002eb47 (patch)
treebdc857e82c9c9e8b49bd5471efa5a954673d58f0 /include/linux/mfd
parentbb03ffb96c72418d06e75c7b74ea62e04c78d322 (diff)
mfd: cros_ec: Use a zero-length array for command data
Commit 1b84f2a4cd4a ("mfd: cros_ec: Use fixed size arrays to transfer data with the EC") modified the struct cros_ec_command fields to not use pointers for the input and output buffers and use fixed length arrays instead. This change was made because the cros_ec ioctl API uses that struct cros_ec_command to allow user-space to send commands to the EC and to get data from the EC. So using pointers made the API not 64-bit safe. Unfortunately this approach was not flexible enough for all the use-cases since there may be a need to send larger commands on newer versions of the EC command protocol. So to avoid to choose a constant length that it may be too big for most commands and thus wasting memory and CPU cycles on copy from and to user-space or having a size that is too small for some big commands, use a zero-length array that is both 64-bit safe and flexible. The same buffer is used for both output and input data so the maximum of these values should be used to allocate it. Suggested-by: Gwendal Grignou <gwendal@chromium.org> Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Tested-by: Heiko Stuebner <heiko@sntech.de> Acked-by: Lee Jones <lee.jones@linaro.org> Acked-by: Olof Johansson <olof@lixom.net> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'include/linux/mfd')
-rw-r--r--include/linux/mfd/cros_ec.h6
1 files changed, 2 insertions, 4 deletions
diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h
index 14cf522123dd..7eee38abd02a 100644
--- a/include/linux/mfd/cros_ec.h
+++ b/include/linux/mfd/cros_ec.h
@@ -42,8 +42,7 @@ enum {
42 * @outsize: Outgoing length in bytes 42 * @outsize: Outgoing length in bytes
43 * @insize: Max number of bytes to accept from EC 43 * @insize: Max number of bytes to accept from EC
44 * @result: EC's response to the command (separate from communication failure) 44 * @result: EC's response to the command (separate from communication failure)
45 * @outdata: Outgoing data to EC 45 * @data: Where to put the incoming data from EC and outgoing data to EC
46 * @indata: Where to put the incoming data from EC
47 */ 46 */
48struct cros_ec_command { 47struct cros_ec_command {
49 uint32_t version; 48 uint32_t version;
@@ -51,8 +50,7 @@ struct cros_ec_command {
51 uint32_t outsize; 50 uint32_t outsize;
52 uint32_t insize; 51 uint32_t insize;
53 uint32_t result; 52 uint32_t result;
54 uint8_t outdata[EC_PROTO2_MAX_PARAM_SIZE]; 53 uint8_t data[0];
55 uint8_t indata[EC_PROTO2_MAX_PARAM_SIZE];
56}; 54};
57 55
58/** 56/**