[PATCH v2 2/5] spi: expand device name to include all CS lines for multi-CS devices

From: Jonathan Santos

Date: Sun Aug 02 2026 - 23:02:34 EST


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.

Signed-off-by: Jonathan Santos <Jonathan.Santos@xxxxxxxxxx>
---
Changes in v2:
* New patch.
---
drivers/spi/spi.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 55fb96fea243..61423aee1525 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -594,6 +594,8 @@ static void spi_dev_set_name(struct spi_device *spi)
{
struct device *dev = &spi->dev;
struct fwnode_handle *fwnode = dev_fwnode(dev);
+ char cs_str[32];
+ int cs_len;

if (is_acpi_device_node(fwnode)) {
dev_set_name(dev, "spi-%s", acpi_dev_name(to_acpi_device_node(fwnode)));
@@ -605,8 +607,12 @@ static void spi_dev_set_name(struct spi_device *spi)
return;
}

- 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 (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));
+
+ dev_set_name(&spi->dev, "%s.%s", dev_name(&spi->controller->dev), cs_str);
}

/*
--
2.34.1