aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2013-06-23 02:36:59 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-06-24 19:32:30 -0400
commit21767546e955c3c1705387ca4548db812382fe08 (patch)
tree742c9495d1a982b5680b9d1cd24e47bacde4e4c9
parent34cb27528398738bea94852b99ef8fb05944ec41 (diff)
mei: move mei_cl_irq_write_complete to client.c
mei_cl_irq_write_complete operates on a client so move it to client.c Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/misc/mei/client.c60
-rw-r--r--drivers/misc/mei/client.h3
-rw-r--r--drivers/misc/mei/interrupt.c59
3 files changed, 63 insertions, 59 deletions
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index c2534ca5c6f1..788f6478b4ab 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -682,6 +682,66 @@ err:
682} 682}
683 683
684/** 684/**
685 * mei_cl_irq_write_complete - write a message to device
686 * from the interrupt thread context
687 *
688 * @cl: client
689 * @cb: callback block.
690 * @slots: free slots.
691 * @cmpl_list: complete list.
692 *
693 * returns 0, OK; otherwise error.
694 */
695int mei_cl_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
696 s32 *slots, struct mei_cl_cb *cmpl_list)
697{
698 struct mei_device *dev = cl->dev;
699 struct mei_msg_hdr mei_hdr;
700 size_t len = cb->request_buffer.size - cb->buf_idx;
701 u32 msg_slots = mei_data2slots(len);
702
703 mei_hdr.host_addr = cl->host_client_id;
704 mei_hdr.me_addr = cl->me_client_id;
705 mei_hdr.reserved = 0;
706
707 if (*slots >= msg_slots) {
708 mei_hdr.length = len;
709 mei_hdr.msg_complete = 1;
710 /* Split the message only if we can write the whole host buffer */
711 } else if (*slots == dev->hbuf_depth) {
712 msg_slots = *slots;
713 len = (*slots * sizeof(u32)) - sizeof(struct mei_msg_hdr);
714 mei_hdr.length = len;
715 mei_hdr.msg_complete = 0;
716 } else {
717 /* wait for next time the host buffer is empty */
718 return 0;
719 }
720
721 dev_dbg(&dev->pdev->dev, "buf: size = %d idx = %lu\n",
722 cb->request_buffer.size, cb->buf_idx);
723 dev_dbg(&dev->pdev->dev, MEI_HDR_FMT, MEI_HDR_PRM(&mei_hdr));
724
725 *slots -= msg_slots;
726 if (mei_write_message(dev, &mei_hdr,
727 cb->request_buffer.data + cb->buf_idx)) {
728 cl->status = -ENODEV;
729 list_move_tail(&cb->list, &cmpl_list->list);
730 return -ENODEV;
731 }
732
733 cl->status = 0;
734 cb->buf_idx += mei_hdr.length;
735 if (mei_hdr.msg_complete) {
736 if (mei_cl_flow_ctrl_reduce(cl))
737 return -ENODEV;
738 list_move_tail(&cb->list, &dev->write_waiting_list.list);
739 }
740
741 return 0;
742}
743
744/**
685 * mei_cl_write - submit a write cb to mei device 745 * mei_cl_write - submit a write cb to mei device
686 assumes device_lock is locked 746 assumes device_lock is locked
687 * 747 *
diff --git a/drivers/misc/mei/client.h b/drivers/misc/mei/client.h
index 7dc2af7b6fba..26b157d8bad5 100644
--- a/drivers/misc/mei/client.h
+++ b/drivers/misc/mei/client.h
@@ -89,6 +89,9 @@ int mei_cl_disconnect(struct mei_cl *cl);
89int mei_cl_connect(struct mei_cl *cl, struct file *file); 89int mei_cl_connect(struct mei_cl *cl, struct file *file);
90int mei_cl_read_start(struct mei_cl *cl, size_t length); 90int mei_cl_read_start(struct mei_cl *cl, size_t length);
91int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking); 91int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking);
92int mei_cl_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
93 s32 *slots, struct mei_cl_cb *cmpl_list);
94
92void mei_cl_complete(struct mei_cl *cl, struct mei_cl_cb *cb); 95void mei_cl_complete(struct mei_cl *cl, struct mei_cl_cb *cb);
93 96
94void mei_host_client_init(struct work_struct *work); 97void mei_host_client_init(struct work_struct *work);
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index 7d9509a094e9..4b59cb742dee 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -282,65 +282,6 @@ static int mei_cl_irq_ioctl(struct mei_cl *cl, struct mei_cl_cb *cb,
282 return 0; 282 return 0;
283} 283}
284 284
285/**
286 * mei_cl_irq_write_complete - write messages to device.
287 *
288 * @cl: client
289 * @cb: callback block.
290 * @slots: free slots.
291 * @cmpl_list: complete list.
292 *
293 * returns 0, OK; otherwise, error.
294 */
295static int mei_cl_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
296 s32 *slots, struct mei_cl_cb *cmpl_list)
297{
298 struct mei_device *dev = cl->dev;
299 struct mei_msg_hdr mei_hdr;
300 size_t len = cb->request_buffer.size - cb->buf_idx;
301 u32 msg_slots = mei_data2slots(len);
302
303 mei_hdr.host_addr = cl->host_client_id;
304 mei_hdr.me_addr = cl->me_client_id;
305 mei_hdr.reserved = 0;
306
307 if (*slots >= msg_slots) {
308 mei_hdr.length = len;
309 mei_hdr.msg_complete = 1;
310 /* Split the message only if we can write the whole host buffer */
311 } else if (*slots == dev->hbuf_depth) {
312 msg_slots = *slots;
313 len = (*slots * sizeof(u32)) - sizeof(struct mei_msg_hdr);
314 mei_hdr.length = len;
315 mei_hdr.msg_complete = 0;
316 } else {
317 /* wait for next time the host buffer is empty */
318 return 0;
319 }
320
321 dev_dbg(&dev->pdev->dev, "buf: size = %d idx = %lu\n",
322 cb->request_buffer.size, cb->buf_idx);
323 dev_dbg(&dev->pdev->dev, MEI_HDR_FMT, MEI_HDR_PRM(&mei_hdr));
324
325 *slots -= msg_slots;
326 if (mei_write_message(dev, &mei_hdr,
327 cb->request_buffer.data + cb->buf_idx)) {
328 cl->status = -ENODEV;
329 list_move_tail(&cb->list, &cmpl_list->list);
330 return -ENODEV;
331 }
332
333
334 cl->status = 0;
335 cb->buf_idx += mei_hdr.length;
336 if (mei_hdr.msg_complete) {
337 if (mei_cl_flow_ctrl_reduce(cl))
338 return -ENODEV;
339 list_move_tail(&cb->list, &dev->write_waiting_list.list);
340 }
341
342 return 0;
343}
344 285
345/** 286/**
346 * mei_irq_read_handler - bottom half read routine after ISR to 287 * mei_irq_read_handler - bottom half read routine after ISR to