From patchwork Fri Sep 2 21:22:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9311693 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 B9F1F60865 for ; Fri, 2 Sep 2016 21:23:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA6EC29843 for ; Fri, 2 Sep 2016 21:23:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F9742985C; Fri, 2 Sep 2016 21:23:06 +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=-5.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3ED732985E for ; Fri, 2 Sep 2016 21:23:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751699AbcIBVXF (ORCPT ); Fri, 2 Sep 2016 17:23:05 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:35459 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752006AbcIBVXE (ORCPT ); Fri, 2 Sep 2016 17:23:04 -0400 Received: by mail-wm0-f65.google.com with SMTP id c133so4383314wmd.2 for ; Fri, 02 Sep 2016 14:23:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:subject:to:references:cc:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=w86LY+uVN+pVj/CWLsQaOc8jmeNUh2El63f/GzWJtJk=; b=ix5YvB9zeH8TxafCCB012kEmsEa/N6k0mEnmQKoW4UWivi6q7vjPGK3hquD62UKHWV Qyqq92riCtwsWpniaIT/hI2jJaS7MZZTMlb67/WAFg5zeY71WDRVkdzttNVD8zqwt6gj NcrTvIgSzvKHzuuPb9USzUd9hoJ7PBLyhimXj7ARm+E2j4X/xOVL1aWZsPXaiGB47pnc xTGAjAAhzxXCwj0ZYVG0aGyATTjerioZeWetk+jOuDjjbqixOsqZNxdjwC/VJqjWxib/ Zs84oZmphF0RR1tNw3gDlYykl35CbnunJ1zAlz6O2wFd88XA6Zw2kuLShcozZg1huinn 97zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:subject:to:references:cc:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=w86LY+uVN+pVj/CWLsQaOc8jmeNUh2El63f/GzWJtJk=; b=aFDJdJqTzmmlVoxjDCYpXOJCgdFZfzZMILLVJL/fSMsPopK990ucpysdNMcqJ77bfO OBg2vB6CM0plppQeih30JDo1ees9gFhErowaaNDvWcJ6UUMc5xb6UHvfcuY4wl2v3xua atjrAGyV953ZLVekTSh5+6OL9VM8luhsyDSoXkE/n9aDdTb3ds1+6kmO8OXu6snmCTUw rjiQdH4oFBQHiNqEjKDMs5354NfggQiGndSfW4TYps1rOyeerCsPvZQlgquQ/QOBDQjn LfMfdnJTECzli4c+jMBV95rMBMn+sboljmIrXPG6K4YgdHGMniBsc4yTHoSWYXSjGhuW YSRA== X-Gm-Message-State: AE9vXwO9Pq5267t7APsB8TOz3Pyv4akZdQxfPZOf6+PF9qFYRUylvaI2RhxGt2OS9EFGkw== X-Received: by 10.28.50.3 with SMTP id y3mr5279091wmy.23.1472851383086; Fri, 02 Sep 2016 14:23:03 -0700 (PDT) Received: from ?IPv6:2003:62:5f43:9500:39ed:a1fb:9a43:e02d? (p200300625F43950039EDA1FB9A43E02D.dip0.t-ipconnect.de. [2003:62:5f43:9500:39ed:a1fb:9a43:e02d]) by smtp.googlemail.com with ESMTPSA id d8sm5420142wmi.0.2016.09.02.14.23.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Sep 2016 14:23:02 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH v2 18/23] spi: fsl-espi: improve the ISR frame To: Mark Brown References: Cc: "linux-spi@vger.kernel.org" Message-ID: Date: Fri, 2 Sep 2016 23:22:29 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Improve the ISR frame: - move resetting the event bits to the ISR frame - change type of parameter irq to int - make sure that the event bits match at least one bit in the interrupt mask register Signed-off-by: Heiner Kallweit --- v2: - rebased --- drivers/spi/spi-fsl-espi.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index 190ca5c..534dc14 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -451,17 +451,11 @@ static void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) ®_base->event)) & SPIE_NF), 1000, 0); if (!ret) { dev_err(mspi->dev, "tired waiting for SPIE_NF\n"); - - /* Clear the SPIE bits */ - mpc8xxx_spi_write_reg(®_base->event, events); complete(&mspi->done); return; } } - /* Clear the events */ - mpc8xxx_spi_write_reg(®_base->event, events); - mspi->count -= 1; if (mspi->count) { u32 word = mspi->get_tx(mspi); @@ -472,23 +466,26 @@ static void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) } } -static irqreturn_t fsl_espi_irq(s32 irq, void *context_data) +static irqreturn_t fsl_espi_irq(int irq, void *context_data) { struct mpc8xxx_spi *mspi = context_data; struct fsl_espi_reg *reg_base = mspi->reg_base; - irqreturn_t ret = IRQ_NONE; - u32 events; + u32 mask, events; - /* Get interrupt events(tx/rx) */ + /* Get interrupt mask and events and check that irq belongs to us */ + mask = mpc8xxx_spi_read_reg(®_base->mask); events = mpc8xxx_spi_read_reg(®_base->event); - if (events) - ret = IRQ_HANDLED; + if (!(mask & events)) + return IRQ_NONE; dev_vdbg(mspi->dev, "%s: events %x\n", __func__, events); fsl_espi_cpu_irq(mspi, events); - return ret; + /* Clear the events */ + mpc8xxx_spi_write_reg(®_base->event, events); + + return IRQ_HANDLED; } #ifdef CONFIG_PM