linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Devin J. Pohly" <djpohly@gmail.com>
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, "Devin J. Pohly" <djpohly@gmail.com>
Subject: [PATCH 8/9] mei: reduce indentation in read_client_message
Date: Thu, 23 Feb 2012 20:38:55 -0500	[thread overview]
Message-ID: <1330047536-3827-9-git-send-email-djpohly@gmail.com> (raw)
In-Reply-To: <1330047536-3827-1-git-send-email-djpohly@gmail.com>

From: "Devin J. Pohly" <djpohly@gmail.com>

Removes the empty check since that's handled by foreach.  Moves a big
chunk of code out of the foreach since it's followed by a break anyway.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
---
 drivers/staging/mei/interrupt.c |   67 ++++++++++++++++++---------------------
 1 file changed, 30 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/mei/interrupt.c b/drivers/staging/mei/interrupt.c
index 6ae7a0e..f2c864e 100644
--- a/drivers/staging/mei/interrupt.c
+++ b/drivers/staging/mei/interrupt.c
@@ -193,51 +193,44 @@ static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list,
 	unsigned char *buffer = NULL;
 
 	dev_dbg(&dev->pdev->dev, "start client msg\n");
-	if (list_empty(&dev->read_list.mei_cb.cb_list))
-		goto out;
 
 	list_for_each_entry_safe(cb_pos, cb_next,
 			&dev->read_list.mei_cb.cb_list, cb_list) {
 		cl = (struct mei_cl *)cb_pos->file_private;
-		if (cl && _mei_irq_thread_state_ok(cl, mei_hdr)) {
-			cl->reading_state = MEI_READING;
-			buffer = (unsigned char *)
-				(cb_pos->response_buffer.data +
-				cb_pos->information);
-
-			if (cb_pos->response_buffer.size <
-					mei_hdr->length + cb_pos->information) {
-				dev_dbg(&dev->pdev->dev, "message overflow.\n");
-				list_del(&cb_pos->cb_list);
-				return -ENOMEM;
-			}
-			if (buffer)
-				mei_read_slots(dev, buffer, mei_hdr->length);
+		if (cl && _mei_irq_thread_state_ok(cl, mei_hdr))
+			break;
+	}
 
-			cb_pos->information += mei_hdr->length;
-			if (mei_hdr->msg_complete) {
-				cl->status = 0;
-				list_del(&cb_pos->cb_list);
-				dev_dbg(&dev->pdev->dev,
-					"completed read host client = %d,"
-					"ME client = %d, "
-					"data length = %lu\n",
-					cl->host_client_id,
-					cl->me_client_id,
-					cb_pos->information);
-
-				*(cb_pos->response_buffer.data +
-					cb_pos->information) = '\0';
-				dev_dbg(&dev->pdev->dev, "cb_pos->res_buffer - %s\n",
-					cb_pos->response_buffer.data);
-				list_add_tail(&cb_pos->cb_list,
-					&complete_list->mei_cb.cb_list);
-			}
+	/* List empty, or client not found */
+	if (&cb_pos->cb_list == &dev->read_list.mei_cb.cb_list)
+		goto out;
 
-			break;
-		}
+	cl->reading_state = MEI_READING;
+	buffer = cb_pos->response_buffer.data + cb_pos->information;
 
+	if (cb_pos->response_buffer.size <
+			mei_hdr->length + cb_pos->information) {
+		dev_dbg(&dev->pdev->dev, "message overflow.\n");
+		list_del(&cb_pos->cb_list);
+		return -ENOMEM;
 	}
+	if (buffer)
+		mei_read_slots(dev, buffer, mei_hdr->length);
+
+	cb_pos->information += mei_hdr->length;
+	if (!mei_hdr->msg_complete)
+		goto out;
+
+	cl->status = 0;
+	list_del(&cb_pos->cb_list);
+	dev_dbg(&dev->pdev->dev, "completed read host client = %d, "
+		"ME client = %d, data length = %lu\n",
+		cl->host_client_id, cl->me_client_id, cb_pos->information);
+
+	cb_pos->response_buffer.data[cb_pos->information] = '\0';
+	dev_dbg(&dev->pdev->dev, "cb_pos->res_buffer - %s\n",
+		cb_pos->response_buffer.data);
+	list_add_tail(&cb_pos->cb_list, &complete_list->mei_cb.cb_list);
 
 out:
 	dev_dbg(&dev->pdev->dev, "message read\n");
-- 
1.7.9.2


  parent reply	other threads:[~2012-02-24  1:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-24  1:38 Devin J. Pohly
2012-02-24  1:38 ` [PATCH 1/9] mei: cosmetic cleanup in interrupt.c Devin J. Pohly
2012-02-24  2:51   ` Greg KH
2012-02-24  1:38 ` [PATCH 2/9] mei: factor some bits of code outside if blocks Devin J. Pohly
2012-02-24  1:38 ` [PATCH 3/9] mei: more idiomatic variable/label usage Devin J. Pohly
2012-02-24  1:38 ` [PATCH 4/9] mei: return values are -Exxx, not ~Exxx! Devin J. Pohly
2012-02-27 16:35   ` Tomas Winkler
2012-02-24  1:38 ` [PATCH 5/9] mei: remove indentation where else follows return Devin J. Pohly
2012-02-24  1:38 ` [PATCH 6/9] mei: reduce indentation with early returns Devin J. Pohly
2012-02-24  1:38 ` [PATCH 7/9] mei: reduce indentation by combining if blocks Devin J. Pohly
2012-02-24  1:38 ` Devin J. Pohly [this message]
2012-02-24  1:38 ` [PATCH 9/9] mei: reduce indentation in read_bus_message Devin J. Pohly

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1330047536-3827-9-git-send-email-djpohly@gmail.com \
    --to=djpohly@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).