Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

power: supply: cros_charge-control: Avoid -Wflex-array-member-not-at-end warning

-Wflex-array-member-not-at-end was introduced in GCC-14, and we are
getting ready to enable it, globally.

Replace an on-stack definition of a flexible structure with a call
to utility function cros_ec_cmd().

So, with these changes, fix the following warning:

drivers/power/supply/cros_charge-control.c:57:40: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Acked-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/aBEwnKtUOTYzS7C3@kspp
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

authored by

Gustavo A. R. Silva and committed by
Sebastian Reichel
d4d2dc1b 18672fe1

+7 -16
+7 -16
drivers/power/supply/cros_charge-control.c
··· 47 47 static int cros_chctl_send_charge_control_cmd(struct cros_ec_device *cros_ec, 48 48 u8 cmd_version, struct ec_params_charge_control *req) 49 49 { 50 + int ret; 50 51 static const u8 outsizes[] = { 51 52 [1] = offsetof(struct ec_params_charge_control, cmd), 52 53 [2] = sizeof(struct ec_params_charge_control), 53 54 [3] = sizeof(struct ec_params_charge_control), 54 55 }; 55 56 56 - struct { 57 - struct cros_ec_command msg; 58 - union { 59 - struct ec_params_charge_control req; 60 - struct ec_response_charge_control resp; 61 - } __packed data; 62 - } __packed buf = { 63 - .msg = { 64 - .command = EC_CMD_CHARGE_CONTROL, 65 - .version = cmd_version, 66 - .insize = 0, 67 - .outsize = outsizes[cmd_version], 68 - }, 69 - .data.req = *req, 70 - }; 57 + ret = cros_ec_cmd(cros_ec, cmd_version, EC_CMD_CHARGE_CONTROL, req, 58 + outsizes[cmd_version], NULL, 0); 71 59 72 - return cros_ec_cmd_xfer_status(cros_ec, &buf.msg); 60 + if (ret < 0) 61 + return ret; 62 + 63 + return 0; 73 64 } 74 65 75 66 static int cros_chctl_configure_ec(struct cros_chctl_priv *priv)