Re: [PATCH v2] spi: dw: support 4-16 bits per word

From: Trent Piepho
Date: Fri Aug 17 2018 - 12:32:37 EST


On Fri, 2018-08-17 at 09:01 +0200, Simon Goldschmidt wrote:
> The spi-dw driver currently only supports 8 or 16 bits per word.
>
> Since the hardware supports 4-16 bits per word, adapt the driver
> to also support this.
>
>

> @@ -307,15 +307,13 @@ static int dw_spi_transfer_one(struct spi_controller *master,
> +
> + if ((transfer->bits_per_word < 4) || (transfer->bits_per_word > 16))
> return -EINVAL;
> - }

You don't need this check as the spi core validates the transfer
against master->bits_per_word_mask.

> master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LOOP;
> - master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
> + master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16);
> master->bus_num = dws->bus_num;
>