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 7/9] mei: reduce indentation by combining if blocks
Date: Thu, 23 Feb 2012 20:38:54 -0500	[thread overview]
Message-ID: <1330047536-3827-8-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>

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

diff --git a/drivers/staging/mei/interrupt.c b/drivers/staging/mei/interrupt.c
index 541d018..6ae7a0e 100644
--- a/drivers/staging/mei/interrupt.c
+++ b/drivers/staging/mei/interrupt.c
@@ -1231,29 +1231,23 @@ static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list,
 		*slots -= dev->extra_write_index;
 		dev->extra_write_index = 0;
 	}
-	if (dev->mei_state == MEI_ENABLED) {
-		if (dev->wd_pending &&
+	if (dev->mei_state == MEI_ENABLED && dev->wd_pending &&
 			mei_flow_ctrl_creds(dev, &dev->wd_cl) > 0) {
-			if (mei_wd_send(dev))
-				dev_dbg(&dev->pdev->dev, "wd send failed.\n");
-			else
-				if (mei_flow_ctrl_reduce(dev, &dev->wd_cl))
-					return -ENODEV;
+		if (mei_wd_send(dev))
+			dev_dbg(&dev->pdev->dev, "wd send failed.\n");
+		else if (mei_flow_ctrl_reduce(dev, &dev->wd_cl))
+			return -ENODEV;
 
-			dev->wd_pending = false;
+		dev->wd_pending = false;
 
-			if (dev->wd_timeout) {
-				*slots -= DIV_ROUND_UP(
-					sizeof(struct mei_msg_hdr) +
+		if (dev->wd_timeout) {
+			*slots -= DIV_ROUND_UP(sizeof(struct mei_msg_hdr) +
 					MEI_START_WD_DATA_SIZE, sizeof(u32));
-				dev->wd_due_counter = 2;
-			} else {
-				*slots -= DIV_ROUND_UP(
-					sizeof(struct mei_msg_hdr) +
+			dev->wd_due_counter = 2;
+		} else {
+			*slots -= DIV_ROUND_UP(sizeof(struct mei_msg_hdr) +
 					MEI_WD_PARAMS_SIZE, sizeof(u32));
-				dev->wd_due_counter = 0;
-			}
-
+			dev->wd_due_counter = 0;
 		}
 	}
 	if (dev->stop)
@@ -1356,46 +1350,40 @@ void mei_timer(struct work_struct *work)
 
 	mutex_lock(&dev->device_lock);
 	if (dev->mei_state != MEI_ENABLED) {
-		if (dev->mei_state == MEI_INIT_CLIENTS) {
-			if (dev->init_clients_timer) {
-				if (--dev->init_clients_timer == 0) {
-					dev_dbg(&dev->pdev->dev, "IMEI reset due to init clients timeout ,init clients state = %d.\n",
-						dev->init_clients_state);
-					mei_reset(dev, 1);
-				}
-			}
+		if (dev->mei_state == MEI_INIT_CLIENTS &&
+				dev->init_clients_timer &&
+				--dev->init_clients_timer == 0) {
+			dev_dbg(&dev->pdev->dev, "IMEI reset due to init clients timeout ,init clients state = %d.\n",
+					dev->init_clients_state);
+			mei_reset(dev, 1);
 		}
 		goto out;
 	}
 	/* connect/disconnect timeouts */
 	list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) {
-		if (cl_pos->timer_count) {
-			if (--cl_pos->timer_count == 0) {
-				dev_dbg(&dev->pdev->dev, "HECI reset due to connect/disconnect timeout.\n");
-				mei_reset(dev, 1);
-				goto out;
-			}
+		if (cl_pos->timer_count && --cl_pos->timer_count == 0) {
+			dev_dbg(&dev->pdev->dev, "HECI reset due to connect/disconnect timeout.\n");
+			mei_reset(dev, 1);
+			goto out;
 		}
 	}
 
-	if (dev->iamthif_stall_timer) {
-		if (--dev->iamthif_stall_timer == 0) {
-			dev_dbg(&dev->pdev->dev, "reseting because of hang to amthi.\n");
-			mei_reset(dev, 1);
-			dev->iamthif_msg_buf_size = 0;
-			dev->iamthif_msg_buf_index = 0;
-			dev->iamthif_canceled = false;
-			dev->iamthif_ioctl = true;
-			dev->iamthif_state = MEI_IAMTHIF_IDLE;
-			dev->iamthif_timer = 0;
+	if (dev->iamthif_stall_timer && --dev->iamthif_stall_timer == 0) {
+		dev_dbg(&dev->pdev->dev, "reseting because of hang to amthi.\n");
+		mei_reset(dev, 1);
+		dev->iamthif_msg_buf_size = 0;
+		dev->iamthif_msg_buf_index = 0;
+		dev->iamthif_canceled = false;
+		dev->iamthif_ioctl = true;
+		dev->iamthif_state = MEI_IAMTHIF_IDLE;
+		dev->iamthif_timer = 0;
 
-			if (dev->iamthif_current_cb)
-				mei_free_cb_private(dev->iamthif_current_cb);
+		if (dev->iamthif_current_cb)
+			mei_free_cb_private(dev->iamthif_current_cb);
 
-			dev->iamthif_file_object = NULL;
-			dev->iamthif_current_cb = NULL;
-			mei_run_next_iamthif_cmd(dev);
-		}
+		dev->iamthif_file_object = NULL;
+		dev->iamthif_current_cb = NULL;
+		mei_run_next_iamthif_cmd(dev);
 	}
 
 	if (dev->iamthif_timer) {
-- 
1.7.9.2


  parent reply	other threads:[~2012-02-24  1:40 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 ` Devin J. Pohly [this message]
2012-02-24  1:38 ` [PATCH 8/9] mei: reduce indentation in read_client_message Devin J. Pohly
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-8-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).