mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
platform/chrome: cros_ec_debugfs: Avoid -Wflex-array-member-not-at-end warnings
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are getting ready to enable it, globally. Use the `DEFINE_RAW_FLEX()` helper for an on-stack definition of a flexible structure where the size of the flexible-array member is known at compile-time, and refactor the rest of the code, accordingly. So, with these changes, fix the following warnings: drivers/platform/chrome/cros_ec_debugfs.c:211:40: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/platform/chrome/cros_ec_debugfs.c:257:40: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/platform/chrome/cros_ec_debugfs.c:279: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> Link: https://lore.kernel.org/r/Z-aiAAcIP7sBRtz0@kspp Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
This commit is contained in:
committed by
Tzung-Bi Shih
parent
04251bc866
commit
da90147bf5
@@ -207,22 +207,15 @@ static ssize_t cros_ec_pdinfo_read(struct file *file,
|
||||
char read_buf[EC_USB_PD_MAX_PORTS * 40], *p = read_buf;
|
||||
struct cros_ec_debugfs *debug_info = file->private_data;
|
||||
struct cros_ec_device *ec_dev = debug_info->ec->ec_dev;
|
||||
struct {
|
||||
struct cros_ec_command msg;
|
||||
union {
|
||||
struct ec_response_usb_pd_control_v1 resp;
|
||||
struct ec_params_usb_pd_control params;
|
||||
};
|
||||
} __packed ec_buf;
|
||||
struct cros_ec_command *msg;
|
||||
struct ec_response_usb_pd_control_v1 *resp;
|
||||
struct ec_params_usb_pd_control *params;
|
||||
DEFINE_RAW_FLEX(struct cros_ec_command, msg, data,
|
||||
MAX(sizeof(struct ec_response_usb_pd_control_v1),
|
||||
sizeof(struct ec_params_usb_pd_control)));
|
||||
struct ec_response_usb_pd_control_v1 *resp =
|
||||
(struct ec_response_usb_pd_control_v1 *)msg->data;
|
||||
struct ec_params_usb_pd_control *params =
|
||||
(struct ec_params_usb_pd_control *)msg->data;
|
||||
int i;
|
||||
|
||||
msg = &ec_buf.msg;
|
||||
params = (struct ec_params_usb_pd_control *)msg->data;
|
||||
resp = (struct ec_response_usb_pd_control_v1 *)msg->data;
|
||||
|
||||
msg->command = EC_CMD_USB_PD_CONTROL;
|
||||
msg->version = 1;
|
||||
msg->insize = sizeof(*resp);
|
||||
@@ -253,17 +246,15 @@ static ssize_t cros_ec_pdinfo_read(struct file *file,
|
||||
|
||||
static bool cros_ec_uptime_is_supported(struct cros_ec_device *ec_dev)
|
||||
{
|
||||
struct {
|
||||
struct cros_ec_command cmd;
|
||||
struct ec_response_uptime_info resp;
|
||||
} __packed msg = {};
|
||||
DEFINE_RAW_FLEX(struct cros_ec_command, msg, data,
|
||||
sizeof(struct ec_response_uptime_info));
|
||||
int ret;
|
||||
|
||||
msg.cmd.command = EC_CMD_GET_UPTIME_INFO;
|
||||
msg.cmd.insize = sizeof(msg.resp);
|
||||
msg->command = EC_CMD_GET_UPTIME_INFO;
|
||||
msg->insize = sizeof(struct ec_response_uptime_info);
|
||||
|
||||
ret = cros_ec_cmd_xfer_status(ec_dev, &msg.cmd);
|
||||
if (ret == -EPROTO && msg.cmd.result == EC_RES_INVALID_COMMAND)
|
||||
ret = cros_ec_cmd_xfer_status(ec_dev, msg);
|
||||
if (ret == -EPROTO && msg->result == EC_RES_INVALID_COMMAND)
|
||||
return false;
|
||||
|
||||
/* Other errors maybe a transient error, do not rule about support. */
|
||||
@@ -275,20 +266,17 @@ static ssize_t cros_ec_uptime_read(struct file *file, char __user *user_buf,
|
||||
{
|
||||
struct cros_ec_debugfs *debug_info = file->private_data;
|
||||
struct cros_ec_device *ec_dev = debug_info->ec->ec_dev;
|
||||
struct {
|
||||
struct cros_ec_command cmd;
|
||||
struct ec_response_uptime_info resp;
|
||||
} __packed msg = {};
|
||||
struct ec_response_uptime_info *resp;
|
||||
DEFINE_RAW_FLEX(struct cros_ec_command, msg, data,
|
||||
sizeof(struct ec_response_uptime_info));
|
||||
struct ec_response_uptime_info *resp =
|
||||
(struct ec_response_uptime_info *)msg->data;
|
||||
char read_buf[32];
|
||||
int ret;
|
||||
|
||||
resp = (struct ec_response_uptime_info *)&msg.resp;
|
||||
msg->command = EC_CMD_GET_UPTIME_INFO;
|
||||
msg->insize = sizeof(*resp);
|
||||
|
||||
msg.cmd.command = EC_CMD_GET_UPTIME_INFO;
|
||||
msg.cmd.insize = sizeof(*resp);
|
||||
|
||||
ret = cros_ec_cmd_xfer_status(ec_dev, &msg.cmd);
|
||||
ret = cros_ec_cmd_xfer_status(ec_dev, msg);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user