From patchwork Sat Mar 11 18:24:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9618933 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9106E604CC for ; Sat, 11 Mar 2017 18:25:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89A3B28678 for ; Sat, 11 Mar 2017 18:25:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E89C2872A; Sat, 11 Mar 2017 18:25:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3C5EC28678 for ; Sat, 11 Mar 2017 18:25:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:References:To:Subject:From:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=upCdmmOZKtnAVDmiZ5cMtI3eNrn7ng/gX2mLWS4/rvw=; b=O+QPGyfNWD+rAO PhfkzOhlY/3i8yPKkcPzoruyi7Yp6BsEcvYTdEVYCdRf4kYT0C6tDaBCapNbKBpPgxqyQ/KfEUNfI U35AJ/bEGI0MtYie4zVkqhtDqY9Y8LON4J8mojSthvQ2VoHeb6ndhwwRCuyGxHKA7Kn+GL2eqHhV2 Szi+Xf+e11/bGD2HwiKHQ8+7WkLxywKaIZeQpGKUkAg/l0vh9d9DKfTvxpke+SvHAPAwmqYHqXnno 78JqoD6sGKfy9Ngpw3dDnsVtbF7ZTjBcl5o73vyjPo41iAvAtb+ZU9NfD6mtaVipv/uk6AercJq7g yuY9zsOS9bAmZJuQpB8Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cmlhk-0002Ki-LK; Sat, 11 Mar 2017 18:25:24 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cmlhd-0000sb-6S for linux-amlogic@lists.infradead.org; Sat, 11 Mar 2017 18:25:19 +0000 Received: by mail-wm0-x241.google.com with SMTP id n11so3788328wma.0 for ; Sat, 11 Mar 2017 10:24:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:references:cc:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=ttnm/aaYBX5fVoQam2zSKckCym+MaoWIyS2tgy+FDxk=; b=By7K0XHyVMIfY64h8Zv2mXvJ4ojLraVf6IIY4gp7tXAXUelCiFUkZ3an95oaJiAZle 46FFE2mShdxiudfAQ400JqxkNfEKv362kIOZkyTVo4zaeDZ53xLWm2NQX4mxML5nWVir JA90jd4vnA5tksLnkxObeDPEC8gfVCfCYwrulmlRjWlfHH0GTMnYRB+xXJbLcVWHEscV yZKC4fGAv+oZRij5S+KcOdRgSMyM0ECXcqgBRm1QGqz7KcEAuY0Lfk8kt/zqOP7S/LNt qIMY1PoAw6zuIIaw+BiQDtEvjMCK2Rsb15IzOdf5qAzG/03uSSOYhgq7zYsb8FgWBbPv 0wXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:cc:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=ttnm/aaYBX5fVoQam2zSKckCym+MaoWIyS2tgy+FDxk=; b=GtTSKdG/aBF9a6tFDkahJLqZMfvjH8LU4q6wLH0BovyN4/aZAWrLWkI6gT/5tX/QM1 enfwKScjBS8itxWUthwdAtkPdY3C2FgtvTUP0ETUMq1dR9rv7IlkPDhav/fbDUzug64a WSqcn95soScjvD9T/3FeGiGI1fSYr5OONeIyNa1KbSBufwrtjLBfsChSeg2vE9kP6Twh q8smBF0NmI66a7yV8oeNvTF9gZwy61wxG5P5eVuFVjDZBy0wUtujS4XOe8A00c4Iu4GS ADg6T2h05na2lvLDQha7itZvQom4sP4OQNlNFy7XuXUutDO1XP4/0KXYyjP99zx25gId be2A== X-Gm-Message-State: AFeK/H0PzU2J9+Hfgb5p6mmVFSH5PfmidhFmLvztueeCqZTYH023fUhrrKWzl/obnDLg2A== X-Received: by 10.28.35.66 with SMTP id j63mr4161418wmj.84.1489256695454; Sat, 11 Mar 2017 10:24:55 -0800 (PST) Received: from ?IPv6:2003:c6:ebdc:4000:3419:a191:120:8b2e? (p200300C6EBDC40003419A19101208B2E.dip0.t-ipconnect.de. [2003:c6:ebdc:4000:3419:a191:120:8b2e]) by smtp.googlemail.com with ESMTPSA id 61sm18180840wrs.29.2017.03.11.10.24.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Mar 2017 10:24:55 -0800 (PST) From: Heiner Kallweit Subject: [PATCH v3 10/10] i2c: meson: improve and simplify interrupt handler To: Wolfram Sang , Jerome Brunet References: Message-ID: Date: Sat, 11 Mar 2017 19:24:26 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170311_102517_415682_5B71325F X-CRM114-Status: GOOD ( 10.04 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, "linux-i2c@vger.kernel.org" Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The preceding changes in this patch series now allow to simplify the interrupt handler significantly. Signed-off-by: Heiner Kallweit --- v2: - rebased v3: - no changes --- drivers/i2c/busses/i2c-meson.c | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/drivers/i2c/busses/i2c-meson.c b/drivers/i2c/busses/i2c-meson.c index 23f25efa..590715ae 100644 --- a/drivers/i2c/busses/i2c-meson.c +++ b/drivers/i2c/busses/i2c-meson.c @@ -239,41 +239,21 @@ static irqreturn_t meson_i2c_irq(int irqno, void *dev_id) goto out; } - switch (i2c->state) { - case STATE_READ: - if (i2c->count > 0) { - meson_i2c_get_data(i2c, i2c->msg->buf + i2c->pos, - i2c->count); - i2c->pos += i2c->count; - } - - if (i2c->pos >= i2c->msg->len) { - i2c->state = STATE_IDLE; - complete(&i2c->done); - break; - } - - meson_i2c_prepare_xfer(i2c); - break; - case STATE_WRITE: - i2c->pos += i2c->count; + if (i2c->state == STATE_READ && i2c->count) + meson_i2c_get_data(i2c, i2c->msg->buf + i2c->pos, i2c->count); - if (i2c->pos >= i2c->msg->len) { - i2c->state = STATE_IDLE; - complete(&i2c->done); - break; - } + i2c->pos += i2c->count; - meson_i2c_prepare_xfer(i2c); - break; + if (i2c->pos >= i2c->msg->len) { + i2c->state = STATE_IDLE; + complete(&i2c->done); + goto out; } + /* Restart the processing */ + meson_i2c_prepare_xfer(i2c); + meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_START, REG_CTRL_START); out: - if (i2c->state != STATE_IDLE) - /* Restart the processing */ - meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_START, - REG_CTRL_START); - spin_unlock(&i2c->lock); return IRQ_HANDLED;