-
- Downloads
mfd: cros_ec: Use a zero-length array for command data
Commit 1b84f2a4 ("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>
Showing
- drivers/i2c/busses/i2c-cros-ec-tunnel.c 30 additions, 15 deletionsdrivers/i2c/busses/i2c-cros-ec-tunnel.c
- drivers/input/keyboard/cros_ec_keyb.c 19 additions, 10 deletionsdrivers/input/keyboard/cros_ec_keyb.c
- drivers/mfd/cros_ec.c 20 additions, 8 deletionsdrivers/mfd/cros_ec.c
- drivers/mfd/cros_ec_i2c.c 2 additions, 2 deletionsdrivers/mfd/cros_ec_i2c.c
- drivers/mfd/cros_ec_spi.c 1 addition, 1 deletiondrivers/mfd/cros_ec_spi.c
- drivers/platform/chrome/cros_ec_dev.c 42 additions, 23 deletionsdrivers/platform/chrome/cros_ec_dev.c
- drivers/platform/chrome/cros_ec_lightbar.c 103 additions, 49 deletionsdrivers/platform/chrome/cros_ec_lightbar.c
- drivers/platform/chrome/cros_ec_lpc.c 4 additions, 4 deletionsdrivers/platform/chrome/cros_ec_lpc.c
- drivers/platform/chrome/cros_ec_sysfs.c 95 additions, 59 deletionsdrivers/platform/chrome/cros_ec_sysfs.c
- include/linux/mfd/cros_ec.h 2 additions, 4 deletionsinclude/linux/mfd/cros_ec.h
Loading
Please register or sign in to comment