linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@stericsson.com>
To: Grant Likely <grant.likely@secretlab.ca>,
	<spi-devel-general@lists.sourceforge.net>
Cc: Linus Walleij <linus.walleij@stericsson.com>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH] spi/pl022: compare bitwidth to enums
Date: Thu, 30 Sep 2010 11:57:51 +0200	[thread overview]
Message-ID: <1285840671-9567-1-git-send-email-linus.walleij@stericsson.com> (raw)

The enums from <linux/amba/pl022.h> are actually off-by-one
since bitwidth 4 is defined as 0x03, causing weirdness when
we were trying out some 9-bit peripheral. Fix this by
comparing to the enum values rather than hardcoded values
and also fixing the enum to something reasonable.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
---
 drivers/spi/amba-pl022.c   |    4 ++--
 include/linux/amba/pl022.h |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/amba-pl022.c b/drivers/spi/amba-pl022.c
index 90a7e5d..981f78d 100644
--- a/drivers/spi/amba-pl022.c
+++ b/drivers/spi/amba-pl022.c
@@ -1605,12 +1605,12 @@ static int pl022_setup(struct spi_device *spi)
 	chip->xfer_type = chip_info->com_mode;
 	chip->cs_control = chip_info->cs_control;
 
-	if (chip_info->data_size <= 8) {
+	if (chip_info->data_size <= SSP_DATA_BITS_8) {
 		dev_dbg(&spi->dev, "1 <= n <=8 bits per word\n");
 		chip->n_bytes = 1;
 		chip->read = READING_U8;
 		chip->write = WRITING_U8;
-	} else if (chip_info->data_size <= 16) {
+	} else if (chip_info->data_size <= SSP_DATA_BITS_16) {
 		dev_dbg(&spi->dev, "9 <= n <= 16 bits per word\n");
 		chip->n_bytes = 2;
 		chip->read = READING_U16;
diff --git a/include/linux/amba/pl022.h b/include/linux/amba/pl022.h
index abf26cc..3c83c62 100644
--- a/include/linux/amba/pl022.h
+++ b/include/linux/amba/pl022.h
@@ -90,7 +90,7 @@ enum ssp_tx_endian {
  * enum ssp_data_size - number of bits in one data element
  */
 enum ssp_data_size {
-	SSP_DATA_BITS_4 = 0x03, SSP_DATA_BITS_5, SSP_DATA_BITS_6,
+	SSP_DATA_BITS_4 = 0x04, SSP_DATA_BITS_5, SSP_DATA_BITS_6,
 	SSP_DATA_BITS_7, SSP_DATA_BITS_8, SSP_DATA_BITS_9,
 	SSP_DATA_BITS_10, SSP_DATA_BITS_11, SSP_DATA_BITS_12,
 	SSP_DATA_BITS_13, SSP_DATA_BITS_14, SSP_DATA_BITS_15,
-- 
1.6.3.3

             reply	other threads:[~2010-09-30  9:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-30  9:57 Linus Walleij [this message]
2010-09-30 11:34 ` [PATCH] spi/pl022: compare bitwidth to enums Linus Walleij
2010-09-30 14:37   ` Grant Likely
2010-09-30 16:21     ` Kevin Wells

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=1285840671-9567-1-git-send-email-linus.walleij@stericsson.com \
    --to=linus.walleij@stericsson.com \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=spi-devel-general@lists.sourceforge.net \
    /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).