From patchwork Tue Aug 7 05:51:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 1283631 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id C7A2CDF280 for ; Tue, 7 Aug 2012 05:58:49 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Sycm0-0007Lj-6m; Tue, 07 Aug 2012 05:56:08 +0000 Received: from na3sys009aog116.obsmtp.com ([74.125.149.240]) by merlin.infradead.org with smtps (Exim 4.76 #1 (Red Hat Linux)) id 1Syclw-0007LU-UF for linux-arm-kernel@lists.infradead.org; Tue, 07 Aug 2012 05:56:05 +0000 Received: from mail-lpp01m010-f50.google.com ([209.85.215.50]) (using TLSv1) by na3sys009aob116.postini.com ([74.125.148.12]) with SMTP ID DSNKUCCt8sD+c8L1Kpybxh8NxlSlGJL5gikw@postini.com; Mon, 06 Aug 2012 22:56:04 PDT Received: by lagp5 with SMTP id p5so20749lag.37 for ; Mon, 06 Aug 2012 22:55:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=uRzb3LOl5bIqfEAHuTWcDJv2JEYPhfNDe8hUK5PQ3TY=; b=Zp1fuOfFU0XoMwgesyvMb9WZD5X058V4IFsHrR7A/rH+SohhiS+s0NPmrIet8nUGGI s1anhC7EVe8thGHQTzs7gmBLCrIbIvT2zUnFcSHvYPbjZyLGmpDjsV+P/XRpWyP2YEhH 2TB9Ob/7a2YgjrO/bFW4htui6kpwuA2YD65pZ3d+Q8PmUIbYb4Tyc/aKb3nSRWeqxl06 PJskKvV54PpZJRvgUVVwPOI8cT1sJXA43Czgp2hNmfZeOEDMkfpOqnHcJJyYA1kcw3FU hcp2k5FSWpNuuqAC2RRCoa6oKLW2P8+zfzbgfyXJsIo7zafWgntnwkKV96BnlGpowDlU isNw== Received: by 10.152.103.146 with SMTP id fw18mr13180355lab.30.1344318902318; Mon, 06 Aug 2012 22:55:02 -0700 (PDT) Received: from localhost (cs78217178.pp.htv.fi. [62.78.217.178]) by mx.google.com with ESMTPS id n7sm4122642lbk.10.2012.08.06.22.55.00 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 06 Aug 2012 22:55:01 -0700 (PDT) From: Felipe Balbi To: Shubhrajyoti Datta Subject: [PATCH] i2c: omap: sanitize exit path Date: Tue, 7 Aug 2012 08:51:29 +0300 Message-Id: <1344318689-24522-1-git-send-email-balbi@ti.com> X-Mailer: git-send-email 1.7.12.rc0 X-Gm-Message-State: ALoCoQlBTVBM+li2U1ovUY0AedR8httCQ+N8YV+jtsSaEUppeIq/uJcr8NYr60gJk99N3rJ3pERr X-Spam-Note: CRM114 invocation failed X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [74.125.149.240 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Linux OMAP Mailing List , Felipe Balbi , w.sang@pengutronix.de, Linux ARM Kernel Mailing List X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org move the goto out label one line down, so that it can be used when stat is read as zero. All other exits, can be done with a break statement. While at that, also break out as soon as we complete draining IRQ, since at that time we know we transferred everything there was to be transferred. Signed-off-by: Felipe Balbi --- drivers/i2c/busses/i2c-omap.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 22efaba..57c2824 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -898,27 +898,26 @@ omap_i2c_isr_thread(int this_irq, void *dev_id) if (!stat) { /* my work here is done */ - spin_unlock_irqrestore(&dev->lock, flags); - return IRQ_HANDLED; + goto out; } dev_dbg(dev->dev, "IRQ (ISR = 0x%04x)\n", stat); if (count++ == 100) { dev_warn(dev->dev, "Too much work in one IRQ\n"); - goto out; + break; } if (stat & OMAP_I2C_STAT_NACK) { err |= OMAP_I2C_STAT_NACK; omap_i2c_ack_stat(dev, OMAP_I2C_STAT_NACK); - goto out; + break; } if (stat & OMAP_I2C_STAT_AL) { dev_err(dev->dev, "Arbitration lost\n"); err |= OMAP_I2C_STAT_AL; omap_i2c_ack_stat(dev, OMAP_I2C_STAT_AL); - goto out; + break; } /* @@ -931,7 +930,7 @@ omap_i2c_isr_thread(int this_irq, void *dev_id) OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR | OMAP_I2C_STAT_ARDY)); - goto out; + break; } if (stat & OMAP_I2C_STAT_RDR) { @@ -946,7 +945,7 @@ omap_i2c_isr_thread(int this_irq, void *dev_id) i2c_omap_errata_i207(dev, stat); omap_i2c_ack_stat(dev, OMAP_I2C_STAT_RDR); - continue; + break; } if (stat & OMAP_I2C_STAT_RRDY) { @@ -969,10 +968,10 @@ omap_i2c_isr_thread(int this_irq, void *dev_id) ret = omap_i2c_transmit_data(dev, num_bytes, true); if (ret < 0) - goto out; + break; omap_i2c_ack_stat(dev, OMAP_I2C_STAT_XDR); - continue; + break; } if (stat & OMAP_I2C_STAT_XRDY) { @@ -984,7 +983,7 @@ omap_i2c_isr_thread(int this_irq, void *dev_id) ret = omap_i2c_transmit_data(dev, num_bytes, false); if (ret < 0) - goto out; + break; omap_i2c_ack_stat(dev, OMAP_I2C_STAT_XRDY); continue; @@ -994,19 +993,20 @@ omap_i2c_isr_thread(int this_irq, void *dev_id) dev_err(dev->dev, "Receive overrun\n"); err |= OMAP_I2C_STAT_ROVR; omap_i2c_ack_stat(dev, OMAP_I2C_STAT_ROVR); - goto out; + break; } if (stat & OMAP_I2C_STAT_XUDF) { dev_err(dev->dev, "Transmit underflow\n"); err |= OMAP_I2C_STAT_XUDF; omap_i2c_ack_stat(dev, OMAP_I2C_STAT_XUDF); - goto out; + break; } } while (stat); -out: omap_i2c_complete_cmd(dev, err); + +out: spin_unlock_irqrestore(&dev->lock, flags); return IRQ_HANDLED;