From: Scott Jiang <scott.jiang.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Grant Likely
<grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>,
Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
Scott Jiang
<scott.jiang.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b@public.gmane.org
Subject: [PATCH] spi: add bits_per_word_mask check in spi_setup
Date: Wed, 26 Jun 2013 18:54:46 -0400 [thread overview]
Message-ID: <1372287286-12682-1-git-send-email-scott.jiang.linux@gmail.com> (raw)
The spi_setup should fail if underlying controller or its driver
does not support requested bits_per_word. So if the master driver
set mask and let core do bits_per_word check then we should also
test this mask in spi_setup.
Signed-off-by: Scott Jiang <scott.jiang.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
drivers/spi/spi.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 45cb6a9..dc8fde0 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1326,6 +1326,15 @@ int spi_setup(struct spi_device *spi)
if (!spi->bits_per_word)
spi->bits_per_word = 8;
+ if (spi->master->bits_per_word_mask) {
+ /* Only 32 bits fit in the mask */
+ if (spi->bits_per_word > 32)
+ return -EINVAL;
+ if (!(spi->master->bits_per_word_mask &
+ BIT(spi->bits_per_word - 1)))
+ return -EINVAL;
+ }
+
if (spi->master->setup)
status = spi->master->setup(spi);
--
1.7.0.4
next reply other threads:[~2013-06-26 22:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-26 22:54 Scott Jiang [this message]
[not found] ` <1372287286-12682-1-git-send-email-scott.jiang.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-06-27 11:35 ` [PATCH] spi: add bits_per_word_mask check in spi_setup Mark Brown
[not found] ` <20130627113522.GZ27646-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-06-28 2:51 ` Scott Jiang
[not found] ` <CAHG8p1DeSojQ-kn=GZTFpaepUTDCme7NA+=Vani3zK1QePDCzA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-06-28 10:40 ` 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=1372287286-12682-1-git-send-email-scott.jiang.linux@gmail.com \
--to=scott.jiang.linux-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
--cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.