Skip to content
Snippets Groups Projects
Commit 981b14f0 authored by Stephen Warren's avatar Stephen Warren Committed by Heiko Schocher
Browse files

i2c: tegra: write clean data to TX FIFO


The Tegra I2C controller's TX FIFO contains 32-bit words. If the final
FIFO entry of a transaction contains fewer than 4 bytes, the driver
currently fills the unused FIFO bytes with uninitialized data. This can
be confusing when reading back the FIFO content for debugging purposes.

Solve this by explicitly initializing the variable containing FIFO data
before filling it (partially) with data. With this change,
send_recv_packets()'s loop's if (is_write) code mirrors the else (i.e.
read) branch.

Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
Reviewed-by: default avatarYen Lin <yelin@nvidia.com>
parent 68049a08
No related branches found
No related tags found
No related merge requests found
...@@ -224,14 +224,16 @@ static int send_recv_packets(struct i2c_bus *i2c_bus, ...@@ -224,14 +224,16 @@ static int send_recv_packets(struct i2c_bus *i2c_bus,
if (is_write) { if (is_write) {
/* deal with word alignment */ /* deal with word alignment */
if ((unsigned)dptr & 3) { if ((words == 1) && last_bytes) {
local = 0;
memcpy(&local, dptr, last_bytes);
} else if ((unsigned)dptr & 3) {
memcpy(&local, dptr, sizeof(u32)); memcpy(&local, dptr, sizeof(u32));
writel(local, &control->tx_fifo);
debug("pkt data sent (0x%x)\n", local);
} else { } else {
writel(*wptr, &control->tx_fifo); local = *wptr;
debug("pkt data sent (0x%x)\n", *wptr);
} }
writel(local, &control->tx_fifo);
debug("pkt data sent (0x%x)\n", local);
if (!wait_for_tx_fifo_empty(control)) { if (!wait_for_tx_fifo_empty(control)) {
error = -1; error = -1;
goto exit; goto exit;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment