Skip to content

Commit a92c338

Browse files
jhnikulawsakernel
authored andcommitted
i2c: designware: Simplify master interrupt handler nesting
In my opinion 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 <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 184c475 commit a92c338

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

drivers/i2c/busses/i2c-designware-master.c

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -711,9 +711,18 @@ static u32 i2c_dw_read_clear_intrbits(struct dw_i2c_dev *dev)
711711
* Interrupt service routine. This gets called whenever an I2C master interrupt
712712
* occurs.
713713
*/
714-
static int i2c_dw_irq_handler_master(struct dw_i2c_dev *dev)
714+
static irqreturn_t i2c_dw_isr(int this_irq, void *dev_id)
715715
{
716-
u32 stat;
716+
struct dw_i2c_dev *dev = dev_id;
717+
u32 stat, enabled;
718+
719+
regmap_read(dev->map, DW_IC_ENABLE, &enabled);
720+
regmap_read(dev->map, DW_IC_RAW_INTR_STAT, &stat);
721+
if (!enabled || !(stat & ~DW_IC_INTR_ACTIVITY))
722+
return IRQ_NONE;
723+
if (pm_runtime_suspended(dev->dev) || stat == GENMASK(31, 0))
724+
return IRQ_NONE;
725+
dev_dbg(dev->dev, "enabled=%#x stat=%#x\n", enabled, stat);
717726

718727
stat = i2c_dw_read_clear_intrbits(dev);
719728

@@ -726,7 +735,7 @@ static int i2c_dw_irq_handler_master(struct dw_i2c_dev *dev)
726735
* the HW active).
727736
*/
728737
regmap_write(dev->map, DW_IC_INTR_MASK, 0);
729-
return 0;
738+
return IRQ_HANDLED;
730739
}
731740

732741
if (stat & DW_IC_INTR_TX_ABRT) {
@@ -765,24 +774,6 @@ static int i2c_dw_irq_handler_master(struct dw_i2c_dev *dev)
765774
regmap_write(dev->map, DW_IC_INTR_MASK, stat);
766775
}
767776

768-
return 0;
769-
}
770-
771-
static irqreturn_t i2c_dw_isr(int this_irq, void *dev_id)
772-
{
773-
struct dw_i2c_dev *dev = dev_id;
774-
u32 stat, enabled;
775-
776-
regmap_read(dev->map, DW_IC_ENABLE, &enabled);
777-
regmap_read(dev->map, DW_IC_RAW_INTR_STAT, &stat);
778-
if (!enabled || !(stat & ~DW_IC_INTR_ACTIVITY))
779-
return IRQ_NONE;
780-
if (pm_runtime_suspended(dev->dev) || stat == GENMASK(31, 0))
781-
return IRQ_NONE;
782-
dev_dbg(dev->dev, "enabled=%#x stat=%#x\n", enabled, stat);
783-
784-
i2c_dw_irq_handler_master(dev);
785-
786777
return IRQ_HANDLED;
787778
}
788779

0 commit comments

Comments
 (0)