aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/mei/amthif.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc/mei/amthif.c')
-rw-r--r--drivers/misc/mei/amthif.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index d0fdc134068a..04fd38567729 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -312,13 +312,13 @@ static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb)
312 mei_hdr.me_addr = dev->iamthif_cl.me_client_id; 312 mei_hdr.me_addr = dev->iamthif_cl.me_client_id;
313 mei_hdr.reserved = 0; 313 mei_hdr.reserved = 0;
314 dev->iamthif_msg_buf_index += mei_hdr.length; 314 dev->iamthif_msg_buf_index += mei_hdr.length;
315 if (mei_write_message(dev, &mei_hdr, 315 ret = mei_write_message(dev, &mei_hdr, dev->iamthif_msg_buf);
316 (unsigned char *)dev->iamthif_msg_buf)) 316 if (ret)
317 return -ENODEV; 317 return ret;
318 318
319 if (mei_hdr.msg_complete) { 319 if (mei_hdr.msg_complete) {
320 if (mei_cl_flow_ctrl_reduce(&dev->iamthif_cl)) 320 if (mei_cl_flow_ctrl_reduce(&dev->iamthif_cl))
321 return -ENODEV; 321 return -EIO;
322 dev->iamthif_flow_control_pending = true; 322 dev->iamthif_flow_control_pending = true;
323 dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL; 323 dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL;
324 dev_dbg(&dev->pdev->dev, "add amthif cb to write waiting list\n"); 324 dev_dbg(&dev->pdev->dev, "add amthif cb to write waiting list\n");
@@ -458,6 +458,16 @@ int mei_amthif_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
458 struct mei_msg_hdr mei_hdr; 458 struct mei_msg_hdr mei_hdr;
459 size_t len = dev->iamthif_msg_buf_size - dev->iamthif_msg_buf_index; 459 size_t len = dev->iamthif_msg_buf_size - dev->iamthif_msg_buf_index;
460 u32 msg_slots = mei_data2slots(len); 460 u32 msg_slots = mei_data2slots(len);
461 int rets;
462
463 rets = mei_cl_flow_ctrl_creds(cl);
464 if (rets < 0)
465 return rets;
466
467 if (rets == 0) {
468 cl_dbg(dev, cl, "No flow control credentials: not sending.\n");
469 return 0;
470 }
461 471
462 mei_hdr.host_addr = cl->host_client_id; 472 mei_hdr.host_addr = cl->host_client_id;
463 mei_hdr.me_addr = cl->me_client_id; 473 mei_hdr.me_addr = cl->me_client_id;
@@ -480,16 +490,17 @@ int mei_amthif_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
480 dev_dbg(&dev->pdev->dev, MEI_HDR_FMT, MEI_HDR_PRM(&mei_hdr)); 490 dev_dbg(&dev->pdev->dev, MEI_HDR_FMT, MEI_HDR_PRM(&mei_hdr));
481 491
482 *slots -= msg_slots; 492 *slots -= msg_slots;
483 if (mei_write_message(dev, &mei_hdr, 493 rets = mei_write_message(dev, &mei_hdr,
484 dev->iamthif_msg_buf + dev->iamthif_msg_buf_index)) { 494 dev->iamthif_msg_buf + dev->iamthif_msg_buf_index);
485 dev->iamthif_state = MEI_IAMTHIF_IDLE; 495 if (rets) {
486 cl->status = -ENODEV; 496 dev->iamthif_state = MEI_IAMTHIF_IDLE;
487 list_del(&cb->list); 497 cl->status = rets;
488 return -ENODEV; 498 list_del(&cb->list);
499 return rets;
489 } 500 }
490 501
491 if (mei_cl_flow_ctrl_reduce(cl)) 502 if (mei_cl_flow_ctrl_reduce(cl))
492 return -ENODEV; 503 return -EIO;
493 504
494 dev->iamthif_msg_buf_index += mei_hdr.length; 505 dev->iamthif_msg_buf_index += mei_hdr.length;
495 cl->status = 0; 506 cl->status = 0;