diff options
author | David Brownell <dbrownell@users.sourceforge.net> | 2009-06-17 19:26:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-18 16:03:42 -0400 |
commit | e7db06b5d5afcef15c4c3e61c3a7441ed7ad1407 (patch) | |
tree | c0d1e01d49fdb3f288da28ffc3b349810c4e1b61 /drivers/spi/spi_imx.c | |
parent | 7d0771970c51e736758525dd71fb82dd036b823a (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_imx.c')
-rw-r--r-- | drivers/spi/spi_imx.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c index 26d5ef06dbd9..c195e45f7f35 100644 --- a/drivers/spi/spi_imx.c +++ b/drivers/spi/spi_imx.c | |||
@@ -1171,9 +1171,6 @@ msg_rejected: | |||
1171 | return -EINVAL; | 1171 | return -EINVAL; |
1172 | } | 1172 | } |
1173 | 1173 | ||
1174 | /* the spi->mode bits understood by this driver: */ | ||
1175 | #define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH) | ||
1176 | |||
1177 | /* On first setup bad values must free chip_data memory since will cause | 1174 | /* On first setup bad values must free chip_data memory since will cause |
1178 | spi_new_device to fail. Bad value setup from protocol driver are simply not | 1175 | spi_new_device to fail. Bad value setup from protocol driver are simply not |
1179 | applied and notified to the calling driver. */ | 1176 | applied and notified to the calling driver. */ |
@@ -1186,12 +1183,6 @@ static int setup(struct spi_device *spi) | |||
1186 | u32 tmp; | 1183 | u32 tmp; |
1187 | int status = 0; | 1184 | int status = 0; |
1188 | 1185 | ||
1189 | if (spi->mode & ~MODEBITS) { | ||
1190 | dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n", | ||
1191 | spi->mode & ~MODEBITS); | ||
1192 | return -EINVAL; | ||
1193 | } | ||
1194 | |||
1195 | /* Get controller data */ | 1186 | /* Get controller data */ |
1196 | chip_info = spi->controller_data; | 1187 | chip_info = spi->controller_data; |
1197 | 1188 | ||
@@ -1478,6 +1469,9 @@ static int __init spi_imx_probe(struct platform_device *pdev) | |||
1478 | drv_data->master_info = platform_info; | 1469 | drv_data->master_info = platform_info; |
1479 | drv_data->pdev = pdev; | 1470 | drv_data->pdev = pdev; |
1480 | 1471 | ||
1472 | /* the spi->mode bits understood by this driver: */ | ||
1473 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; | ||
1474 | |||
1481 | master->bus_num = pdev->id; | 1475 | master->bus_num = pdev->id; |
1482 | master->num_chipselect = platform_info->num_chipselect; | 1476 | master->num_chipselect = platform_info->num_chipselect; |
1483 | master->dma_alignment = DMA_ALIGNMENT; | 1477 | master->dma_alignment = DMA_ALIGNMENT; |