spi_nxp_lpspi: Fix unit of buf_len in fill_tx_fifo

The buf_len parameter of lpspi_fill_tx_fifo is supposed to be bytes, so
we do not need to convert it. This could cause an issue if the end of
the buffer is less bytes than the word size.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
This commit is contained in:
Declan Snyder 2025-06-10 10:20:35 -05:00 committed by Anas Nashif
commit f6a9a1f3bc

View file

@ -112,17 +112,16 @@ static inline void lpspi_fill_tx_fifo(const struct device *dev, const uint8_t *b
struct lpspi_data *data = dev->data;
struct lpspi_driver_data *lpspi_data = (struct lpspi_driver_data *)data->driver_data;
uint8_t word_size = lpspi_data->word_size_bytes;
size_t buf_remaining_bytes = buf_len * word_size;
size_t offset = 0;
uint32_t next_word;
uint32_t next_word_bytes;
for (int word_count = 0; word_count < fill_len; word_count++) {
next_word_bytes = MIN(word_size, buf_remaining_bytes);
next_word_bytes = MIN(word_size, buf_len);
next_word = lpspi_next_tx_word(dev, buf, offset, next_word_bytes);
base->TDR = next_word;
offset += word_size;
buf_remaining_bytes -= word_size;
buf_len -= word_size;
}
LOG_DBG("Filled TX FIFO to %d words (%d bytes)", fill_len, offset);