mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Jonathan Santos <Jonathan.Santos@analog.com>
Cc: <linux-spi@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <linux-iio@vger.kernel.org>,
	<linux@analog.com>, <broonie@kernel.org>, <robh@kernel.org>,
	<krzk+dt@kernel.org>, <conor+dt@kernel.org>,
	<Michael.Hennerich@analog.com>, <nuno.sa@analog.com>,
	<dlechner@baylibre.com>, <andriy.shevchenko@intel.com>
Subject: Re: [PATCH v4 5/9] spi: expand device name to include enabled CS lines for multi-CS devices
Date: Mon, 26 Oct 2026 02:07:53 +0000	[thread overview]
Message-ID: <20261026020753.42426bc0@jic23-hlaptop> (raw)
In-Reply-To: <0bd7dfae5aa64066b8a3555cdcbd1b84de688f33.1792435248.git.Jonathan.Santos@analog.com>

On Tue, 20 Oct 2026 22:57:44 -0300
Jonathan Santos <Jonathan.Santos@analog.com> 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>-<csN> for multi-cs
> devices so that the range of active chip-selects is reflected in the
> device name. Since we are not expecting sparse values for logical CS
> values, adopt the range format.
change that to not supporting rather than expecting.

I'm not sure that's a good idea - and Andy's request to check for
existing ones is a good start.  However, if you do it, consistency
through the patch set is important.

> 
> Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com>
> ---
> Changes in v4:
> * Opted for the range format, since we decide to limit logical CS values
>   to a contiguous sequence.
> 
> Changes in v3:
> * replaced `int idx = 1` by `unsigned int idx = 1` in the for loop.
> 
> Changes in v2:
> * New patch.
> ---
>  drivers/spi/spi.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 2b2eeaa4c15d..53d6ab4ce8a3 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -782,6 +782,7 @@ static void spi_dev_set_name(struct spi_device *spi)
>  {
>  	struct device *dev = &spi->dev;
>  	struct fwnode_handle *fwnode = dev_fwnode(dev);
> +	u8 num_enabled_cs = hweight32(spi->cs_index_mask);
>  
>  	if (is_acpi_device_node(fwnode)) {
>  		dev_set_name(dev, "spi-%s", acpi_dev_name(to_acpi_device_node(fwnode)));
> @@ -793,6 +794,19 @@ static void spi_dev_set_name(struct spi_device *spi)
>  		return;
>  	}
>  
> +	/*
> +	 * In multi-CS arrangements, use num_enabled_cs (derived from
> +	 * cs_index_mask) to determine which CS lines the device is actively
> +	 * using. num_chipselect only reflects how many CS lines are assigned
> +	 * to the device, not how many are actually enabled.
> +	 */
> +	if (num_enabled_cs > 1) {
> +		dev_set_name(&spi->dev, "%s.%u-%u", dev_name(&spi->controller->dev),
> +			     spi_get_chipselect(spi, 0),
> +			     spi_get_chipselect(spi, num_enabled_cs - 1));
> +		return;
> +	}
> +
>  	dev_set_name(&spi->dev, "%s.%u", dev_name(&spi->controller->dev),
>  		     spi_get_chipselect(spi, 0));
>  }


  reply	other threads:[~2026-10-26  2:08 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21  1:56 [PATCH v4 0/9] spi: add multi-CS and multi-chip aggregation support Jonathan Santos
2026-10-21  1:56 ` [PATCH v4 1/9] spi: dt-bindings: Add spi-cs-composite property Jonathan Santos
2026-10-26  2:00   ` Jonathan Cameron
2026-10-21  1:56 ` [PATCH v4 2/9] dt-bindings: iio: adc: ad7768-1: Document multidevice support Jonathan Santos
2026-10-26  2:05   ` Jonathan Cameron
2026-10-21  1:57 ` [PATCH v4 3/9] spi: support simultaneous assertion of multiple CS Jonathan Santos
2026-10-21  1:57 ` [PATCH v4 4/9] spi: restrict CS logical values to a contiguous sequence Jonathan Santos
2026-10-21 15:06   ` Andy Shevchenko
2026-10-21  1:57 ` [PATCH v4 5/9] spi: expand device name to include enabled CS lines for multi-CS devices Jonathan Santos
2026-10-26  2:07   ` Jonathan Cameron [this message]
2026-10-21  1:58 ` [PATCH v4 6/9] spi: introduce SPI ancillary device with lanes Jonathan Santos
2026-10-26  2:17   ` Jonathan Cameron
2026-10-21  1:58 ` [PATCH v4 7/9] spi: add KUnit tests for the multi-CS framework Jonathan Santos
2026-10-21  1:58 ` [PATCH v4 8/9] spi: spi-engine-ex: Add support for multi-CS devices Jonathan Santos
2026-10-21 15:13   ` Andy Shevchenko
2026-10-21  1:58 ` [PATCH v4 9/9] iio: adc: ad7768-1: add support for multiple chip aggregation Jonathan Santos
2026-10-26  2:26   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261026020753.42426bc0@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=Jonathan.Santos@analog.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=linux@analog.com \
    --cc=nuno.sa@analog.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®