aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/mei/hbm.c
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2014-08-21 07:29:20 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-09-24 01:57:48 -0400
commit2af89db1d61a872e5f2f1fb18d44cf5d8f5f6a2a (patch)
tree596d00419dc2577777495de3b7f49eaa5cdc8b71 /drivers/misc/mei/hbm.c
parentcb02efc3a6e96a0dc4aba8ebf0c1136b72fbe8ba (diff)
mei: simplify handling of hbm client events
Add mei_hbm_cl_find_by_cmd handler to retrieve the destination client Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/mei/hbm.c')
-rw-r--r--drivers/misc/mei/hbm.c74
1 files changed, 43 insertions, 31 deletions
diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
index 2968b52fc12a..280befc46d11 100644
--- a/drivers/misc/mei/hbm.c
+++ b/drivers/misc/mei/hbm.c
@@ -157,22 +157,43 @@ int mei_hbm_cl_write(struct mei_device *dev,
157} 157}
158 158
159/** 159/**
160 * mei_hbm_cl_addr_equal - tells if they have the same address 160 * mei_hbm_cl_addr_equal - check if the client's and
161 * the message address match
161 * 162 *
162 * @cl: - client 163 * @cl: client
163 * @buf: buffer with cl header 164 * @cmd: hbm client message
164 * 165 *
165 * returns true if addresses are the same 166 * returns true if addresses are the same
166 */ 167 */
167static inline 168static inline
168bool mei_hbm_cl_addr_equal(struct mei_cl *cl, void *buf) 169bool mei_hbm_cl_addr_equal(struct mei_cl *cl, struct mei_hbm_cl_cmd *cmd)
169{ 170{
170 struct mei_hbm_cl_cmd *cmd = buf;
171 return cl->host_client_id == cmd->host_addr && 171 return cl->host_client_id == cmd->host_addr &&
172 cl->me_client_id == cmd->me_addr; 172 cl->me_client_id == cmd->me_addr;
173} 173}
174 174
175/** 175/**
176 * mei_hbm_cl_find_by_cmd - find recipient client
177 *
178 * @dev: the device structure
179 * @buf: a buffer with hbm cl command
180 *
181 * returns the recipient client or NULL if not found
182 */
183static inline
184struct mei_cl *mei_hbm_cl_find_by_cmd(struct mei_device *dev, void *buf)
185{
186 struct mei_hbm_cl_cmd *cmd = (struct mei_hbm_cl_cmd *)buf;
187 struct mei_cl *cl;
188
189 list_for_each_entry(cl, &dev->file_list, link)
190 if (mei_hbm_cl_addr_equal(cl, cmd))
191 return cl;
192 return NULL;
193}
194
195
196/**
176 * mei_hbm_start_wait - wait for start response message. 197 * mei_hbm_start_wait - wait for start response message.
177 * 198 *
178 * @dev: the device structure 199 * @dev: the device structure
@@ -449,7 +470,7 @@ static int mei_hbm_add_single_flow_creds(struct mei_device *dev,
449 * @flow_control: flow control response bus message 470 * @flow_control: flow control response bus message
450 */ 471 */
451static void mei_hbm_cl_flow_control_res(struct mei_device *dev, 472static void mei_hbm_cl_flow_control_res(struct mei_device *dev,
452 struct hbm_flow_control *flow_control) 473 struct hbm_flow_control *flow_control)
453{ 474{
454 struct mei_cl *cl; 475 struct mei_cl *cl;
455 476
@@ -459,15 +480,11 @@ static void mei_hbm_cl_flow_control_res(struct mei_device *dev,
459 return; 480 return;
460 } 481 }
461 482
462 /* normal connection */ 483 cl = mei_hbm_cl_find_by_cmd(dev, flow_control);
463 list_for_each_entry(cl, &dev->file_list, link) { 484 if (cl) {
464 if (mei_hbm_cl_addr_equal(cl, flow_control)) { 485 cl->mei_flow_ctrl_creds++;
465 cl->mei_flow_ctrl_creds++; 486 cl_dbg(dev, cl, "flow control creds = %d.\n",
466 dev_dbg(&dev->pdev->dev, "flow ctrl msg for host %d ME %d creds %d.\n",
467 flow_control->host_addr, flow_control->me_addr,
468 cl->mei_flow_ctrl_creds); 487 cl->mei_flow_ctrl_creds);
469 break;
470 }
471 } 488 }
472} 489}
473 490
@@ -627,23 +644,18 @@ static int mei_hbm_fw_disconnect_req(struct mei_device *dev,
627 struct mei_cl *cl; 644 struct mei_cl *cl;
628 struct mei_cl_cb *cb; 645 struct mei_cl_cb *cb;
629 646
630 list_for_each_entry(cl, &dev->file_list, link) { 647 cl = mei_hbm_cl_find_by_cmd(dev, disconnect_req);
631 if (mei_hbm_cl_addr_equal(cl, disconnect_req)) { 648 if (cl) {
632 dev_dbg(&dev->pdev->dev, "disconnect request host client %d ME client %d.\n", 649 cl_dbg(dev, cl, "disconnect request received\n");
633 disconnect_req->host_addr, 650 cl->state = MEI_FILE_DISCONNECTED;
634 disconnect_req->me_addr); 651 cl->timer_count = 0;
635 cl->state = MEI_FILE_DISCONNECTED; 652
636 cl->timer_count = 0; 653 cb = mei_io_cb_init(cl, NULL);
637 654 if (!cb)
638 cb = mei_io_cb_init(cl, NULL); 655 return -ENOMEM;
639 if (!cb) 656 cb->fop_type = MEI_FOP_DISCONNECT_RSP;
640 return -ENOMEM; 657 cl_dbg(dev, cl, "add disconnect response as first\n");
641 cb->fop_type = MEI_FOP_DISCONNECT_RSP; 658 list_add(&cb->list, &dev->ctrl_wr_list.list);
642 cl_dbg(dev, cl, "add disconnect response as first\n");
643 list_add(&cb->list, &dev->ctrl_wr_list.list);
644
645 break;
646 }
647 } 659 }
648 return 0; 660 return 0;
649} 661}