Re: [PATCH v3 3/6] spi: expand device name to include all CS lines for multi-CS devices

Nuno Sá <[email protected]>
Newsgroups org.kernel.vger.linux-spi,org.kernel.vger.linux-kernel
Message-ID <178706966052.3163.11425556311922813200.b4-reply@b4>
On 2026-08-18 09:45:05+03:00, Andy Shevchenko wrote:
> On Mon, Aug 17, 2026 at 08:32:57PM -0300, Jonathan Santos wrote:
> 
> > The device name for SPI devices was formatted as <controller>.<cs0>,
> > always using only the first chip-select index, ignoring the remaining CS
> > lines.
> > 
> > Change the naming format to <controller>.<cs0>+<cs1>+... so that all
> > active chip-selects are reflected in the device name. Single-CS devices
> > are not affected since the loop only appends extra indices when
> > num_chipselect is greater than one.
> 
> ...
> 
> > -	dev_set_name(&spi->dev, "%s.%u", dev_name(&spi->controller->dev),
> > -		     spi_get_chipselect(spi, 0));
> > +	cs_len = scnprintf(cs_str, sizeof(cs_str), "%u", spi_get_chipselect(spi, 0));
> > +	for (unsigned int idx = 1; idx < spi->num_chipselect; idx++)
> > +		cs_len += scnprintf(cs_str + cs_len, sizeof(cs_str) - cs_len,
> > +				    "+%u", spi_get_chipselect(spi, idx));
> 
> So, if this won't support sparse CS list, I would just go with a standard range:
> 
> 	dev_set_name(&spi->dev, "%s.%u-%u", dev_name(&spi->controller->dev),
> 		     spi_get_chipselect(spi, 0), spi_get_chipselect(spi, 0) + spi->num_chipselect - 1);
> 

I don't think there's anything forcing cs to be contiguous. So cs4-0 does
not mean we have 0,1,2,3 and 4 which I think the above implies.

Moreover, i also don't think is guaranteed that `spi_get_chipselect(spi,
0) + spi->num_chipselect - 1)` yields a valid cs. IOW, in theory

spi_get_chipselect(spi, spi->num_chipselect - 1) might be different
than spi_get_chipselect(spi, 0) + spi->num_chipselect - 1

- Nuno Sá

> (yes, need a variation for num_chipselect == 1, but I leave the rest for you)
> 
> Note, I do not see that we are expecting to see the sparse CS list here. It
> would make too complex logic to follow. So, range approach is KISS in my opinion.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.