]> www.infradead.org Git - linux.git/commitdiff
power: supply: cros_charge-control: Avoid -Wflex-array-member-not-at-end warning
authorGustavo A. R. Silva <gustavoars@kernel.org>
Tue, 29 Apr 2025 20:03:40 +0000 (14:03 -0600)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Tue, 29 Apr 2025 21:58:33 +0000 (23:58 +0200)
-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>
drivers/power/supply/cros_charge-control.c

index 02d5bdbe2e8d45108dd8f2d3ab6a927b94864b9e..53e6a77e03fcff4891bcfb62853809ea6ad67125 100644 (file)
@@ -47,29 +47,20 @@ struct cros_chctl_priv {
 static int cros_chctl_send_charge_control_cmd(struct cros_ec_device *cros_ec,
                                              u8 cmd_version, struct ec_params_charge_control *req)
 {
+       int ret;
        static const u8 outsizes[] = {
                [1] = offsetof(struct ec_params_charge_control, cmd),
                [2] = sizeof(struct ec_params_charge_control),
                [3] = sizeof(struct ec_params_charge_control),
        };
 
-       struct {
-               struct cros_ec_command msg;
-               union {
-                       struct ec_params_charge_control req;
-                       struct ec_response_charge_control resp;
-               } __packed data;
-       } __packed buf = {
-               .msg = {
-                       .command = EC_CMD_CHARGE_CONTROL,
-                       .version = cmd_version,
-                       .insize  = 0,
-                       .outsize = outsizes[cmd_version],
-               },
-               .data.req = *req,
-       };
+       ret = cros_ec_cmd(cros_ec, cmd_version, EC_CMD_CHARGE_CONTROL, req,
+                         outsizes[cmd_version], NULL, 0);
+
+       if (ret < 0)
+               return ret;
 
-       return cros_ec_cmd_xfer_status(cros_ec, &buf.msg);
+       return 0;
 }
 
 static int cros_chctl_configure_ec(struct cros_chctl_priv *priv)