From: Jonas Gorski <jonas.gorski@gmail.com>
To: Mark Brown <broonie@kernel.org>,
Amit Kumar Mahapatra <amit.kumar-mahapatra@amd.com>
Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 0/6] spi: multi CS cleanup and controller CS limit removal
Date: Sat, 12 Oct 2024 11:53:34 +0200 [thread overview]
Message-ID: <20241012-spi_multi_cs_cleanup-v1-0-dc491113880d@gmail.com> (raw)
This series aims at cleaning up the current multi CS parts and removing
the CS limit per controller that was introduced with the multi CS
support.
To do this, store the assigned chip selects per device in
spi_device::num_chipselects, which allows us to use that instead of
SPI_CS_CNT_MAX for most loops, as well as remove the initialization to
and the check for SPI_INVALID_CS.
This should hopefully make it obvious that SPI_CS_CNT_MAX only limits
accesses to arrays indexed by the number of chip selects of a device, not
the controller, and we can remove the check for
spi_controller::num_chipselects being less than SPI_CS_CNT_MAX in device
registration (which was the wrong place to do that anyway).
After having done that, we can reduce SPI_CS_CNT_MAX again to 4 without
breaking devices on higher CS lines.
Finally, rename SPI_CS_CNT_MAX to SPI_DEVICE_CNT_MAX to make it more
clear that this limit only applies to devices, not controllers.
There are still more issues left, but these can be addressed in future
submissions:
* The code allows multi-cs devices for any controller, as long as the
device does not set parallel-memories.
* No current spi controller driver handles logical chip selects other
than the first one, and always use it, regardless what cs_index_mask
says.
* While most spi controllers should be able to handle devices that have
multiple cs that just get enables selectively, but not at the same
time, there is no way to tell that to the core (ties into the above).
* There is no parallel memories/multi cs flag for devices, so any
implementing driver needs to check the device tree node, making it
impossible to register these kind of devices via code.
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
Jonas Gorski (6):
spi: fix return code when spi device has too many chipselects
spi: keep track of number of chipselects in spi_device
spi: do not initialize device chipselects to SPI_INVALID_CS
spi: don't check spi_controller::num_chipselect when parsing a dt device
Revert "spi: Raise limit on number of chip selects"
spi: rename SPI_CS_CNT_MAX => SPI_DEVICE_CS_CNT_MAX
drivers/spi/spi-cadence-quadspi.c | 2 +-
drivers/spi/spi.c | 71 +++++++++++++++------------------------
include/linux/spi/spi.h | 17 ++++++----
3 files changed, 39 insertions(+), 51 deletions(-)
---
base-commit: c2a59c892f20379a3e48124a83491a12374cd7e0
change-id: 20241010-spi_multi_cs_cleanup-28b1a1516933
Best regards,
--
Jonas Gorski <jonas.gorski@gmail.com>
next reply other threads:[~2024-10-12 9:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-12 9:53 Jonas Gorski [this message]
2024-10-12 9:53 ` [PATCH 1/6] spi: fix return code when spi device has too many chipselects Jonas Gorski
2024-10-12 9:53 ` [PATCH 2/6] spi: keep track of number of chipselects in spi_device Jonas Gorski
2024-10-12 9:53 ` [PATCH 3/6] spi: do not initialize device chipselects to SPI_INVALID_CS Jonas Gorski
2024-10-12 10:27 ` Mark Brown
2024-10-12 9:53 ` [PATCH 4/6] spi: don't check spi_controller::num_chipselect when parsing a dt device Jonas Gorski
2024-10-12 9:53 ` [PATCH 5/6] Revert "spi: Raise limit on number of chip selects" Jonas Gorski
2024-10-12 10:28 ` Mark Brown
2024-10-12 9:53 ` [PATCH 6/6] spi: rename SPI_CS_CNT_MAX => SPI_DEVICE_CS_CNT_MAX Jonas Gorski
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=20241012-spi_multi_cs_cleanup-v1-0-dc491113880d@gmail.com \
--to=jonas.gorski@gmail.com \
--cc=amit.kumar-mahapatra@amd.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.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;
as well as URLs for NNTP newsgroup(s).