mei: use the same bus msg for connect and disconnect request

structs hbm_client_connect_request and hbm_client_disconnect_request
have the same layout so we can drop the later

Add kdoc for the request and response structure so it is clear
they can be used for both purposes

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Tomas Winkler 2012-11-11 17:38:04 +02:00 коммит произвёл Greg Kroah-Hartman
Родитель ff8b2f4e42
Коммит aeba4a06f2
3 изменённых файлов: 34 добавлений и 27 удалений

Просмотреть файл

@ -293,6 +293,14 @@ struct hbm_props_response {
struct mei_client_properties client_properties; struct mei_client_properties client_properties;
} __packed; } __packed;
/**
* struct hbm_client_connect_request - connect/disconnect request
*
* @hbm_cmd - bus message command header
* @me_addr - address of the client in ME
* @host_addr - address of the client in the driver
* @reserved
*/
struct hbm_client_connect_request { struct hbm_client_connect_request {
u8 hbm_cmd; u8 hbm_cmd;
u8 me_addr; u8 me_addr;
@ -300,6 +308,14 @@ struct hbm_client_connect_request {
u8 reserved; u8 reserved;
} __packed; } __packed;
/**
* struct hbm_client_connect_response - connect/disconnect response
*
* @hbm_cmd - bus message command header
* @me_addr - address of the client in ME
* @host_addr - address of the client in the driver
* @status - status of the request
*/
struct hbm_client_connect_response { struct hbm_client_connect_response {
u8 hbm_cmd; u8 hbm_cmd;
u8 me_addr; u8 me_addr;
@ -307,12 +323,6 @@ struct hbm_client_connect_response {
u8 status; u8 status;
} __packed; } __packed;
struct hbm_client_disconnect_request {
u8 hbm_cmd;
u8 me_addr;
u8 host_addr;
u8 reserved[1];
} __packed;
#define MEI_FC_MESSAGE_RESERVED_LENGTH 5 #define MEI_FC_MESSAGE_RESERVED_LENGTH 5

Просмотреть файл

@ -352,26 +352,24 @@ int mei_other_client_is_connecting(struct mei_device *dev,
int mei_disconnect(struct mei_device *dev, struct mei_cl *cl) int mei_disconnect(struct mei_device *dev, struct mei_cl *cl)
{ {
struct mei_msg_hdr *mei_hdr; struct mei_msg_hdr *mei_hdr;
struct hbm_client_disconnect_request *mei_cli_disconnect; struct hbm_client_connect_request *req;
mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0]; mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
mei_hdr->host_addr = 0; mei_hdr->host_addr = 0;
mei_hdr->me_addr = 0; mei_hdr->me_addr = 0;
mei_hdr->length = sizeof(struct hbm_client_disconnect_request); mei_hdr->length = sizeof(struct hbm_client_connect_request);
mei_hdr->msg_complete = 1; mei_hdr->msg_complete = 1;
mei_hdr->reserved = 0; mei_hdr->reserved = 0;
mei_cli_disconnect = req = (struct hbm_client_connect_request *)&dev->wr_msg_buf[1];
(struct hbm_client_disconnect_request *) &dev->wr_msg_buf[1]; memset(req, 0, sizeof(*req));
memset(mei_cli_disconnect, 0, sizeof(*mei_cli_disconnect)); req->host_addr = cl->host_client_id;
mei_cli_disconnect->host_addr = cl->host_client_id; req->me_addr = cl->me_client_id;
mei_cli_disconnect->me_addr = cl->me_client_id; req->hbm_cmd = CLIENT_DISCONNECT_REQ_CMD;
mei_cli_disconnect->hbm_cmd = CLIENT_DISCONNECT_REQ_CMD; req->reserved = 0;
mei_cli_disconnect->reserved[0] = 0;
return mei_write_message(dev, mei_hdr, return mei_write_message(dev, mei_hdr, (unsigned char *)req,
(unsigned char *) mei_cli_disconnect, sizeof(struct hbm_client_connect_request));
sizeof(struct hbm_client_disconnect_request));
} }
/** /**

Просмотреть файл

@ -174,10 +174,10 @@ static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots,
struct mei_cl_cb *cmpl_list) struct mei_cl_cb *cmpl_list)
{ {
if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) + if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) +
sizeof(struct hbm_client_disconnect_request))) sizeof(struct hbm_client_connect_request)))
return -EBADMSG; return -EBADMSG;
*slots -= mei_data2slots(sizeof(struct hbm_client_disconnect_request)); *slots -= mei_data2slots(sizeof(struct hbm_client_connect_request));
if (mei_disconnect(dev, cl)) { if (mei_disconnect(dev, cl)) {
cl->status = 0; cl->status = 0;
@ -414,10 +414,10 @@ static void mei_client_flow_control_response(struct mei_device *dev,
* returns !=0, same; 0,not. * returns !=0, same; 0,not.
*/ */
static int same_disconn_addr(struct mei_cl *cl, static int same_disconn_addr(struct mei_cl *cl,
struct hbm_client_disconnect_request *disconn) struct hbm_client_connect_request *req)
{ {
return (cl->host_client_id == disconn->host_addr && return (cl->host_client_id == req->host_addr &&
cl->me_client_id == disconn->me_addr); cl->me_client_id == req->me_addr);
} }
/** /**
@ -427,7 +427,7 @@ static int same_disconn_addr(struct mei_cl *cl,
* @disconnect_req: disconnect request bus message. * @disconnect_req: disconnect request bus message.
*/ */
static void mei_client_disconnect_request(struct mei_device *dev, static void mei_client_disconnect_request(struct mei_device *dev,
struct hbm_client_disconnect_request *disconnect_req) struct hbm_client_connect_request *disconnect_req)
{ {
struct mei_msg_hdr *mei_hdr; struct mei_msg_hdr *mei_hdr;
struct hbm_client_connect_response *disconnect_res; struct hbm_client_connect_response *disconnect_res;
@ -484,10 +484,10 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev,
struct hbm_host_version_response *version_res; struct hbm_host_version_response *version_res;
struct hbm_client_connect_response *connect_res; struct hbm_client_connect_response *connect_res;
struct hbm_client_connect_response *disconnect_res; struct hbm_client_connect_response *disconnect_res;
struct hbm_client_connect_request *disconnect_req;
struct hbm_flow_control *flow_control; struct hbm_flow_control *flow_control;
struct hbm_props_response *props_res; struct hbm_props_response *props_res;
struct hbm_host_enum_response *enum_res; struct hbm_host_enum_response *enum_res;
struct hbm_client_disconnect_request *disconnect_req;
struct hbm_host_stop_request *host_stop_req; struct hbm_host_stop_request *host_stop_req;
int res; int res;
@ -653,8 +653,7 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev,
case CLIENT_DISCONNECT_REQ_CMD: case CLIENT_DISCONNECT_REQ_CMD:
/* search for client */ /* search for client */
disconnect_req = disconnect_req = (struct hbm_client_connect_request *)mei_msg;
(struct hbm_client_disconnect_request *) mei_msg;
mei_client_disconnect_request(dev, disconnect_req); mei_client_disconnect_request(dev, disconnect_req);
break; break;