aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/mei/amthif.c
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2013-03-11 12:27:02 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-15 14:10:48 -0400
commitc8c8d080ed94cea6757f2d781b6e360a74b256fd (patch)
tree5fa9937912d66e7d6633c3109fdce1b344c8728f /drivers/misc/mei/amthif.c
parent388f7bd24d2ffc945ad08be3a592672c1e32156e (diff)
mei: revamp mei_data2slots
1. Move the mei_data2slots to mei_dev.h as it will be used by the all supported HW. 2. Change return value from u8 to u32 to catch possible overflows 3. Eliminate computing the slots number twice in the same function Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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;