Skip to contentSkip to conversation

mei: amthif simplifications

PATCH New Tomas Winkler 1 participant 3 messages Aug 14, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover mei: amthif simplifications

Alexander Usyskin (2):
mei: amthif: use service function to flush amthif queue
mei: amthif: don't check amthif client identity on amthif queues

 drivers/misc/mei/amthif.c    | 37 +++++++++++++++----------------------
 drivers/misc/mei/client.c    |  2 +-
 drivers/misc/mei/client.h    |  2 ++
 drivers/misc/mei/interrupt.c | 13 ++-----------
 4 files changed, 20 insertions(+), 34 deletions(-)
Signature · 1 line
1.9.3
#1 lore raw

PATCH 1/2 mei: amthif: use service function to flush amthif queue

From: Alexander Usyskin <[email protected]>

Replace open coded loop with an existing service function:
mei_io_list_flush

---
 drivers/misc/mei/client.c    |  2 +-
 drivers/misc/mei/client.h    |  2 ++
 drivers/misc/mei/interrupt.c | 13 ++-----------
 3 files changed, 5 insertions(+), 12 deletions(-)
drivers/misc/mei/client.c +1 -1
index 7dfe2b5..a90052e 100644
@@ -117,7 +117,7 @@ static void __mei_io_list_flush(struct mei_cl_cb *list,
  * @list:  An instance of our list structure
  * @cl: host client
  */
-static inline void mei_io_list_flush(struct mei_cl_cb *list, struct mei_cl *cl)
+void mei_io_list_flush(struct mei_cl_cb *list, struct mei_cl *cl)
 {
 	__mei_io_list_flush(list, cl, false);
 }
drivers/misc/mei/client.h +2 -0
index 96d5de0..bf2b0b1 100644
@@ -45,6 +45,8 @@ static inline void mei_io_list_init(struct mei_cl_cb *list)
 {
 	INIT_LIST_HEAD(&list->list);
 }
+void mei_io_list_flush(struct mei_cl_cb *list, struct mei_cl *cl);
+
 /*
  * MEI Host Client Functions
  */
drivers/misc/mei/interrupt.c +2 -11
index 4e3cba6d..19709b7 100644
@@ -556,8 +556,6 @@ void mei_timer(struct work_struct *work)
 {
 	unsigned long timeout;
 	struct mei_cl *cl;
-	struct mei_cl_cb  *cb_pos = NULL;
-	struct mei_cl_cb  *cb_next = NULL;
 
 	struct mei_device *dev = container_of(work,
 					struct mei_device, timer_work.work);
@@ -632,15 +630,8 @@ void mei_timer(struct work_struct *work)
 
 			dev_dbg(&dev->pdev->dev, "freeing AMTHI for other requests\n");
 
-			list_for_each_entry_safe(cb_pos, cb_next,
-				&dev->amthif_rd_complete_list.list, list) {
-
-				cl = cb_pos->file_object->private_data;
-
-				/* Finding the AMTHI entry. */
-				if (cl == &dev->iamthif_cl)
-					list_del(&cb_pos->list);
-			}
+			mei_io_list_flush(&dev->amthif_rd_complete_list,
+				&dev->iamthif_cl);
 			mei_io_cb_free(dev->iamthif_current_cb);
 			dev->iamthif_current_cb = NULL;
 
Signature · 1 line
1.9.3
#2 lore raw

PATCH 2/2 mei: amthif: don't check amthif client identity on amthif queues

In reply to Tomas Winkler

From: Alexander Usyskin <[email protected]>

Amthif has its own queues therefore it is redundant to check the client type when processing the queues

---
 drivers/misc/mei/amthif.c | 37 +++++++++++++++----------------------
 1 file changed, 15 insertions(+), 22 deletions(-)
drivers/misc/mei/amthif.c +15 -22
index 0d6234d..ab60959 100644
@@ -130,12 +130,9 @@ struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev,
 						struct file *file)
 {
 	struct mei_cl_cb *cb;
-
-	list_for_each_entry(cb, &dev->amthif_rd_complete_list.list, list) {
-		if (cb->cl && cb->cl == &dev->iamthif_cl &&
-			cb->file_object == file)
+	list_for_each_entry(cb, &dev->amthif_rd_complete_list.list, list)
+		if (cb->file_object == file)
 			return cb;
-	}
 	return NULL;
 }
 
@@ -168,8 +165,8 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,
 	int i;
 
 	/* Only possible if we are in timeout */
-	if (!cl || cl != &dev->iamthif_cl) {
-		dev_dbg(&dev->pdev->dev, "bad file ext.\n");
+	if (!cl) {
+		dev_err(&dev->pdev->dev, "bad file ext.\n");
 		return -ETIME;
 	}
 
@@ -371,8 +368,8 @@ int mei_amthif_write(struct mei_device *dev, struct mei_cl_cb *cb)
  */
 void mei_amthif_run_next_cmd(struct mei_device *dev)
 {
-	struct mei_cl_cb *pos = NULL;
-	struct mei_cl_cb *next = NULL;
+	struct mei_cl_cb *cb;
+	struct mei_cl_cb *next;
 	int status;
 
 	if (!dev)
@@ -388,19 +385,15 @@ void mei_amthif_run_next_cmd(struct mei_device *dev)
 
 	dev_dbg(&dev->pdev->dev, "complete amthif cmd_list cb.\n");
 
-	list_for_each_entry_safe(pos, next, &dev->amthif_cmd_list.list, list) {
-		list_del(&pos->list);
-
-		if (pos->cl && pos->cl == &dev->iamthif_cl) {
-			status = mei_amthif_send_cmd(dev, pos);
-			if (status) {
-				dev_dbg(&dev->pdev->dev,
-					"amthif write failed status = %d\n",
+	list_for_each_entry_safe(cb, next, &dev->amthif_cmd_list.list, list) {
+		list_del(&cb->list);
+		if (!cb->cl)
+			continue;
+		status = mei_amthif_send_cmd(dev, cb);
+		if (status)
+			dev_warn(&dev->pdev->dev, "amthif write failed status = %d\n",
 						status);
-				return;
-			}
-			break;
-		}
+		break;
 	}
 }
 
@@ -559,7 +552,7 @@ int mei_amthif_irq_read_msg(struct mei_device *dev,
 	dev->iamthif_stall_timer = 0;
 	cb->buf_idx = dev->iamthif_msg_buf_index;
 	cb->read_time = jiffies;
-	if (dev->iamthif_ioctl && cb->cl == &dev->iamthif_cl) {
+	if (dev->iamthif_ioctl) {
 		/* found the iamthif cb */
 		dev_dbg(&dev->pdev->dev, "complete the amthif read cb.\n ");
 		dev_dbg(&dev->pdev->dev, "add the amthif read cb to complete.\n ");
Signature · 1 line
1.9.3