From: Jarkko Nikula <jarkko.nikula@linux.intel.com>
To: linux-i2c@vger.kernel.org
Cc: Wolfram Sang <wsa@kernel.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Jan Dabros <jsd@semihalf.com>, Michael Wu <michael.wu@vatics.com>,
Tian Ye <tianye@sugon.com>,
Jarkko Nikula <jarkko.nikula@linux.intel.com>
Subject: [PATCH v2 09/12] i2c: designware: Simplify master interrupt handler nesting
Date: Wed, 2 Nov 2022 15:11:22 +0200 [thread overview]
Message-ID: <20221102131125.421512-10-jarkko.nikula@linux.intel.com> (raw)
In-Reply-To: <20221102131125.421512-1-jarkko.nikula@linux.intel.com>
In my opinnion a few lines of spurious interrupt detection code can be
moved to the actual master interrupt handling function i2c_dw_isr()
without hurting readability.
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-master.c | 33 ++++++++--------------
1 file changed, 12 insertions(+), 21 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
index 9c2c9d002dc3..dfb499e54c05 100644
--- a/drivers/i2c/busses/i2c-designware-master.c
+++ b/drivers/i2c/busses/i2c-designware-master.c
@@ -711,9 +711,18 @@ static u32 i2c_dw_read_clear_intrbits(struct dw_i2c_dev *dev)
* Interrupt service routine. This gets called whenever an I2C master interrupt
* occurs.
*/
-static int i2c_dw_irq_handler_master(struct dw_i2c_dev *dev)
+static irqreturn_t i2c_dw_isr(int this_irq, void *dev_id)
{
- u32 stat;
+ struct dw_i2c_dev *dev = dev_id;
+ u32 stat, enabled;
+
+ regmap_read(dev->map, DW_IC_ENABLE, &enabled);
+ regmap_read(dev->map, DW_IC_RAW_INTR_STAT, &stat);
+ if (!enabled || !(stat & ~DW_IC_INTR_ACTIVITY))
+ return IRQ_NONE;
+ if (pm_runtime_suspended(dev->dev) || stat == GENMASK(31, 0))
+ return IRQ_NONE;
+ dev_dbg(dev->dev, "enabled=%#x stat=%#x\n", enabled, stat);
stat = i2c_dw_read_clear_intrbits(dev);
@@ -726,7 +735,7 @@ static int i2c_dw_irq_handler_master(struct dw_i2c_dev *dev)
* the HW active).
*/
regmap_write(dev->map, DW_IC_INTR_MASK, 0);
- return 0;
+ return IRQ_HANDLED;
}
if (stat & DW_IC_INTR_TX_ABRT) {
@@ -765,24 +774,6 @@ static int i2c_dw_irq_handler_master(struct dw_i2c_dev *dev)
regmap_write(dev->map, DW_IC_INTR_MASK, stat);
}
- return 0;
-}
-
-static irqreturn_t i2c_dw_isr(int this_irq, void *dev_id)
-{
- struct dw_i2c_dev *dev = dev_id;
- u32 stat, enabled;
-
- regmap_read(dev->map, DW_IC_ENABLE, &enabled);
- regmap_read(dev->map, DW_IC_RAW_INTR_STAT, &stat);
- if (!enabled || !(stat & ~DW_IC_INTR_ACTIVITY))
- return IRQ_NONE;
- if (pm_runtime_suspended(dev->dev) || stat == GENMASK(31, 0))
- return IRQ_NONE;
- dev_dbg(dev->dev, "enabled=%#x stat=%#x\n", enabled, stat);
-
- i2c_dw_irq_handler_master(dev);
-
return IRQ_HANDLED;
}
--
2.35.1
next prev parent reply other threads:[~2022-11-02 13:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-02 13:11 [PATCH v2 00/12] i2c: designware: Slave fixes and generic cleanups Jarkko Nikula
2022-11-02 13:11 ` [PATCH v2 01/12] i2c: designware: Fix slave state machine for sequential reads Jarkko Nikula
2022-11-02 13:11 ` [PATCH v2 02/12] i2c: designware: Empty receive FIFO in slave interrupt handler Jarkko Nikula
2022-11-02 13:11 ` [PATCH v2 03/12] i2c: designware: Define software status flags with BIT() Jarkko Nikula
2022-11-02 13:11 ` [PATCH v2 04/12] i2c: designware: Remove needless initializations from i2c_dw_reg_slave() Jarkko Nikula
2022-11-02 13:11 ` [PATCH v2 05/12] i2c: designware: Remove unused completion code from i2c-designware-slave Jarkko Nikula
2022-11-02 13:11 ` [PATCH v2 06/12] i2c: designware: Simplify slave interrupt handler nesting Jarkko Nikula
2022-11-02 13:11 ` [PATCH v2 07/12] i2c: designware: Do not process interrupt when device is suspended Jarkko Nikula
2022-11-02 13:11 ` [PATCH v2 08/12] i2c: designware: Move debug print in i2c_dw_isr() Jarkko Nikula
2022-11-02 13:11 ` Jarkko Nikula [this message]
2022-11-02 14:23 ` [PATCH v2 09/12] i2c: designware: Simplify master interrupt handler nesting Andy Shevchenko
2022-11-02 13:11 ` [PATCH v2 10/12] i2c: designware: Remove common i2c_dw_disable_int() Jarkko Nikula
2022-11-02 13:11 ` [PATCH v2 11/12] i2c: designware: Align defines in i2c-designware-core.h Jarkko Nikula
2022-11-02 13:11 ` [PATCH v2 12/12] i2c: designware: Add comment to custom register value constants Jarkko Nikula
2022-11-02 14:37 ` Andy Shevchenko
2022-11-03 8:48 ` Jarkko Nikula
2022-11-02 14:28 ` [PATCH v2 00/12] i2c: designware: Slave fixes and generic cleanups Andy Shevchenko
2022-11-07 11:55 ` Jarkko Nikula
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221102131125.421512-10-jarkko.nikula@linux.intel.com \
--to=jarkko.nikula@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=jsd@semihalf.com \
--cc=linux-i2c@vger.kernel.org \
--cc=michael.wu@vatics.com \
--cc=mika.westerberg@linux.intel.com \
--cc=tianye@sugon.com \
--cc=wsa@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox