diff options
author | David Brownell <david-b@pacbell.net> | 2007-07-17 07:04:02 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-17 13:23:04 -0400 |
commit | dccd573bb02aa011a4a7146c02c409ac0bd722a0 (patch) | |
tree | 743eeca4fbbea8272ca4f341b806d776e404d704 /drivers/spi/omap_uwire.c | |
parent | ff294cba8a62fa8334b88692da6d48683900f015 (diff) |
SPI controller drivers: check for unsupported modes
Minor SPI controller driver updates: make the setup() methods reject
spi->mode bits they don't support, by masking aginst the inverse of bits
they *do* support. This insures against misbehavior later when new mode
bits get added.
Most controllers can't support SPI_LSB_FIRST; more handle SPI_CS_HIGH.
Support for all four SPI clock/transfer modes is routine.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/spi/omap_uwire.c')
-rw-r--r-- | drivers/spi/omap_uwire.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/spi/omap_uwire.c b/drivers/spi/omap_uwire.c index 95183e1df525..d275c615a73e 100644 --- a/drivers/spi/omap_uwire.c +++ b/drivers/spi/omap_uwire.c | |||
@@ -445,10 +445,19 @@ done: | |||
445 | return status; | 445 | return status; |
446 | } | 446 | } |
447 | 447 | ||
448 | /* the spi->mode bits understood by this driver: */ | ||
449 | #define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH) | ||
450 | |||
448 | static int uwire_setup(struct spi_device *spi) | 451 | static int uwire_setup(struct spi_device *spi) |
449 | { | 452 | { |
450 | struct uwire_state *ust = spi->controller_state; | 453 | struct uwire_state *ust = spi->controller_state; |
451 | 454 | ||
455 | if (spi->mode & ~MODEBITS) { | ||
456 | dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n", | ||
457 | spi->mode & ~MODEBITS); | ||
458 | return -EINVAL; | ||
459 | } | ||
460 | |||
452 | if (ust == NULL) { | 461 | if (ust == NULL) { |
453 | ust = kzalloc(sizeof(*ust), GFP_KERNEL); | 462 | ust = kzalloc(sizeof(*ust), GFP_KERNEL); |
454 | if (ust == NULL) | 463 | if (ust == NULL) |