* [PATCH v2] i2c: designware: call i2c_dw_read_clear_intrbits_slave() once
@ 2020-10-22 5:46 Michael Wu
2020-10-22 13:50 ` Jarkko Nikula
0 siblings, 1 reply; 2+ messages in thread
From: Michael Wu @ 2020-10-22 5:46 UTC (permalink / raw)
To: Jarkko Nikula, Andy Shevchenko, Mika Westerberg, linux-i2c,
linux-kernel
Cc: Morgan Chang, Michael Wu
If some bits were cleared by i2c_dw_read_clear_intrbits_slave() in
i2c_dw_isr_slave() and not handled immediately, those cleared bits would
not be shown again by later i2c_dw_read_clear_intrbits_slave(). They
therefore were forgotten to be handled.
i2c_dw_read_clear_intrbits_slave() should be called once in an ISR and take
its returned state for all later handlings.
Signed-off-by: Michael Wu <michael.wu@vatics.com>
---
Changes in v2:
- revert moving I2C_SLAVE_WRITE_REQUESTED reporting
drivers/i2c/busses/i2c-designware-slave.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-slave.c b/drivers/i2c/busses/i2c-designware-slave.c
index 44974b53a626..8eced99b7aeb 100644
--- a/drivers/i2c/busses/i2c-designware-slave.c
+++ b/drivers/i2c/busses/i2c-designware-slave.c
@@ -159,7 +159,6 @@ static int i2c_dw_irq_handler_slave(struct dw_i2c_dev *dev)
u32 raw_stat, stat, enabled, tmp;
u8 val = 0, slave_activity;
- regmap_read(dev->map, DW_IC_INTR_STAT, &stat);
regmap_read(dev->map, DW_IC_ENABLE, &enabled);
regmap_read(dev->map, DW_IC_RAW_INTR_STAT, &raw_stat);
regmap_read(dev->map, DW_IC_STATUS, &tmp);
@@ -168,6 +167,7 @@ static int i2c_dw_irq_handler_slave(struct dw_i2c_dev *dev)
if (!enabled || !(raw_stat & ~DW_IC_INTR_ACTIVITY) || !dev->slave)
return 0;
+ stat = i2c_dw_read_clear_intrbits_slave(dev);
dev_dbg(dev->dev,
"%#x STATUS SLAVE_ACTIVITY=%#x : RAW_INTR_STAT=%#x : INTR_STAT=%#x\n",
enabled, slave_activity, raw_stat, stat);
@@ -188,11 +188,9 @@ static int i2c_dw_irq_handler_slave(struct dw_i2c_dev *dev)
val);
}
regmap_read(dev->map, DW_IC_CLR_RD_REQ, &tmp);
- stat = i2c_dw_read_clear_intrbits_slave(dev);
} else {
regmap_read(dev->map, DW_IC_CLR_RD_REQ, &tmp);
regmap_read(dev->map, DW_IC_CLR_RX_UNDER, &tmp);
- stat = i2c_dw_read_clear_intrbits_slave(dev);
}
if (!i2c_slave_event(dev->slave,
I2C_SLAVE_READ_REQUESTED,
@@ -207,7 +205,6 @@ static int i2c_dw_irq_handler_slave(struct dw_i2c_dev *dev)
regmap_read(dev->map, DW_IC_CLR_RX_DONE, &tmp);
i2c_slave_event(dev->slave, I2C_SLAVE_STOP, &val);
- stat = i2c_dw_read_clear_intrbits_slave(dev);
return 1;
}
@@ -217,10 +214,8 @@ static int i2c_dw_irq_handler_slave(struct dw_i2c_dev *dev)
if (!i2c_slave_event(dev->slave, I2C_SLAVE_WRITE_RECEIVED,
&val))
dev_vdbg(dev->dev, "Byte %X acked!", val);
- } else {
+ } else
i2c_slave_event(dev->slave, I2C_SLAVE_STOP, &val);
- stat = i2c_dw_read_clear_intrbits_slave(dev);
- }
return 1;
}
@@ -230,7 +225,6 @@ static irqreturn_t i2c_dw_isr_slave(int this_irq, void *dev_id)
struct dw_i2c_dev *dev = dev_id;
int ret;
- i2c_dw_read_clear_intrbits_slave(dev);
ret = i2c_dw_irq_handler_slave(dev);
if (ret > 0)
complete(&dev->cmd_complete);
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] i2c: designware: call i2c_dw_read_clear_intrbits_slave() once
2020-10-22 5:46 [PATCH v2] i2c: designware: call i2c_dw_read_clear_intrbits_slave() once Michael Wu
@ 2020-10-22 13:50 ` Jarkko Nikula
0 siblings, 0 replies; 2+ messages in thread
From: Jarkko Nikula @ 2020-10-22 13:50 UTC (permalink / raw)
To: Michael Wu, Andy Shevchenko, Mika Westerberg, linux-i2c,
linux-kernel
Cc: Morgan Chang
Hi
On 10/22/20 8:46 AM, Michael Wu wrote:
> @@ -217,10 +214,8 @@ static int i2c_dw_irq_handler_slave(struct dw_i2c_dev *dev)
> if (!i2c_slave_event(dev->slave, I2C_SLAVE_WRITE_RECEIVED,
> &val))
> dev_vdbg(dev->dev, "Byte %X acked!", val);
> - } else {
> + } else
> i2c_slave_event(dev->slave, I2C_SLAVE_STOP, &val);
> - stat = i2c_dw_read_clear_intrbits_slave(dev);
> - }
>
Minor nit. Please don't remove braces here since the upper part of if
statement has them.
From Documentation/process/coding-style.rst:
"
This does not apply if only one branch of a conditional statement is a
single
statement; in the latter case use braces in both branches:
.. code-block:: c
if (condition) {
do_this();
do_that();
} else {
otherwise();
}
"
Otherwise looks good to me.
Jarkko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-22 13:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-22 5:46 [PATCH v2] i2c: designware: call i2c_dw_read_clear_intrbits_slave() once Michael Wu
2020-10-22 13:50 ` Jarkko Nikula
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).