Re: [PATCH v4 4/9] spi: restrict CS logical values to a contiguous sequence

From: Nuno Sá

Date: Fri Oct 30 2026 - 07:28:55 EST


On Tue, 20 Oct 2026 22:57:28 -0300, Jonathan Santos <Jonathan.Santos@xxxxxxxxxx> wrote:
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 7a0406ec200e..2b2eeaa4c15d 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -902,6 +902,16 @@ static int __spi_add_device(struct spi_device *spi, struct spi_device *parent)
> for (idx = spi->num_chipselect; idx < SPI_DEVICE_CS_CNT_MAX; idx++)
> spi_set_chipselect(spi, idx, SPI_INVALID_CS);
>
> + /* Restrict CS logical values to a contiguous sequence */
> + for (idx = 1; idx < spi->num_chipselect; idx++) {
> + if (spi_get_chipselect(spi, idx) != spi_get_chipselect(spi, idx - 1) + 1) {
> + dev_err(dev, "cs%d is not consecutive with cs%d\n",
> + spi_get_chipselect(spi, idx),
> + spi_get_chipselect(spi, idx - 1));
> + return -EINVAL;
> + }
> + }
> +

Can't this break existing users? Not sure of any strong reason to
enforce it as it was nerver enforced AFAIK.

- Nuno Sá

--
Nuno Sá <nuno.sa@xxxxxxxxxx>