mei: add mei_irq_compl_handler function
authorTomas Winkler <tomas.winkler@intel.com>
Sun, 17 Mar 2013 09:41:20 +0000 (11:41 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 25 Mar 2013 20:20:49 +0000 (13:20 -0700)
similar to read/write add also irq completion handler
that is called for the irq thread

rename missnamed mei_irq_complete_handler to
mei_cl_complete_handler as it operates on a single client

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/mei/hw-me.c
drivers/misc/mei/interrupt.c
drivers/misc/mei/mei_dev.h

index df9b43d81eeadd2f1b2c016dd13b1d8640d80fcb..11a2a6538c0b55a1e908731bb03907b10abc16ad 100644 (file)
@@ -456,8 +456,6 @@ irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id)
 {
        struct mei_device *dev = (struct mei_device *) dev_id;
        struct mei_cl_cb complete_list;
-       struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL;
-       struct mei_cl *cl;
        s32 slots;
        int rets;
        bool  bus_message_received;
@@ -527,23 +525,9 @@ end:
                wake_up_interruptible(&dev->wait_recvd_msg);
                bus_message_received = false;
        }
-       if (list_empty(&complete_list.list))
-               return IRQ_HANDLED;
 
+       mei_irq_compl_handler(dev, &complete_list);
 
-       list_for_each_entry_safe(cb_pos, cb_next, &complete_list.list, list) {
-               cl = cb_pos->cl;
-               list_del(&cb_pos->list);
-               if (cl) {
-                       if (cl != &dev->iamthif_cl) {
-                               dev_dbg(&dev->pdev->dev, "completing call back.\n");
-                               mei_irq_complete_handler(cl, cb_pos);
-                               cb_pos = NULL;
-                       } else if (cl == &dev->iamthif_cl) {
-                               mei_amthif_complete(dev, cb_pos);
-                       }
-               }
-       }
        return IRQ_HANDLED;
 }
 static const struct mei_hw_ops mei_me_hw_ops = {
index 14c70b8815d820c02c364f734331328c21039af2..73fbce3e77460f83cdce0a5034c52353b2606991 100644 (file)
 
 
 /**
- * mei_complete_handler - processes completed operation.
+ * mei_cl_complete_handler - processes completed operation for a client
  *
  * @cl: private data of the file object.
- * @cb_pos: callback block.
+ * @cb: callback block.
  */
-void mei_irq_complete_handler(struct mei_cl *cl, struct mei_cl_cb *cb_pos)
+static void mei_cl_complete_handler(struct mei_cl *cl, struct mei_cl_cb *cb)
 {
-       if (cb_pos->fop_type == MEI_FOP_WRITE) {
-               mei_io_cb_free(cb_pos);
-               cb_pos = NULL;
+       if (cb->fop_type == MEI_FOP_WRITE) {
+               mei_io_cb_free(cb);
+               cb = NULL;
                cl->writing_state = MEI_WRITE_COMPLETE;
                if (waitqueue_active(&cl->tx_wait))
                        wake_up_interruptible(&cl->tx_wait);
 
-       } else if (cb_pos->fop_type == MEI_FOP_READ &&
+       } else if (cb->fop_type == MEI_FOP_READ &&
                        MEI_READING == cl->reading_state) {
                cl->reading_state = MEI_READ_COMPLETE;
                if (waitqueue_active(&cl->rx_wait))
@@ -53,6 +53,31 @@ void mei_irq_complete_handler(struct mei_cl *cl, struct mei_cl_cb *cb_pos)
        }
 }
 
+/**
+ * mei_irq_compl_handler - dispatch complete handelers
+ *     for the completed callbacks
+ *
+ * @dev - mei device
+ * @compl_list - list of completed cbs
+ */
+void mei_irq_compl_handler(struct mei_device *dev, struct mei_cl_cb *compl_list)
+{
+       struct mei_cl_cb *cb, *next;
+       struct mei_cl *cl;
+
+       list_for_each_entry_safe(cb, next, &compl_list->list, list) {
+               cl = cb->cl;
+               list_del(&cb->list);
+               if (!cl)
+                       continue;
+
+               dev_dbg(&dev->pdev->dev, "completing call back.\n");
+               if (cl == &dev->iamthif_cl)
+                       mei_amthif_complete(dev, cb);
+               else
+                       mei_cl_complete_handler(cl, cb);
+       }
+}
 /**
  * _mei_irq_thread_state_ok - checks if mei header matches file private data
  *
index 5c30857e91d5314f66aff47f461976b37775ceba..1a4b50ca4b3b6f6dd5a8edd92bb4d7f9a7a28ed0 100644 (file)
@@ -405,8 +405,7 @@ int mei_irq_read_handler(struct mei_device *dev,
                struct mei_cl_cb *cmpl_list, s32 *slots);
 
 int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list);
-
-void mei_irq_complete_handler(struct mei_cl *cl, struct mei_cl_cb *cb_pos);
+void mei_irq_compl_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list);
 
 /*
  * AMTHIF - AMT Host Interface Functions