Skip to content

Commit ff0cf7b

Browse files
larsclausenwsakernel
authored andcommitted
i2c: cadence: Remove unnecessary register reads
In the `cdns_i2c_mrecv()` function the CTRL register of the Cadence I2C controller is written and read back multiple times. The register value does not change on its own. So it is possible to remember the just written value instead of reading it back from the hardware. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Michal Simek <michal.simek@amd.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
1 parent e9d373c commit ff0cf7b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/i2c/busses/i2c-cadence.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id)
613613

614614
/* Determine hold_clear based on number of bytes to receive and hold flag */
615615
if (!id->bus_hold_flag && id->recv_count <= CDNS_I2C_FIFO_DEPTH) {
616-
if (cdns_i2c_readreg(CDNS_I2C_CR_OFFSET) & CDNS_I2C_CR_HOLD) {
616+
if (ctrl_reg & CDNS_I2C_CR_HOLD) {
617617
hold_clear = true;
618618
if (id->quirks & CDNS_I2C_BROKEN_HOLD_BIT)
619619
irq_save = true;
@@ -624,7 +624,7 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id)
624624
addr &= CDNS_I2C_ADDR_MASK;
625625

626626
if (hold_clear) {
627-
ctrl_reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET) & ~CDNS_I2C_CR_HOLD;
627+
ctrl_reg &= ~CDNS_I2C_CR_HOLD;
628628
/*
629629
* In case of Xilinx Zynq SOC, clear the HOLD bit before transfer size
630630
* register reaches '0'. This is an IP bug which causes transfer size

0 commit comments

Comments
 (0)