Re: [PATCH v9 2/3] spi: spacemit: introduce SpacemiT K1 SPI controller driver

From: Mark Brown

Date: Mon Apr 27 2026 - 20:17:54 EST


On Mon, Apr 27, 2026 at 10:01:28PM -0400, Guodong Xu wrote:

> +static int k1_spi_transfer_one(struct spi_controller *host,
> + struct spi_device *spi,
> + struct spi_transfer *transfer)
> +{

> + /* Record how many words the len bytes represent */
> + count = transfer->len / drv_data->bytes;
> + drv_data->rx_resid = count;
> + drv_data->tx_resid = count;

This is setting up _resid with a number of words.

> +static void k1_spi_write_word(struct k1_spi_driver_data *drv_data)
> +{
> + struct spi_transfer *transfer = drv_data->transfer;
> + u32 bytes = drv_data->bytes;
> + u32 val;
> +
> + if (transfer->tx_buf) {
> + const void *buf;
> +
> + buf = transfer->tx_buf + (transfer->len - drv_data->tx_resid);

This is using _resid as a byte count. It'll be fine for 8 bits per word
(which is by far the most common thing).

Attachment: signature.asc
Description: PGP signature