Re: [PATCH v3 3/6] spi: expand device name to include all CS lines for multi-CS devices
Andy Shevchenko <[email protected]>
| Newsgroups | org.kernel.vger.linux-spi,org.kernel.vger.linux-kernel |
|---|---|
| Organization | Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo |
| Message-ID | <[email protected]> |
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); (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. -- With Best Regards, Andy Shevchenko