aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi.c
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2012-12-06 08:58:31 -0500
committerGrant Likely <grant.likely@secretlab.ca>2012-12-06 08:58:31 -0500
commita34fc82e234255b657e62c3ce0c12e9439a59e80 (patch)
treea305e3c3c271bb5d6cd7980780f39938a02e32ce /drivers/spi/spi.c
parent161b96c383c442f4d7dabbb8500a5fbd551b344d (diff)
parent227c4ce6eac9fe6566d9718546a0e31b5b4633cd (diff)
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);
1204int spi_setup(struct spi_device *spi) 1204int spi_setup(struct spi_device *spi)
1205{ 1205{
1206 unsigned bad_bits; 1206 unsigned bad_bits;
1207 int status; 1207 int status = 0;
1208 1208
1209 /* help drivers fail *cleanly* when they need options 1209 /* help drivers fail *cleanly* when they need options
1210 * that aren't supported with their current master 1210 * that aren't supported with their current master
@@ -1219,7 +1219,8 @@ int spi_setup(struct spi_device *spi)
1219 if (!spi->bits_per_word) 1219 if (!spi->bits_per_word)
1220 spi->bits_per_word = 8; 1220 spi->bits_per_word = 8;
1221 1221
1222 status = spi->master->setup(spi); 1222 if (spi->master->setup)
1223 status = spi->master->setup(spi);
1223 1224
1224 dev_dbg(&spi->dev, "setup mode %d, %s%s%s%s" 1225 dev_dbg(&spi->dev, "setup mode %d, %s%s%s%s"
1225 "%u bits/w, %u Hz max --> %d\n", 1226 "%u bits/w, %u Hz max --> %d\n",
@@ -1238,6 +1239,7 @@ EXPORT_SYMBOL_GPL(spi_setup);
1238static int __spi_async(struct spi_device *spi, struct spi_message *message) 1239static int __spi_async(struct spi_device *spi, struct spi_message *message)
1239{ 1240{
1240 struct spi_master *master = spi->master; 1241 struct spi_master *master = spi->master;
1242 struct spi_transfer *xfer;
1241 1243
1242 /* Half-duplex links include original MicroWire, and ones with 1244 /* Half-duplex links include original MicroWire, and ones with
1243 * only one data pin like SPI_3WIRE (switches direction) or where 1245 * 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)
1246 */ 1248 */
1247 if ((master->flags & SPI_MASTER_HALF_DUPLEX) 1249 if ((master->flags & SPI_MASTER_HALF_DUPLEX)
1248 || (spi->mode & SPI_3WIRE)) { 1250 || (spi->mode & SPI_3WIRE)) {
1249 struct spi_transfer *xfer;
1250 unsigned flags = master->flags; 1251 unsigned flags = master->flags;
1251 1252
1252 list_for_each_entry(xfer, &message->transfers, transfer_list) { 1253 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)
1259 } 1260 }
1260 } 1261 }
1261 1262
1263 /**
1264 * Set transfer bits_per_word as spi device default if it is not
1265 * set for this transfer.
1266 */
1267 list_for_each_entry(xfer, &message->transfers, transfer_list) {
1268 if (!xfer->bits_per_word)
1269 xfer->bits_per_word = spi->bits_per_word;
1270 }
1271
1262 message->spi = spi; 1272 message->spi = spi;
1263 message->status = -EINPROGRESS; 1273 message->status = -EINPROGRESS;
1264 return master->transfer(spi, message); 1274 return master->transfer(spi, message);