Commit 2af89db1 authored by Tomas Winkler's avatar Tomas Winkler Committed by Greg Kroah-Hartman

mei: simplify handling of hbm client events

Add mei_hbm_cl_find_by_cmd handler to retrieve
the destination client
Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cb02efc3
...@@ -157,21 +157,42 @@ int mei_hbm_cl_write(struct mei_device *dev, ...@@ -157,21 +157,42 @@ int mei_hbm_cl_write(struct mei_device *dev,
} }
/** /**
* mei_hbm_cl_addr_equal - tells if they have the same address * mei_hbm_cl_addr_equal - check if the client's and
* the message address match
* *
* @cl: - client * @cl: client
* @buf: buffer with cl header * @cmd: hbm client message
* *
* returns true if addresses are the same * returns true if addresses are the same
*/ */
static inline static inline
bool mei_hbm_cl_addr_equal(struct mei_cl *cl, void *buf) bool mei_hbm_cl_addr_equal(struct mei_cl *cl, struct mei_hbm_cl_cmd *cmd)
{ {
struct mei_hbm_cl_cmd *cmd = buf;
return cl->host_client_id == cmd->host_addr && return cl->host_client_id == cmd->host_addr &&
cl->me_client_id == cmd->me_addr; cl->me_client_id == cmd->me_addr;
} }
/**
* mei_hbm_cl_find_by_cmd - find recipient client
*
* @dev: the device structure
* @buf: a buffer with hbm cl command
*
* returns the recipient client or NULL if not found
*/
static inline
struct mei_cl *mei_hbm_cl_find_by_cmd(struct mei_device *dev, void *buf)
{
struct mei_hbm_cl_cmd *cmd = (struct mei_hbm_cl_cmd *)buf;
struct mei_cl *cl;
list_for_each_entry(cl, &dev->file_list, link)
if (mei_hbm_cl_addr_equal(cl, cmd))
return cl;
return NULL;
}
/** /**
* mei_hbm_start_wait - wait for start response message. * mei_hbm_start_wait - wait for start response message.
* *
...@@ -459,15 +480,11 @@ static void mei_hbm_cl_flow_control_res(struct mei_device *dev, ...@@ -459,15 +480,11 @@ static void mei_hbm_cl_flow_control_res(struct mei_device *dev,
return; return;
} }
/* normal connection */ cl = mei_hbm_cl_find_by_cmd(dev, flow_control);
list_for_each_entry(cl, &dev->file_list, link) { if (cl) {
if (mei_hbm_cl_addr_equal(cl, flow_control)) {
cl->mei_flow_ctrl_creds++; cl->mei_flow_ctrl_creds++;
dev_dbg(&dev->pdev->dev, "flow ctrl msg for host %d ME %d creds %d.\n", cl_dbg(dev, cl, "flow control creds = %d.\n",
flow_control->host_addr, flow_control->me_addr,
cl->mei_flow_ctrl_creds); cl->mei_flow_ctrl_creds);
break;
}
} }
} }
...@@ -627,11 +644,9 @@ static int mei_hbm_fw_disconnect_req(struct mei_device *dev, ...@@ -627,11 +644,9 @@ static int mei_hbm_fw_disconnect_req(struct mei_device *dev,
struct mei_cl *cl; struct mei_cl *cl;
struct mei_cl_cb *cb; struct mei_cl_cb *cb;
list_for_each_entry(cl, &dev->file_list, link) { cl = mei_hbm_cl_find_by_cmd(dev, disconnect_req);
if (mei_hbm_cl_addr_equal(cl, disconnect_req)) { if (cl) {
dev_dbg(&dev->pdev->dev, "disconnect request host client %d ME client %d.\n", cl_dbg(dev, cl, "disconnect request received\n");
disconnect_req->host_addr,
disconnect_req->me_addr);
cl->state = MEI_FILE_DISCONNECTED; cl->state = MEI_FILE_DISCONNECTED;
cl->timer_count = 0; cl->timer_count = 0;
...@@ -641,9 +656,6 @@ static int mei_hbm_fw_disconnect_req(struct mei_device *dev, ...@@ -641,9 +656,6 @@ static int mei_hbm_fw_disconnect_req(struct mei_device *dev,
cb->fop_type = MEI_FOP_DISCONNECT_RSP; cb->fop_type = MEI_FOP_DISCONNECT_RSP;
cl_dbg(dev, cl, "add disconnect response as first\n"); cl_dbg(dev, cl, "add disconnect response as first\n");
list_add(&cb->list, &dev->ctrl_wr_list.list); list_add(&cb->list, &dev->ctrl_wr_list.list);
break;
}
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment