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.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index c86d7e3839a4..9a5e8c72628b 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -449,7 +449,7 @@ int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots,
449 struct mei_msg_hdr mei_hdr; 449 struct mei_msg_hdr mei_hdr;
450 struct mei_cl *cl = cb->cl; 450 struct mei_cl *cl = cb->cl;
451 size_t len = dev->iamthif_msg_buf_size - dev->iamthif_msg_buf_index; 451 size_t len = dev->iamthif_msg_buf_size - dev->iamthif_msg_buf_index;
452 size_t msg_slots = mei_data2slots(len); 452 u32 msg_slots = mei_data2slots(len);
453 453
454 mei_hdr.host_addr = cl->host_client_id; 454 mei_hdr.host_addr = cl->host_client_id;
455 mei_hdr.me_addr = cl->me_client_id; 455 mei_hdr.me_addr = cl->me_client_id;
@@ -566,12 +566,13 @@ int mei_amthif_irq_read_message(struct mei_cl_cb *complete_list,
566 */ 566 */
567int mei_amthif_irq_read(struct mei_device *dev, s32 *slots) 567int mei_amthif_irq_read(struct mei_device *dev, s32 *slots)
568{ 568{
569 u32 msg_slots = mei_data2slots(sizeof(struct hbm_flow_control));
569 570
570 if (((*slots) * sizeof(u32)) < (sizeof(struct mei_msg_hdr) 571 if (*slots < msg_slots)
571 + sizeof(struct hbm_flow_control))) {
572 return -EMSGSIZE; 572 return -EMSGSIZE;
573 } 573
574 *slots -= mei_data2slots(sizeof(struct hbm_flow_control)); 574 *slots -= msg_slots;
575
575 if (mei_hbm_cl_flow_control_req(dev, &dev->iamthif_cl)) { 576 if (mei_hbm_cl_flow_control_req(dev, &dev->iamthif_cl)) {
576 dev_dbg(&dev->pdev->dev, "iamthif flow control failed\n"); 577 dev_dbg(&dev->pdev->dev, "iamthif flow control failed\n");
577 return -EIO; 578 return -EIO;