From: Andi Shyti <andi.shyti-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
To: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Kukjin Kim <kgene-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Krzysztof Kozlowski
<k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Andi Shyti <andi.shyti-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
Andi Shyti <andi-ahk0KpmfxKRAfugRpC6u6w@public.gmane.org>
Subject: [PATCH 1/5] spi: do not fail if the CS line is not connected
Date: Fri, 17 Jun 2016 16:57:21 +0900 [thread overview]
Message-ID: <1466150245-2648-2-git-send-email-andi.shyti@samsung.com> (raw)
In-Reply-To: <1466150245-2648-1-git-send-email-andi.shyti-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
Some SPI connected devices do not have any CS line connected as
some devices are alway enabled. Indeed, until now, a common
workaround was to assign to num_chipselect a -1 value or 255
(num_chipselect is unsigned).
In this case do not fail and defer to the SPI device drivers the
responsibility to check whether the num-cs is '0'.
Signed-off-by: Andi Shyti <andi.shyti-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
---
drivers/spi/spi.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 77e6e45..f22dc27 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -504,8 +504,13 @@ int spi_add_device(struct spi_device *spi)
struct device *dev = master->dev.parent;
int status;
- /* Chipselects are numbered 0..max; validate. */
- if (spi->chip_select >= master->num_chipselect) {
+ /*
+ * Chipselects are numbered 0..max; validate.
+ * If there is no chip select (i.e. num_chipselect == 0),
+ * the comparison doesn't make sense.
+ */
+ if (master->num_chipselect &&
+ spi->chip_select >= master->num_chipselect) {
dev_err(dev, "cs%d >= max %d\n",
spi->chip_select,
master->num_chipselect);
@@ -1851,12 +1856,6 @@ int spi_register_master(struct spi_master *master)
if (status)
return status;
- /* even if it's just one always-selected device, there must
- * be at least one chipselect
- */
- if (master->num_chipselect == 0)
- return -EINVAL;
-
if ((master->bus_num < 0) && master->dev.of_node)
master->bus_num = of_alias_get_id(master->dev.of_node, "spi");
--
2.8.1
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-06-17 7:57 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-17 7:57 [PATCH 0/5] SPI CS line logical change and s3c64xx code rework Andi Shyti
[not found] ` <1466150245-2648-1-git-send-email-andi.shyti-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2016-06-17 7:57 ` Andi Shyti [this message]
[not found] ` <1466150245-2648-2-git-send-email-andi.shyti-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2016-06-17 10:47 ` [PATCH 1/5] spi: do not fail if the CS line is not connected Mark Brown
2016-06-17 11:36 ` Andi Shyti
[not found] ` <20160617113622.GA10760-A05emIGRluN/OPZsa/fw/Q@public.gmane.org>
2016-06-17 12:28 ` Mark Brown
[not found] ` <20160617122803.GN26099-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-06-19 6:09 ` Andi Shyti
[not found] ` <20160619060902.GB424-A05emIGRluN/OPZsa/fw/Q@public.gmane.org>
2016-06-26 12:48 ` Mark Brown
[not found] ` <20160626124843.GP28202-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-06-27 10:57 ` Andi Shyti
2016-06-27 13:06 ` Mark Brown
[not found] ` <20160627130657.GV28202-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-06-27 14:08 ` Andi Shyti
2016-06-17 7:57 ` [PATCH 2/5] spi: s3c64xx: group the CS signalling writes in a single function Andi Shyti
2016-06-30 12:15 ` Applied "spi: s3c64xx: group the CS signalling writes in a single function" to the spi tree Mark Brown
2016-06-17 7:57 ` [PATCH 3/5] spi: s3c64xx: consider the case where the CS line is not connected Andi Shyti
2016-06-17 7:57 ` [PATCH 4/5] spi: s3c64xx: do not configure the device twice Andi Shyti
2016-06-30 12:15 ` Applied "spi: s3c64xx: do not configure the device twice" to the spi tree Mark Brown
2016-06-17 7:57 ` [PATCH 5/5] spi: s3c63xx: simplify if statement in prepare_transfer function Andi Shyti
2016-06-30 12:15 ` Applied "spi: s3c64xx: simplify if statement in prepare_transfer function" to the spi tree Mark Brown
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=1466150245-2648-2-git-send-email-andi.shyti@samsung.com \
--to=andi.shyti-sze3o3uu22jbdgjk7y7tuq@public.gmane.org \
--cc=andi-ahk0KpmfxKRAfugRpC6u6w@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=kgene-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.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).