aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi_txx9.c
diff options
context:
space:
mode:
authorDavid Brownell <dbrownell@users.sourceforge.net>2009-06-17 19:26:04 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-06-18 16:03:42 -0400
commite7db06b5d5afcef15c4c3e61c3a7441ed7ad1407 (patch)
treec0d1e01d49fdb3f288da28ffc3b349810c4e1b61 /drivers/spi/spi_txx9.c
parent7d0771970c51e736758525dd71fb82dd036b823a (diff)
spi: move more spi_setup() functionality into core
Move some common spi_setup() error checks into the SPI framework from the spi_master controller drivers: - Add a new "mode_bits" field to spi_master - Use that in spi_setup to validate the spi->mode value being requested. Setting this new field is now mandatory for any controller supporting more than vanilla SPI_MODE_0. - Update all spi_master drivers to: * Initialize that field * Remove current spi_setup() checks using that value. This is a net minor code shrink. 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/spi_txx9.c')
-rw-r--r--drivers/spi/spi_txx9.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/spi/spi_txx9.c b/drivers/spi/spi_txx9.c
index 8e36b2153d9a..96057de133ad 100644
--- a/drivers/spi/spi_txx9.c
+++ b/drivers/spi/spi_txx9.c
@@ -110,17 +110,11 @@ static void txx9spi_cs_func(struct spi_device *spi, struct txx9spi *c,
110 ndelay(cs_delay); /* CS Setup Time / CS Recovery Time */ 110 ndelay(cs_delay); /* CS Setup Time / CS Recovery Time */
111} 111}
112 112
113/* the spi->mode bits understood by this driver: */
114#define MODEBITS (SPI_CS_HIGH|SPI_CPOL|SPI_CPHA)
115
116static int txx9spi_setup(struct spi_device *spi) 113static int txx9spi_setup(struct spi_device *spi)
117{ 114{
118 struct txx9spi *c = spi_master_get_devdata(spi->master); 115 struct txx9spi *c = spi_master_get_devdata(spi->master);
119 u8 bits_per_word; 116 u8 bits_per_word;
120 117
121 if (spi->mode & ~MODEBITS)
122 return -EINVAL;
123
124 if (!spi->max_speed_hz 118 if (!spi->max_speed_hz
125 || spi->max_speed_hz > c->max_speed_hz 119 || spi->max_speed_hz > c->max_speed_hz
126 || spi->max_speed_hz < c->min_speed_hz) 120 || spi->max_speed_hz < c->min_speed_hz)
@@ -414,6 +408,9 @@ static int __init txx9spi_probe(struct platform_device *dev)
414 (unsigned long long)res->start, irq, 408 (unsigned long long)res->start, irq,
415 (c->baseclk + 500000) / 1000000); 409 (c->baseclk + 500000) / 1000000);
416 410
411 /* the spi->mode bits understood by this driver: */
412 master->mode_bits = SPI_CS_HIGH | SPI_CPOL | SPI_CPHA;
413
417 master->bus_num = dev->id; 414 master->bus_num = dev->id;
418 master->setup = txx9spi_setup; 415 master->setup = txx9spi_setup;
419 master->transfer = txx9spi_transfer; 416 master->transfer = txx9spi_transfer;