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 4/6] spi: don't check spi_controller::num_chipselect when parsing a dt device
Date: Sat, 12 Oct 2024 11:53:38 +0200 [thread overview]
Message-ID: <20241012-spi_multi_cs_cleanup-v1-4-dc491113880d@gmail.com> (raw)
In-Reply-To: <20241012-spi_multi_cs_cleanup-v1-0-dc491113880d@gmail.com>
Do not validate spi_controller::num_chipselect against SPI_CS_CNT_MAX
when parsing an spi device firmware node.
Firstly this is the wrong place, and this should be done while
registering/validating the controller. Secondly, there is no reason for
that check, as SPI_CS_CNT_MAX controls the amount of chipselects a
device may have, not a controller may have.
So drop that check as it needlessly limits controllers to SPI_CS_CNT_MAX
number of chipselects.
Likewise, drop the check for number of device chipselects larger than
controller's number of chipselects, as __spi_add_device() will already
catch that as either one of the chip selects will be out of range, or
there is a duplicate one.
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
drivers/spi/spi.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 495b391710d69a46beaa56c1a4332eb6677d2f45..ebf8bc9c2276a6f50ba6e9fded48c870c4bd5ff0 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -2430,11 +2430,6 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
return 0;
}
- if (ctlr->num_chipselect > SPI_CS_CNT_MAX) {
- dev_err(&ctlr->dev, "No. of CS is more than max. no. of supported CS\n");
- return -EINVAL;
- }
-
/* Device address */
rc = of_property_read_variable_u32_array(nc, "reg", &cs[0], 1,
SPI_CS_CNT_MAX);
@@ -2443,11 +2438,7 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
nc, rc);
return rc;
}
- if (rc > ctlr->num_chipselect) {
- dev_err(&ctlr->dev, "%pOF has number of CS > ctlr->num_chipselect (%d)\n",
- nc, rc);
- return -EINVAL;
- }
+
if ((of_property_read_bool(nc, "parallel-memories")) &&
(!(ctlr->flags & SPI_CONTROLLER_MULTI_CS))) {
dev_err(&ctlr->dev, "SPI controller doesn't support multi CS\n");
--
2.43.0
next prev parent 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 [PATCH 0/6] spi: multi CS cleanup and controller CS limit removal Jonas Gorski
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 ` Jonas Gorski [this message]
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-4-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).