Skip to content

Commit f042a1c

Browse files
c-maudererkartben
authored andcommitted
drivers: spi: mchp_mss: Avoid sending extra bytes
The driver did send some extra 0 bytes when the receive hasn't been finished yet. This patch makes sure to avoid that. Signed-off-by: Christian Mauderer <[email protected]>
1 parent a522062 commit f042a1c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/spi/spi_mchp_mss.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,15 @@ static inline void mss_spi_readwr_fifo(const struct device *dev)
211211
}
212212

213213
if (!(mss_spi_read(cfg, MSS_SPI_REG_STATUS) & MSS_SPI_STATUS_TXFIFO_FULL)) {
214-
if (spi_context_tx_buf_on(ctx)) {
215-
data8 = ctx->tx_buf[0];
216-
mss_spi_write(cfg, MSS_SPI_REG_TX_DATA, data8);
217-
} else {
218-
mss_spi_write(cfg, MSS_SPI_REG_TX_DATA, 0x0);
214+
if (spi_context_tx_on(ctx)) {
215+
if (spi_context_tx_buf_on(ctx)) {
216+
data8 = ctx->tx_buf[0];
217+
mss_spi_write(cfg, MSS_SPI_REG_TX_DATA, data8);
218+
} else {
219+
mss_spi_write(cfg, MSS_SPI_REG_TX_DATA, 0x0);
220+
}
221+
spi_context_update_tx(ctx, 1, 1);
219222
}
220-
spi_context_update_tx(ctx, 1, 1);
221223
}
222224
}
223225
}

0 commit comments

Comments
 (0)