aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/pxa2xx_spi.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/pxa2xx_spi.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/pxa2xx_spi.c')
-rw-r--r--drivers/spi/pxa2xx_spi.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index c7365e0b22dd..9c311dc4771d 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -1185,9 +1185,6 @@ static int transfer(struct spi_device *spi, struct spi_message *msg)
1185 return 0; 1185 return 0;
1186} 1186}
1187 1187
1188/* the spi->mode bits understood by this driver: */
1189#define MODEBITS (SPI_CPOL | SPI_CPHA)
1190
1191static int setup_cs(struct spi_device *spi, struct chip_data *chip, 1188static int setup_cs(struct spi_device *spi, struct chip_data *chip,
1192 struct pxa2xx_spi_chip *chip_info) 1189 struct pxa2xx_spi_chip *chip_info)
1193{ 1190{
@@ -1252,12 +1249,6 @@ static int setup(struct spi_device *spi)
1252 return -EINVAL; 1249 return -EINVAL;
1253 } 1250 }
1254 1251
1255 if (spi->mode & ~MODEBITS) {
1256 dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n",
1257 spi->mode & ~MODEBITS);
1258 return -EINVAL;
1259 }
1260
1261 /* Only alloc on first setup */ 1252 /* Only alloc on first setup */
1262 chip = spi_get_ctldata(spi); 1253 chip = spi_get_ctldata(spi);
1263 if (!chip) { 1254 if (!chip) {
@@ -1493,6 +1484,9 @@ static int __init pxa2xx_spi_probe(struct platform_device *pdev)
1493 drv_data->pdev = pdev; 1484 drv_data->pdev = pdev;
1494 drv_data->ssp = ssp; 1485 drv_data->ssp = ssp;
1495 1486
1487 /* the spi->mode bits understood by this driver: */
1488 master->mode_bits = SPI_CPOL | SPI_CPHA;
1489
1496 master->bus_num = pdev->id; 1490 master->bus_num = pdev->id;
1497 master->num_chipselect = platform_info->num_chipselect; 1491 master->num_chipselect = platform_info->num_chipselect;
1498 master->dma_alignment = DMA_ALIGNMENT; 1492 master->dma_alignment = DMA_ALIGNMENT;