summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi.c
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2012-12-06 13:58:31 +0000
committerGrant Likely <grant.likely@secretlab.ca>2012-12-06 13:58:31 +0000
commita34fc82e234255b657e62c3ce0c12e9439a59e80 (patch)
treea305e3c3c271bb5d6cd7980780f39938a02e32ce /drivers/spi/spi.c
parent161b96c383c442f4d7dabbb8500a5fbd551b344d (diff)
parent227c4ce6eac9fe6566d9718546a0e31b5b4633cd (diff)
downloadlinux-stable-a34fc82e234255b657e62c3ce0c12e9439a59e80.tar.gz
linux-stable-a34fc82e234255b657e62c3ce0c12e9439a59e80.tar.bz2
linux-stable-a34fc82e234255b657e62c3ce0c12e9439a59e80.zip
Merge branch 'spi-next' from git://git.kernel.org/pub/scm/linux/kernel/git/broonie/misc.git
Pull in the changes Mark has queued up for SPI
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r--drivers/spi/spi.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 1587a4a5ff41..f1217ae59f3d 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1204,7 +1204,7 @@ EXPORT_SYMBOL_GPL(spi_busnum_to_master);
int spi_setup(struct spi_device *spi)
{
unsigned bad_bits;
- int status;
+ int status = 0;
/* help drivers fail *cleanly* when they need options
* that aren't supported with their current master
@@ -1219,7 +1219,8 @@ int spi_setup(struct spi_device *spi)
if (!spi->bits_per_word)
spi->bits_per_word = 8;
- status = spi->master->setup(spi);
+ if (spi->master->setup)
+ status = spi->master->setup(spi);
dev_dbg(&spi->dev, "setup mode %d, %s%s%s%s"
"%u bits/w, %u Hz max --> %d\n",
@@ -1238,6 +1239,7 @@ EXPORT_SYMBOL_GPL(spi_setup);
static int __spi_async(struct spi_device *spi, struct spi_message *message)
{
struct spi_master *master = spi->master;
+ struct spi_transfer *xfer;
/* Half-duplex links include original MicroWire, and ones with
* only one data pin like SPI_3WIRE (switches direction) or where
@@ -1246,7 +1248,6 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message)
*/
if ((master->flags & SPI_MASTER_HALF_DUPLEX)
|| (spi->mode & SPI_3WIRE)) {
- struct spi_transfer *xfer;
unsigned flags = master->flags;
list_for_each_entry(xfer, &message->transfers, transfer_list) {
@@ -1259,6 +1260,15 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message)
}
}
+ /**
+ * Set transfer bits_per_word as spi device default if it is not
+ * set for this transfer.
+ */
+ list_for_each_entry(xfer, &message->transfers, transfer_list) {
+ if (!xfer->bits_per_word)
+ xfer->bits_per_word = spi->bits_per_word;
+ }
+
message->spi = spi;
message->status = -EINPROGRESS;
return master->transfer(spi, message);