spi.c (f477b7fb13df2b843997559ff34e87d054ba6538) | spi.c (db90a44177ac39fc22b2da5235b231fccdd4c673) |
---|---|
1/* 2 * SPI init/core code 3 * 4 * Copyright (C) 2005 David Brownell 5 * Copyright (C) 2008 Secret Lab Technologies Ltd. 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by --- 1459 unchanged lines hidden (view full) --- 1468 xfer->tx_nbits = SPI_NBITS_SINGLE; 1469 if (xfer->rx_buf && !xfer->rx_nbits) 1470 xfer->rx_nbits = SPI_NBITS_SINGLE; 1471 /* check transfer tx/rx_nbits: 1472 * 1. keep the value is not out of single, dual and quad 1473 * 2. keep tx/rx_nbits is contained by mode in spi_device 1474 * 3. if SPI_3WIRE, tx/rx_nbits should be in single 1475 */ | 1/* 2 * SPI init/core code 3 * 4 * Copyright (C) 2005 David Brownell 5 * Copyright (C) 2008 Secret Lab Technologies Ltd. 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by --- 1459 unchanged lines hidden (view full) --- 1468 xfer->tx_nbits = SPI_NBITS_SINGLE; 1469 if (xfer->rx_buf && !xfer->rx_nbits) 1470 xfer->rx_nbits = SPI_NBITS_SINGLE; 1471 /* check transfer tx/rx_nbits: 1472 * 1. keep the value is not out of single, dual and quad 1473 * 2. keep tx/rx_nbits is contained by mode in spi_device 1474 * 3. if SPI_3WIRE, tx/rx_nbits should be in single 1475 */ |
1476 if (xfer->tx_nbits != SPI_NBITS_SINGLE && 1477 xfer->tx_nbits != SPI_NBITS_DUAL && 1478 xfer->tx_nbits != SPI_NBITS_QUAD) 1479 return -EINVAL; 1480 if ((xfer->tx_nbits == SPI_NBITS_DUAL) && 1481 !(spi->mode & (SPI_TX_DUAL | SPI_TX_QUAD))) 1482 return -EINVAL; 1483 if ((xfer->tx_nbits == SPI_NBITS_QUAD) && 1484 !(spi->mode & SPI_TX_QUAD)) 1485 return -EINVAL; 1486 if ((spi->mode & SPI_3WIRE) && 1487 (xfer->tx_nbits != SPI_NBITS_SINGLE)) 1488 return -EINVAL; | 1476 if (xfer->tx_buf) { 1477 if (xfer->tx_nbits != SPI_NBITS_SINGLE && 1478 xfer->tx_nbits != SPI_NBITS_DUAL && 1479 xfer->tx_nbits != SPI_NBITS_QUAD) 1480 return -EINVAL; 1481 if ((xfer->tx_nbits == SPI_NBITS_DUAL) && 1482 !(spi->mode & (SPI_TX_DUAL | SPI_TX_QUAD))) 1483 return -EINVAL; 1484 if ((xfer->tx_nbits == SPI_NBITS_QUAD) && 1485 !(spi->mode & SPI_TX_QUAD)) 1486 return -EINVAL; 1487 if ((spi->mode & SPI_3WIRE) && 1488 (xfer->tx_nbits != SPI_NBITS_SINGLE)) 1489 return -EINVAL; 1490 } |
1489 /* check transfer rx_nbits */ | 1491 /* check transfer rx_nbits */ |
1490 if (xfer->rx_nbits != SPI_NBITS_SINGLE && 1491 xfer->rx_nbits != SPI_NBITS_DUAL && 1492 xfer->rx_nbits != SPI_NBITS_QUAD) 1493 return -EINVAL; 1494 if ((xfer->rx_nbits == SPI_NBITS_DUAL) && 1495 !(spi->mode & (SPI_RX_DUAL | SPI_RX_QUAD))) 1496 return -EINVAL; 1497 if ((xfer->rx_nbits == SPI_NBITS_QUAD) && 1498 !(spi->mode & SPI_RX_QUAD)) 1499 return -EINVAL; 1500 if ((spi->mode & SPI_3WIRE) && 1501 (xfer->rx_nbits != SPI_NBITS_SINGLE)) 1502 return -EINVAL; | 1492 if (xfer->rx_buf) { 1493 if (xfer->rx_nbits != SPI_NBITS_SINGLE && 1494 xfer->rx_nbits != SPI_NBITS_DUAL && 1495 xfer->rx_nbits != SPI_NBITS_QUAD) 1496 return -EINVAL; 1497 if ((xfer->rx_nbits == SPI_NBITS_DUAL) && 1498 !(spi->mode & (SPI_RX_DUAL | SPI_RX_QUAD))) 1499 return -EINVAL; 1500 if ((xfer->rx_nbits == SPI_NBITS_QUAD) && 1501 !(spi->mode & SPI_RX_QUAD)) 1502 return -EINVAL; 1503 if ((spi->mode & SPI_3WIRE) && 1504 (xfer->rx_nbits != SPI_NBITS_SINGLE)) 1505 return -EINVAL; 1506 } |
1503 } 1504 1505 message->spi = spi; 1506 message->status = -EINPROGRESS; 1507 return master->transfer(spi, message); 1508} 1509 1510/** --- 352 unchanged lines hidden --- | 1507 } 1508 1509 message->spi = spi; 1510 message->status = -EINPROGRESS; 1511 return master->transfer(spi, message); 1512} 1513 1514/** --- 352 unchanged lines hidden --- |