From 1ca7e782864222bcdbe305e543df25df4e343963 Mon Sep 17 00:00:00 2001 From: Tomas Winkler Date: Sun, 26 Feb 2012 23:18:57 +0200 Subject: [PATCH] staging: mei: kill struct hbm_cmd bit fields Replace bitfield struct hbm_cmd with simple u8 as we always access the value as whole. This allows us to remove few ugly type casts For possible further uses and documentation purposes we add corresponding bitmask defines Signed-off-by: Tomas Winkler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mei/hw.h | 43 ++++++++++++++++----------------- drivers/staging/mei/init.c | 6 ++--- drivers/staging/mei/interface.c | 6 ++--- drivers/staging/mei/interrupt.c | 9 +++---- 4 files changed, 31 insertions(+), 33 deletions(-) diff --git a/drivers/staging/mei/hw.h b/drivers/staging/mei/hw.h index f86a213c372d..24c4c962819e 100644 --- a/drivers/staging/mei/hw.h +++ b/drivers/staging/mei/hw.h @@ -141,6 +141,11 @@ access to ME_CBD */ #define HBM_MAJOR_VERSION 1 #define HBM_TIMEOUT 1 /* 1 second */ +/* Host bus message command opcode */ +#define MEI_HBM_CMD_OP_MSK 0x7f +/* Host bus message command RESPONSE */ +#define MEI_HBM_CMD_RES_MSK 0x80 + /* * MEI Bus Message Command IDs */ @@ -164,7 +169,7 @@ access to ME_CBD */ #define CLIENT_DISCONNECT_REQ_CMD 0x07 #define CLIENT_DISCONNECT_RES_CMD 0x87 -#define MEI_FLOW_CONTROL_CMD 0x08 +#define MEI_FLOW_CONTROL_CMD 0x08 /* * MEI Stop Reason @@ -213,15 +218,9 @@ struct mei_msg_hdr { } __packed; -struct hbm_cmd { - u8 cmd:7; - u8 is_response:1; -} __packed; - - struct mei_bus_message { - struct hbm_cmd cmd; - u8 command_specific_data[]; + u8 hbm_cmd; + u8 data[0]; } __packed; struct hbm_version { @@ -230,41 +229,41 @@ struct hbm_version { } __packed; struct hbm_host_version_request { - struct hbm_cmd cmd; + u8 hbm_cmd; u8 reserved; struct hbm_version host_version; } __packed; struct hbm_host_version_response { - struct hbm_cmd cmd; + u8 hbm_cmd; u8 host_version_supported; struct hbm_version me_max_version; } __packed; struct hbm_host_stop_request { - struct hbm_cmd cmd; + u8 hbm_cmd; u8 reason; u8 reserved[2]; } __packed; struct hbm_host_stop_response { - struct hbm_cmd cmd; + u8 hbm_cmd; u8 reserved[3]; } __packed; struct hbm_me_stop_request { - struct hbm_cmd cmd; + u8 hbm_cmd; u8 reason; u8 reserved[2]; } __packed; struct hbm_host_enum_request { - struct hbm_cmd cmd; + u8 hbm_cmd; u8 reserved[3]; } __packed; struct hbm_host_enum_response { - struct hbm_cmd cmd; + u8 hbm_cmd; u8 reserved[3]; u8 valid_addresses[32]; } __packed; @@ -279,14 +278,14 @@ struct mei_client_properties { } __packed; struct hbm_props_request { - struct hbm_cmd cmd; + u8 hbm_cmd; u8 address; u8 reserved[2]; } __packed; struct hbm_props_response { - struct hbm_cmd cmd; + u8 hbm_cmd; u8 address; u8 status; u8 reserved[1]; @@ -294,21 +293,21 @@ struct hbm_props_response { } __packed; struct hbm_client_connect_request { - struct hbm_cmd cmd; + u8 hbm_cmd; u8 me_addr; u8 host_addr; u8 reserved; } __packed; struct hbm_client_connect_response { - struct hbm_cmd cmd; + u8 hbm_cmd; u8 me_addr; u8 host_addr; u8 status; } __packed; struct hbm_client_disconnect_request { - struct hbm_cmd cmd; + u8 hbm_cmd; u8 me_addr; u8 host_addr; u8 reserved[1]; @@ -317,7 +316,7 @@ struct hbm_client_disconnect_request { #define MEI_FC_MESSAGE_RESERVED_LENGTH 5 struct hbm_flow_control { - struct hbm_cmd cmd; + u8 hbm_cmd; u8 me_addr; u8 host_addr; u8 reserved[MEI_FC_MESSAGE_RESERVED_LENGTH]; diff --git a/drivers/staging/mei/init.c b/drivers/staging/mei/init.c index 393da4bb2022..e24b6ad3d5fb 100644 --- a/drivers/staging/mei/init.c +++ b/drivers/staging/mei/init.c @@ -362,7 +362,7 @@ void mei_host_start_message(struct mei_device *dev) host_start_req = (struct hbm_host_version_request *) &dev->wr_msg_buf[1]; memset(host_start_req, 0, sizeof(struct hbm_host_version_request)); - host_start_req->cmd.cmd = HOST_START_REQ_CMD; + host_start_req->hbm_cmd = HOST_START_REQ_CMD; host_start_req->host_version.major_version = HBM_MAJOR_VERSION; host_start_req->host_version.minor_version = HBM_MINOR_VERSION; dev->recvd_msg = false; @@ -398,7 +398,7 @@ void mei_host_enum_clients_message(struct mei_device *dev) host_enum_req = (struct hbm_host_enum_request *) &dev->wr_msg_buf[1]; memset(host_enum_req, 0, sizeof(struct hbm_host_enum_request)); - host_enum_req->cmd.cmd = HOST_ENUM_REQ_CMD; + host_enum_req->hbm_cmd = HOST_ENUM_REQ_CMD; if (!mei_write_message(dev, mei_hdr, (unsigned char *)host_enum_req, mei_hdr->length)) { dev->mei_state = MEI_RESETING; @@ -482,7 +482,7 @@ int mei_host_client_properties(struct mei_device *dev) memset(host_cli_req, 0, sizeof(struct hbm_props_request)); - host_cli_req->cmd.cmd = HOST_CLIENT_PROPERTIES_REQ_CMD; + host_cli_req->hbm_cmd = HOST_CLIENT_PROPERTIES_REQ_CMD; host_cli_req->address = b; if (!mei_write_message(dev, mei_header, diff --git a/drivers/staging/mei/interface.c b/drivers/staging/mei/interface.c index 484be56a6594..a873be750874 100644 --- a/drivers/staging/mei/interface.c +++ b/drivers/staging/mei/interface.c @@ -326,7 +326,7 @@ int mei_send_flow_control(struct mei_device *dev, struct mei_cl *cl) memset(mei_flow_control, 0, sizeof(*mei_flow_control)); mei_flow_control->host_addr = cl->host_client_id; mei_flow_control->me_addr = cl->me_client_id; - mei_flow_control->cmd.cmd = MEI_FLOW_CONTROL_CMD; + mei_flow_control->hbm_cmd = MEI_FLOW_CONTROL_CMD; memset(mei_flow_control->reserved, 0, sizeof(mei_flow_control->reserved)); dev_dbg(&dev->pdev->dev, "sending flow control host client = %d, ME client = %d\n", @@ -390,7 +390,7 @@ int mei_disconnect(struct mei_device *dev, struct mei_cl *cl) memset(mei_cli_disconnect, 0, sizeof(*mei_cli_disconnect)); mei_cli_disconnect->host_addr = cl->host_client_id; mei_cli_disconnect->me_addr = cl->me_client_id; - mei_cli_disconnect->cmd.cmd = CLIENT_DISCONNECT_REQ_CMD; + mei_cli_disconnect->hbm_cmd = CLIENT_DISCONNECT_REQ_CMD; mei_cli_disconnect->reserved[0] = 0; if (!mei_write_message(dev, mei_hdr, @@ -425,7 +425,7 @@ int mei_connect(struct mei_device *dev, struct mei_cl *cl) (struct hbm_client_connect_request *) &dev->wr_msg_buf[1]; mei_cli_connect->host_addr = cl->host_client_id; mei_cli_connect->me_addr = cl->me_client_id; - mei_cli_connect->cmd.cmd = CLIENT_CONNECT_REQ_CMD; + mei_cli_connect->hbm_cmd = CLIENT_CONNECT_REQ_CMD; mei_cli_connect->reserved = 0; if (!mei_write_message(dev, mei_hdr, diff --git a/drivers/staging/mei/interrupt.c b/drivers/staging/mei/interrupt.c index 8a9044ba3573..ce14e399adab 100644 --- a/drivers/staging/mei/interrupt.c +++ b/drivers/staging/mei/interrupt.c @@ -597,8 +597,7 @@ static void mei_client_disconnect_request(struct mei_device *dev, &dev->ext_msg_buf[1]; disconnect_res->host_addr = cl_pos->host_client_id; disconnect_res->me_addr = cl_pos->me_client_id; - *(u8 *) (&disconnect_res->cmd) = - CLIENT_DISCONNECT_RES_CMD; + disconnect_res->hbm_cmd = CLIENT_DISCONNECT_RES_CMD; disconnect_res->status = 0; dev->extra_write_index = 2; break; @@ -634,7 +633,7 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev, mei_read_slots(dev, dev->rd_msg_buf, mei_hdr->length); mei_msg = (struct mei_bus_message *)dev->rd_msg_buf; - switch (*(u8 *) mei_msg) { + switch (mei_msg->hbm_cmd) { case HOST_START_RES_CMD: version_res = (struct hbm_host_version_response *) mei_msg; if (version_res->host_version_supported) { @@ -665,7 +664,7 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev, memset(host_stop_req, 0, sizeof(struct hbm_host_stop_request)); - host_stop_req->cmd.cmd = HOST_STOP_REQ_CMD; + host_stop_req->hbm_cmd = HOST_STOP_REQ_CMD; host_stop_req->reason = DRIVER_STOP_REQUEST; mei_write_message(dev, mei_hdr, (unsigned char *) (host_stop_req), @@ -805,7 +804,7 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev, host_stop_req = (struct hbm_host_stop_request *) &dev->ext_msg_buf[1]; memset(host_stop_req, 0, sizeof(struct hbm_host_stop_request)); - host_stop_req->cmd.cmd = HOST_STOP_REQ_CMD; + host_stop_req->hbm_cmd = HOST_STOP_REQ_CMD; host_stop_req->reason = DRIVER_STOP_REQUEST; host_stop_req->reserved[0] = 0; host_stop_req->reserved[1] = 0; -- 2.20.1