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

Mark Brown broonie at kernel.org
Mon Apr 27 17:17:35 PDT 2026


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).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-riscv/attachments/20260428/e2b9707f/attachment.sig>


More information about the linux-riscv mailing list