Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3137232imm; Mon, 24 Sep 2018 16:53:06 -0700 (PDT) X-Google-Smtp-Source: ACcGV62NohxCvA/UCyNRkKbhus4LBncDKdQ5FP1SoEboBQAPswJxiBxoXxk/Dh3fTYn10qs7fihT X-Received: by 2002:a63:f:: with SMTP id 15-v6mr870045pga.430.1537833186215; Mon, 24 Sep 2018 16:53:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537833186; cv=none; d=google.com; s=arc-20160816; b=juq1eeN5tOfvCjxzfbsEgW/ylpS2SHrP4ujkZIpOdepm+uCpDaJ673kuhwczsfv6un XHzdNfduiWiDonPlrmJ5MhiLm1Cn4j/xkzm1OaxV0s2fPEb+y9r5D2U7gP5O2RkKAIhY tohVmpskNTxYiTF9oMSlV1DWlatedHIekh5H6FSHdTk67pZAESOEcjKQRyk6vR3ynuuE zusIDB6gs7b1ILq23RspdPOyVooHrtnHlRKOGrZixwgOPz53CgYdcrJGlcfQzrXefdUY dCcmrsMY0ApePha0wTCPi/OZMFSyfRT0MyFFXlRQ4i+69/+9DD5mHF/pV1kc4EIo/v1v X3lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+uyMWo2cY9l4Ar92yvj0UCofpuhs+WjwXrGz/0hgOvE=; b=YmVOYrESQ85NE9hF6aQPAUIqhp7lpv5cJe5W8o0DtbxPu6FwzrNf08wTYUsJ67Qi2M qG3vB3uPB2YB2cWPJuuCjPcQf44w3eJn8OyVjoNvUzNcKMK+gcqPp/T6FvQXZiNVUHPx Wbs7s3EnqzMUH0PFtR8IVxxuybMNXVKDHS6Tv8OmNI+GY4ej2t8kiqvjrcTvLuGLuy4J QztdImqNj/yFveBlJ/aaOijpoiIsxS+21efLwc3gBFqla6uc+kIx1ozsfaWZz6EIyfBe NQ8UIvscnH3y0JRgKVkUBi2nVLjQpBLWE9pxGnXA/2xosLjqekbWU8da2uRsjzu4bCej O6yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DlzRZgjq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y72-v6si74695pgd.142.2018.09.24.16.52.51; Mon, 24 Sep 2018 16:53:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DlzRZgjq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728164AbeIYF5Z (ORCPT + 99 others); Tue, 25 Sep 2018 01:57:25 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:46873 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727822AbeIYF5V (ORCPT ); Tue, 25 Sep 2018 01:57:21 -0400 Received: by mail-pg1-f195.google.com with SMTP id b129-v6so10059356pga.13 for ; Mon, 24 Sep 2018 16:52:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+uyMWo2cY9l4Ar92yvj0UCofpuhs+WjwXrGz/0hgOvE=; b=DlzRZgjqvhkiyeDAGcTl0W1nVkTR+j0agSSRSUTI4Txj1ks1RC3nLiN2wUFfOUjSWx VLXE4L3DjmOVlrDZ5HBr3gv5gw3WRZ/UsjsE98o2pcgmSn7AGfK2RNfRcqJxkj0zeq70 Vh5mId5TArQLSsq/ZVJFg0Awvg2cXD3Vw1TZU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+uyMWo2cY9l4Ar92yvj0UCofpuhs+WjwXrGz/0hgOvE=; b=jL5/mxCnG6MRNdqLrBwbgHsXRkTOLdOkCbTzL6UGhlS5zROluFzpuPMbGSPXxbbWQG AnuoWVi3MNvmgU3Gupn+sLw7XjOsfpIjkrerVvpVRTe0AUlg0T6jw3DSPCH+r9Hwgpaq m8w8W7ljp9lmV/SC8p3i2T+wp+iQNevZJELmGcVSu/++tAx4rSpymT/WIyGOWbo088Jj TwhUCv+VL3LLjsppPqkFHcpaFAHnpXrGdlU6Ul++BkjJrJ4zBRnz/oWO4y8iGSiw4GZa 9G8k5y+H3n7rWsWvZwowY8gTvLQ6bRj+ybmh3M8pJAxKEfIGKeccAPafTjUkyIhtWvEW g++Q== X-Gm-Message-State: ABuFfohcyyvB03bltkQP5XjwNjzJCRf0NTjQqJyR1zLQ65aTtSd+m0Jq kDT6z4qAeHM58ho+i3LVMvOOhQ== X-Received: by 2002:a17:902:14e:: with SMTP id 72-v6mr856142plb.299.1537833158783; Mon, 24 Sep 2018 16:52:38 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:201:7e28:b9f3:6afc:5326]) by smtp.gmail.com with ESMTPSA id d81-v6sm518993pfj.122.2018.09.24.16.52.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Sep 2018 16:52:38 -0700 (PDT) From: Stephen Boyd To: Wolfram Sang Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org, Karthikeyan Ramasubramanian , Sagar Dharia , Girish Mahadevan , Doug Anderson Subject: [PATCH v3 3/3] i2c: i2c-qcom-geni: Simplify irq handler Date: Mon, 24 Sep 2018 16:52:35 -0700 Message-Id: <20180924235235.182649-3-swboyd@chromium.org> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog In-Reply-To: <20180924235235.182649-1-swboyd@chromium.org> References: <20180924235235.182649-1-swboyd@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We don't need to use goto here, we can just collapse the if statement and goto chain into multiple branches and then combine some duplicate completion calls into one big if statement. Let's do it to clean up code some more. Cc: Karthikeyan Ramasubramanian Cc: Sagar Dharia Cc: Girish Mahadevan Cc: Doug Anderson Signed-off-by: Stephen Boyd --- drivers/i2c/busses/i2c-qcom-geni.c | 70 +++++++++++++----------------- 1 file changed, 29 insertions(+), 41 deletions(-) diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c index 0b466835cf40..527f55c8c4c7 100644 --- a/drivers/i2c/busses/i2c-qcom-geni.c +++ b/drivers/i2c/busses/i2c-qcom-geni.c @@ -201,21 +201,23 @@ static void geni_i2c_err(struct geni_i2c_dev *gi2c, int err) static irqreturn_t geni_i2c_irq(int irq, void *dev) { struct geni_i2c_dev *gi2c = dev; - int j; + void __iomem *base = gi2c->se.base; + int j, p; u32 m_stat; u32 rx_st; u32 dm_tx_st; u32 dm_rx_st; u32 dma; + u32 val; struct i2c_msg *cur; unsigned long flags; spin_lock_irqsave(&gi2c->lock, flags); - m_stat = readl_relaxed(gi2c->se.base + SE_GENI_M_IRQ_STATUS); - rx_st = readl_relaxed(gi2c->se.base + SE_GENI_RX_FIFO_STATUS); - dm_tx_st = readl_relaxed(gi2c->se.base + SE_DMA_TX_IRQ_STAT); - dm_rx_st = readl_relaxed(gi2c->se.base + SE_DMA_RX_IRQ_STAT); - dma = readl_relaxed(gi2c->se.base + SE_GENI_DMA_MODE_EN); + m_stat = readl_relaxed(base + SE_GENI_M_IRQ_STATUS); + rx_st = readl_relaxed(base + SE_GENI_RX_FIFO_STATUS); + dm_tx_st = readl_relaxed(base + SE_DMA_TX_IRQ_STAT); + dm_rx_st = readl_relaxed(base + SE_DMA_RX_IRQ_STAT); + dma = readl_relaxed(base + SE_GENI_DMA_MODE_EN); cur = gi2c->cur; if (!cur || @@ -238,26 +240,17 @@ static irqreturn_t geni_i2c_irq(int irq, void *dev) /* Disable the TX Watermark interrupt to stop TX */ if (!dma) - writel_relaxed(0, gi2c->se.base + - SE_GENI_TX_WATERMARK_REG); - goto irqret; - } - - if (dma) { + writel_relaxed(0, base + SE_GENI_TX_WATERMARK_REG); + } else if (dma) { dev_dbg(gi2c->se.dev, "i2c dma tx:0x%x, dma rx:0x%x\n", dm_tx_st, dm_rx_st); - goto irqret; - } - - if (cur->flags & I2C_M_RD && - m_stat & (M_RX_FIFO_WATERMARK_EN | M_RX_FIFO_LAST_EN)) { + } else if (cur->flags & I2C_M_RD && + m_stat & (M_RX_FIFO_WATERMARK_EN | M_RX_FIFO_LAST_EN)) { u32 rxcnt = rx_st & RX_FIFO_WC_MSK; for (j = 0; j < rxcnt; j++) { - u32 val; - int p = 0; - - val = readl_relaxed(gi2c->se.base + SE_GENI_RX_FIFOn); + p = 0; + val = readl_relaxed(base + SE_GENI_RX_FIFOn); while (gi2c->cur_rd < cur->len && p < sizeof(val)) { cur->buf[gi2c->cur_rd++] = val & 0xff; val >>= 8; @@ -270,44 +263,39 @@ static irqreturn_t geni_i2c_irq(int irq, void *dev) m_stat & M_TX_FIFO_WATERMARK_EN) { for (j = 0; j < gi2c->tx_wm; j++) { u32 temp; - u32 val = 0; - int p = 0; + val = 0; + p = 0; while (gi2c->cur_wr < cur->len && p < sizeof(val)) { temp = cur->buf[gi2c->cur_wr++]; val |= temp << (p * 8); p++; } - writel_relaxed(val, gi2c->se.base + SE_GENI_TX_FIFOn); + writel_relaxed(val, base + SE_GENI_TX_FIFOn); /* TX Complete, Disable the TX Watermark interrupt */ if (gi2c->cur_wr == cur->len) { - writel_relaxed(0, gi2c->se.base + - SE_GENI_TX_WATERMARK_REG); + writel_relaxed(0, base + SE_GENI_TX_WATERMARK_REG); break; } } } -irqret: + if (m_stat) - writel_relaxed(m_stat, gi2c->se.base + SE_GENI_M_IRQ_CLEAR); + writel_relaxed(m_stat, base + SE_GENI_M_IRQ_CLEAR); + + if (dma && dm_tx_st) + writel_relaxed(dm_tx_st, base + SE_DMA_TX_IRQ_CLR); + if (dma && dm_rx_st) + writel_relaxed(dm_rx_st, base + SE_DMA_RX_IRQ_CLR); - if (dma) { - if (dm_tx_st) - writel_relaxed(dm_tx_st, gi2c->se.base + - SE_DMA_TX_IRQ_CLR); - if (dm_rx_st) - writel_relaxed(dm_rx_st, gi2c->se.base + - SE_DMA_RX_IRQ_CLR); - } /* if this is err with done-bit not set, handle that through timeout. */ - if (m_stat & M_CMD_DONE_EN || m_stat & M_CMD_ABORT_EN) - complete(&gi2c->done); - else if (dm_tx_st & TX_DMA_DONE || dm_tx_st & TX_RESET_DONE) - complete(&gi2c->done); - else if (dm_rx_st & RX_DMA_DONE || dm_rx_st & RX_RESET_DONE) + if (m_stat & M_CMD_DONE_EN || m_stat & M_CMD_ABORT_EN || + dm_tx_st & TX_DMA_DONE || dm_tx_st & TX_RESET_DONE || + dm_rx_st & RX_DMA_DONE || dm_rx_st & RX_RESET_DONE) complete(&gi2c->done); spin_unlock_irqrestore(&gi2c->lock, flags); + return IRQ_HANDLED; } -- Sent by a computer through tubes