diff options
author | Felipe Balbi <balbi@ti.com> | 2012-09-12 06:57:59 -0400 |
---|---|---|
committer | Wolfram Sang <w.sang@pengutronix.de> | 2012-09-12 09:02:14 -0400 |
commit | 540a4790f7da0d3ca5ad9d726f198a5eb4db05ec (patch) | |
tree | e4b018b7a0587cfaeb024286b58256c8b50e52ae /drivers/i2c/busses/i2c-omap.c | |
parent | c55edb99028f4d2cd5ad4700447451725835a7bc (diff) |
i2c: omap: simplify omap_i2c_ack_stat()
stat & BIT(1) is the same as BIT(1), so let's
simplify things a bit by removing "stat &" from
all omap_i2c_ack_stat() calls.
Code snippet (extremely simplified):
if (stat & NACK) {
...
omap_i2c_ack_stat(dev, stat & NACK);
}
if (stat & RDR) {
...
omap_i2c_ack_stat(dev, stat & RDR);
}
and so on. The tricky place is only WRT errata handling, for example:
if (*stat & (NACK | AL)) {
omap_i2c_ack_stat(dev, *stat & (XRDY | XDR));
...
}
but in this case, the errata says we must clear XRDY and XDR if that
errata triggers, so if they just got enabled or not, it doesn't matter.
Another tricky place is RDR | RRDY (likewise for XDR | XRDY):
if (stat & (RDR | RRDY)) {
...
omap_i2c_ack_stat(dev, stat & (RDR | RRDY));
}
again here there will be no issues because those IRQs never fire
simultaneously and one will only after after we have handled the
previous, that's because the same FIFO is used anyway and we won't shift
data into FIFO until we tell the IP "hey, I'm done with the FIFO, you
can shift more data"
Signed-off-by: Felipe Balbi <balbi@ti.com>
Reviewed-by : Santosh Shilimkar <santosh.shilimkar@ti.com>
[Added the explaination from the discurssion to the commit logs]
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Diffstat (limited to 'drivers/i2c/busses/i2c-omap.c')
-rw-r--r-- | drivers/i2c/busses/i2c-omap.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 30ea63c24b5d..f24eae9f7f1e 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c | |||
@@ -731,7 +731,7 @@ static int errata_omap3_i462(struct omap_i2c_dev *dev, u16 *stat, int *err) | |||
731 | 731 | ||
732 | while (--timeout && !(*stat & OMAP_I2C_STAT_XUDF)) { | 732 | while (--timeout && !(*stat & OMAP_I2C_STAT_XUDF)) { |
733 | if (*stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) { | 733 | if (*stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) { |
734 | omap_i2c_ack_stat(dev, *stat & (OMAP_I2C_STAT_XRDY | | 734 | omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_XRDY | |
735 | OMAP_I2C_STAT_XDR)); | 735 | OMAP_I2C_STAT_XDR)); |
736 | return -ETIMEDOUT; | 736 | return -ETIMEDOUT; |
737 | } | 737 | } |
@@ -792,10 +792,11 @@ complete: | |||
792 | */ | 792 | */ |
793 | if (stat & (OMAP_I2C_STAT_ARDY | OMAP_I2C_STAT_NACK | | 793 | if (stat & (OMAP_I2C_STAT_ARDY | OMAP_I2C_STAT_NACK | |
794 | OMAP_I2C_STAT_AL)) { | 794 | OMAP_I2C_STAT_AL)) { |
795 | omap_i2c_ack_stat(dev, stat & | 795 | omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_RRDY | |
796 | (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR | | 796 | OMAP_I2C_STAT_RDR | |
797 | OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR | | 797 | OMAP_I2C_STAT_XRDY | |
798 | OMAP_I2C_STAT_ARDY)); | 798 | OMAP_I2C_STAT_XDR | |
799 | OMAP_I2C_STAT_ARDY)); | ||
799 | omap_i2c_complete_cmd(dev, err); | 800 | omap_i2c_complete_cmd(dev, err); |
800 | return IRQ_HANDLED; | 801 | return IRQ_HANDLED; |
801 | } | 802 | } |
@@ -842,8 +843,8 @@ complete: | |||
842 | } | 843 | } |
843 | } | 844 | } |
844 | } | 845 | } |
845 | omap_i2c_ack_stat(dev, | 846 | omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_RRDY | |
846 | stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR)); | 847 | OMAP_I2C_STAT_RDR)); |
847 | continue; | 848 | continue; |
848 | } | 849 | } |
849 | 850 | ||
@@ -890,8 +891,8 @@ complete: | |||
890 | 891 | ||
891 | omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w); | 892 | omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w); |
892 | } | 893 | } |
893 | omap_i2c_ack_stat(dev, | 894 | omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_XRDY | |
894 | stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR)); | 895 | OMAP_I2C_STAT_XDR)); |
895 | continue; | 896 | continue; |
896 | } | 897 | } |
897 | 898 | ||