diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-20 14:03:22 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-20 14:03:22 -0500 |
commit | 3aad3f03b2b6d2d977b985c49274cdb78a1593e5 (patch) | |
tree | e2955fe687fcd9c26f82d57a3c818e05406964ed /drivers/spi/spi.c | |
parent | 10b6339e93244156fac901560117e94bf9dca120 (diff) | |
parent | 095c3752e673c0ba039a2f67fd867297fde75ae7 (diff) |
Merge tag 'spi-for-linus' of git://git.secretlab.ca/git/linux
Pull SPI changes from Grant Likely:
"Changes to both core spi code and spi device drivers. The driver
changes are the usual set of bug fixes and platform enablement.
Core code changes include:
- More intelligent assignment of SPI bus numbers when using DT
- Common mechanism for using gpios as CS lines
- Pull checks for bits_per_word and transfer speed out of drivers and
into core code
- Ensure temporary DMA buffers are DMA safe"
* tag 'spi-for-linus' of git://git.secretlab.ca/git/linux: (50 commits)
spi: Document cs_gpios and cs_gpio in kernel-doc
spi/of: Fix initialization of cs_gpios array
spi/pxa2xx: add support for Lynxpoint SPI controllers
spi/pxa2xx: add support for Intel Low Power Subsystem SPI
spi/pxa2xx: add support for SPI_LOOP
spi/pxa2xx: add support for runtime PM
spi/pxa2xx: add support for DMA engine
spi/pxa2xx: break out the private DMA API usage into a separate file
spi/ath79: add shutdown handler
spi/mips-lantiq: set SPI_MASTER_HALF_DUPLEX flag
spi/mips-lantiq: make use of spi_finalize_current_message
spi/bcm63xx: work around inability to keep CS up
spi/davinci: use request_threaded_irq() to fix deadlock
spi/orion: Use module_platform_driver()
spi/bcm63xx: reject transfers unable to transfer
spi: Ensure memory used for spi_write_then_read() is DMA safe
spi/spi-mpc512x-psc: init mode bits supported by the driver
spi/mpc512x-psc: don't use obsolet cell-index property
spi: Remove erroneous __init, __exit and __exit_p() references in drivers
spi/s3c64xx: fix checkpatch warnings and error
...
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r-- | drivers/spi/spi.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 3a6083b386a1..4fffb1f39def 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -1080,7 +1080,8 @@ static int of_spi_register_master(struct spi_master *master) | |||
1080 | if (!master->cs_gpios) | 1080 | if (!master->cs_gpios) |
1081 | return -ENOMEM; | 1081 | return -ENOMEM; |
1082 | 1082 | ||
1083 | memset(cs, -EINVAL, master->num_chipselect); | 1083 | for (i = 0; i < master->num_chipselect; i++) |
1084 | cs[i] = -EINVAL; | ||
1084 | 1085 | ||
1085 | for (i = 0; i < nb; i++) | 1086 | for (i = 0; i < nb; i++) |
1086 | cs[i] = of_get_named_gpio(np, "cs-gpios", i); | 1087 | cs[i] = of_get_named_gpio(np, "cs-gpios", i); |
@@ -1135,6 +1136,9 @@ int spi_register_master(struct spi_master *master) | |||
1135 | if (master->num_chipselect == 0) | 1136 | if (master->num_chipselect == 0) |
1136 | return -EINVAL; | 1137 | return -EINVAL; |
1137 | 1138 | ||
1139 | if ((master->bus_num < 0) && master->dev.of_node) | ||
1140 | master->bus_num = of_alias_get_id(master->dev.of_node, "spi"); | ||
1141 | |||
1138 | /* convention: dynamically assigned bus IDs count down from the max */ | 1142 | /* convention: dynamically assigned bus IDs count down from the max */ |
1139 | if (master->bus_num < 0) { | 1143 | if (master->bus_num < 0) { |
1140 | /* FIXME switch to an IDR based scheme, something like | 1144 | /* FIXME switch to an IDR based scheme, something like |
@@ -1366,12 +1370,14 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message) | |||
1366 | } | 1370 | } |
1367 | 1371 | ||
1368 | /** | 1372 | /** |
1369 | * Set transfer bits_per_word as spi device default if it is not | 1373 | * Set transfer bits_per_word and max speed as spi device default if |
1370 | * set for this transfer. | 1374 | * it is not set for this transfer. |
1371 | */ | 1375 | */ |
1372 | list_for_each_entry(xfer, &message->transfers, transfer_list) { | 1376 | list_for_each_entry(xfer, &message->transfers, transfer_list) { |
1373 | if (!xfer->bits_per_word) | 1377 | if (!xfer->bits_per_word) |
1374 | xfer->bits_per_word = spi->bits_per_word; | 1378 | xfer->bits_per_word = spi->bits_per_word; |
1379 | if (!xfer->speed_hz) | ||
1380 | xfer->speed_hz = spi->max_speed_hz; | ||
1375 | } | 1381 | } |
1376 | 1382 | ||
1377 | message->spi = spi; | 1383 | message->spi = spi; |
@@ -1656,7 +1662,8 @@ int spi_write_then_read(struct spi_device *spi, | |||
1656 | * using the pre-allocated buffer or the transfer is too large. | 1662 | * using the pre-allocated buffer or the transfer is too large. |
1657 | */ | 1663 | */ |
1658 | if ((n_tx + n_rx) > SPI_BUFSIZ || !mutex_trylock(&lock)) { | 1664 | if ((n_tx + n_rx) > SPI_BUFSIZ || !mutex_trylock(&lock)) { |
1659 | local_buf = kmalloc(max((unsigned)SPI_BUFSIZ, n_tx + n_rx), GFP_KERNEL); | 1665 | local_buf = kmalloc(max((unsigned)SPI_BUFSIZ, n_tx + n_rx), |
1666 | GFP_KERNEL | GFP_DMA); | ||
1660 | if (!local_buf) | 1667 | if (!local_buf) |
1661 | return -ENOMEM; | 1668 | return -ENOMEM; |
1662 | } else { | 1669 | } else { |