mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Khalil <khalilst@gmail.com>
To: broonie@kernel.org, hdegoede@kernel.org, ilpo.jarvinen@linux.intel.com
Cc: rf@opensource.cirrus.com, linux-spi@vger.kernel.org,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org, Khalil <khalilst@gmail.com>
Subject: [PATCH 1/3] spi: Preserve preset cs_gpiod in __spi_add_device()
Date: Sat, 11 Apr 2026 20:04:12 +0200	[thread overview]
Message-ID: <20260411180414.481427-2-khalil@rentman.nl> (raw)
In-Reply-To: <20260411180414.481427-1-khalil@rentman.nl>

From: Khalil <khalilst@gmail.com>

__spi_add_device() unconditionally overwrites spi->cs_gpiod[] from
ctlr->cs_gpiods[cs], even if the caller has already set a GPIO
descriptor on the device. This prevents drivers like
serial-multi-instantiate from pre-configuring a GPIO chip select
acquired from ACPI before adding the device.

Skip the overwrite when the device already has a cs_gpiod set for
the given index, allowing callers to preset GPIO chip selects that
aren't described in the controller's cs-gpios property.

This is useful on platforms where the ACPI _DSD cs-gpios property
on the SPI controller is incomplete, but the peripheral's ACPI node
does contain the correct GpioIo resource for its chip select.

Suggested-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Signed-off-by: Khalil <khalilst@gmail.com>
---
 drivers/spi/spi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index XXXXXXX..XXXXXXX 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1148,7 +1148,8 @@ static int __spi_add_device(struct spi_device *spi)

 	if (ctlr->cs_gpiods) {
 		for (idx = 0; idx < SPI_CS_CNT_MAX; idx++) {
-			if (is_valid_cs(cs))
+			cs = spi_get_chipselect(spi, idx);
+			if (is_valid_cs(cs) && !spi_get_csgpiod(spi, idx))
 				spi_set_csgpiod(spi, idx, ctlr->cs_gpiods[cs]);
 		}
 	}
--
2.43.0

  reply	other threads:[~2026-04-11 18:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-15 13:55 [RFC PATCH 0/2] Fix second CS35L56 amplifier on Intel LPSS SPI with broken ACPI cs-gpios Khalil
2026-02-15 13:55 ` [RFC PATCH 1/2] platform/x86: serial-multi-instantiate: Add GPIO chip select support for SPI devices Khalil
2026-02-23 15:50   ` Richard Fitzgerald
2026-04-11 18:04   ` [PATCH v2 0/3] Fix CS35L56 amplifier on Intel LPSS SPI with broken ACPI cs-gpios Khalil
2026-04-11 18:04     ` Khalil [this message]
2026-04-11 18:04     ` [PATCH 2/3] platform/x86: serial-multi-instantiate: Fix SPI chip select on platforms with incomplete " Khalil
2026-04-11 18:04     ` [PATCH 3/3] spi: pxa2xx: Handle clock gating for GPIO chip select devices Khalil
2026-04-11 21:57     ` [PATCH v2 0/3] Fix CS35L56 amplifier on Intel LPSS SPI with broken ACPI cs-gpios Mark Brown
2026-04-13  8:48       ` Richard Fitzgerald
2026-04-13  9:02         ` Richard Fitzgerald
2026-04-12 16:31   ` Khalil
2026-04-12 16:31     ` [PATCH 1/3] spi: Preserve preset cs_gpiod in __spi_add_device() Khalil
2026-04-12 16:31     ` [PATCH 2/3] platform/x86: serial-multi-instantiate: Fix SPI chip select on platforms with incomplete ACPI cs-gpios Khalil
2026-04-12 16:31     ` [PATCH 3/3] spi: pxa2xx: Handle clock gating for GPIO chip select devices Khalil
2026-02-15 13:55 ` [RFC PATCH 2/2] spi: pxa2xx: Handle dynamic " Khalil

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=20260411180414.481427-2-khalil@rentman.nl \
    --to=khalilst@gmail.com \
    --cc=broonie@kernel.org \
    --cc=hdegoede@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rf@opensource.cirrus.com \
    /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®