From patchwork Thu Mar 9 07:01:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9612375 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 42209602B4 for ; Thu, 9 Mar 2017 07:02:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2319728452 for ; Thu, 9 Mar 2017 07:02:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17FCB2846C; Thu, 9 Mar 2017 07:02:26 +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 C3DCE28452 for ; Thu, 9 Mar 2017 07:02:25 +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:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZDC2No61MZKHaSZg0y0/Lt4cTgbPvbURgcBIUJAv/Oo=; b=o87w92rle5A3So EtFemvamY7ulQgJbO1p77iToOdTX8XDyu52W+e7lHm+UCBSNGzOIH+hW8zHTekkZxgQDLCj8e8ChP 9UGC7vh0DMw1rCmYTejltXzSycXjUolEivDKnh4PM07zTg4lP2KpS2W2V7CWFQyO9D7e5TkRBpU4S pFDIgmih1myjEfyEhGhk70PM6iz5wgcz+QOP4qrUKjZ6Bk1lQMg/3yFj/DYQqoCR7S580L4B0qekA eKcp3KRWcpEYsiiWqVs/efYAEJTCGV30IXTB2JXjX8mHWbPQsc3ogTzEyhWMhc2b2RPJX76Fjt4f/ r2riQIjFVIjrIM74C+TQ==; 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 1cls5e-0002n2-B3; Thu, 09 Mar 2017 07:02:22 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cls5Y-0002Yc-7B for linux-amlogic@lists.infradead.org; Thu, 09 Mar 2017 07:02:19 +0000 Received: by mail-wm0-x243.google.com with SMTP id z63so9380425wmg.2 for ; Wed, 08 Mar 2017 23:01:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=7FqgfLPdldN1Za755JdtL/cQo5kKCgb+WpK0FjiZhdo=; b=hWhKgY1WktAQpGSYoDWqhclg9PTJEtldgxF79A+uxJedUiE4xaGPPZb7g1e2WwDal8 +2Q7hC9Ap5aGxs/bbZSXxn6E1Jg3rDcPBP2VmF+qVHzJppfKXn9MJxyxYulZ7Tl9K/v/ JJXm0sMHNYVD75YtqvhRcEwN5quPla0XG1Ya5NCW+aNw0BhQ2lqj98vZS5IvLcoB8jRj 28Wp/rNGow5JNLFKx9B6B6z06kiGGjbjyiM1Xg2Oo77rE53eZtiyeH+VoiOjjbXQDOlr 1oxHe37Dt6mk/EaGMjsrTOwpBOKkcti3QICNWKHbs8Y8pkrHos1mqS+K2jNkVrOWk3Aa Gcmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=7FqgfLPdldN1Za755JdtL/cQo5kKCgb+WpK0FjiZhdo=; b=NAgR+esEnOlL6ohlk5KgkRNTWgQeQckUnPWIVH4rVd9X4vTP4/M42e5n8nhKLowXX9 JHgSLzYPmfc9xLAWE8IBUk7GPEc8rM4OluQJ1ZxczPIFx6a2SjOk5kRteaPMiZyGJcDo JRYAGlEM0shEewWPFClBSQgRBi6+VLjW0x8FFO/n1OwF1hdFewiJHeNShd3+VSp01VRD IM8bgOlGK6n+yp48InJOZEUuE8Km4ezVaIADBd20hnb8yAW1qXvLeMWju/6kktCeUTG/ i0aijYMcjI6Lgg++3xbAL7w/hsSVt4+Ol3kETFDCH4HiJdJYynFz1oVbNQJQZIEcuBMD SX0A== X-Gm-Message-State: AMke39k5sph5xHP6AI6ahxbM6aLQS+EBRU/FeVW7F5v99MHsEDh+pqgK+sO39hq+UcFLnQ== X-Received: by 10.28.197.133 with SMTP id v127mr11245110wmf.120.1489042911532; Wed, 08 Mar 2017 23:01:51 -0800 (PST) Received: from ?IPv6:2003:c6:ebdc:4000:b589:624b:5134:aa75? (p200300C6EBDC4000B589624B5134AA75.dip0.t-ipconnect.de. [2003:c6:ebdc:4000:b589:624b:5134:aa75]) by smtp.googlemail.com with ESMTPSA id s17sm7069782wrc.25.2017.03.08.23.01.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Mar 2017 23:01:51 -0800 (PST) Subject: [PATCH v2 10/10] i2c: meson: improve and simplify interrupt handler To: Wolfram Sang , Jerome Brunet References: From: Heiner Kallweit Message-ID: <5b848849-d27e-285f-e97f-31b32eeda8da@gmail.com> Date: Thu, 9 Mar 2017 08:01:11 +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-20170308_230216_447273_A7033632 X-CRM114-Status: GOOD ( 10.67 ) 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 --- 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 8f4658de..25415690 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;