]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
spi: remove check for bits_per_word on transfer from low level driver
authorLaxman Dewangan <ldewangan@nvidia.com>
Tue, 18 Dec 2012 08:55:43 +0000 (14:25 +0530)
committerGrant Likely <grant.likely@secretlab.ca>
Tue, 5 Feb 2013 12:26:59 +0000 (12:26 +0000)
The spi core make sure that each transfer structure have the proper
setting for bits_per_word before calling low level transfer APIs.

Hence it is no more require to check again in low level driver for
this field whether this is set correct or not. Removing such code
from low level driver.

The txx9 change also removes a test for bits_per_word set to 0, and
forcing it to 8 in that case. This can also be removed now since
spi_setup() ensures spi->bits_per_word is not zero.

if (!spi->bits_per_word)
spi->bits_per_word = 8;

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
drivers/spi/spi-altera.c
drivers/spi/spi-bfin-sport.c
drivers/spi/spi-bfin5xx.c
drivers/spi/spi-bitbang.c
drivers/spi/spi-clps711x.c
drivers/spi/spi-coldfire-qspi.c
drivers/spi/spi-ep93xx.c
drivers/spi/spi-s3c64xx.c
drivers/spi/spi-sirf.c
drivers/spi/spi-tegra20-slink.c
drivers/spi/spi-txx9.c

index 5e7314ac51e9748d70c00de49814f4912e0aec44..a537f8dffc095b56e4658e2a7c703ba3a809428c 100644 (file)
@@ -134,7 +134,7 @@ static int altera_spi_txrx(struct spi_device *spi, struct spi_transfer *t)
        hw->tx = t->tx_buf;
        hw->rx = t->rx_buf;
        hw->count = 0;
-       hw->bytes_per_word = (t->bits_per_word ? : spi->bits_per_word) / 8;
+       hw->bytes_per_word = t->bits_per_word / 8;
        hw->len = t->len / hw->bytes_per_word;
 
        if (hw->irq >= 0) {
index ac7ffca7ba470592c76885be9e1e84ef86727b74..39b0d1711b4e952fddcad68affd04ee103cdb47e 100644 (file)
@@ -416,8 +416,7 @@ bfin_sport_spi_pump_transfers(unsigned long data)
        drv_data->cs_change = transfer->cs_change;
 
        /* Bits per word setup */
-       bits_per_word = transfer->bits_per_word ? :
-               message->spi->bits_per_word ? : 8;
+       bits_per_word = transfer->bits_per_word;
        if (bits_per_word % 16 == 0)
                drv_data->ops = &bfin_sport_transfer_ops_u16;
        else
index 0429d833f75bf0125df06e5c51d44819769b405c..7d7c9918fffeed817a8f55ee99e37e7eee4016df 100644 (file)
@@ -642,8 +642,7 @@ static void bfin_spi_pump_transfers(unsigned long data)
        drv_data->cs_change = transfer->cs_change;
 
        /* Bits per word setup */
-       bits_per_word = transfer->bits_per_word ? :
-               message->spi->bits_per_word ? : 8;
+       bits_per_word = transfer->bits_per_word;
        if (bits_per_word % 16 == 0) {
                drv_data->n_bytes = bits_per_word/8;
                drv_data->len = (transfer->len) >> 1;
index 8b3d8efafd3cce19116d6f95c8cc46d1643d004e..61beaec7cbed46ad4fbfbcd5bd935bc2a03c3b02 100644 (file)
@@ -69,7 +69,7 @@ static unsigned bitbang_txrx_8(
        unsigned                ns,
        struct spi_transfer     *t
 ) {
-       unsigned                bits = t->bits_per_word ? : spi->bits_per_word;
+       unsigned                bits = t->bits_per_word;
        unsigned                count = t->len;
        const u8                *tx = t->tx_buf;
        u8                      *rx = t->rx_buf;
@@ -95,7 +95,7 @@ static unsigned bitbang_txrx_16(
        unsigned                ns,
        struct spi_transfer     *t
 ) {
-       unsigned                bits = t->bits_per_word ? : spi->bits_per_word;
+       unsigned                bits = t->bits_per_word;
        unsigned                count = t->len;
        const u16               *tx = t->tx_buf;
        u16                     *rx = t->rx_buf;
@@ -121,7 +121,7 @@ static unsigned bitbang_txrx_32(
        unsigned                ns,
        struct spi_transfer     *t
 ) {
-       unsigned                bits = t->bits_per_word ? : spi->bits_per_word;
+       unsigned                bits = t->bits_per_word;
        unsigned                count = t->len;
        const u32               *tx = t->tx_buf;
        u32                     *rx = t->rx_buf;
index 1366c4620d5d10b125f2ddb29b2a416d5d0d7033..a11cbf02691a88564ea8b8b33331453a7163b72a 100644 (file)
@@ -68,7 +68,7 @@ static int spi_clps711x_setup_xfer(struct spi_device *spi,
                                   struct spi_transfer *xfer)
 {
        u32 speed = xfer->speed_hz ? : spi->max_speed_hz;
-       u8 bpw = xfer->bits_per_word ? : spi->bits_per_word;
+       u8 bpw = xfer->bits_per_word;
        struct spi_clps711x_data *hw = spi_master_get_devdata(spi->master);
 
        if (bpw != 8) {
index 58466b810da4be9690f980191f0add1b27263fb9..7b5cc9e4e94d6a355962fca0afe05d3a3837339b 100644 (file)
@@ -329,8 +329,7 @@ static int mcfqspi_transfer_one_message(struct spi_master *master,
                mcfqspi_cs_select(mcfqspi, spi->chip_select, cs_high);
 
                mcfqspi_wr_qir(mcfqspi, MCFQSPI_QIR_SPIFE);
-               if ((t->bits_per_word ? t->bits_per_word :
-                                       spi->bits_per_word) == 8)
+               if (t->bits_per_word == 8)
                        mcfqspi_transfer_msg8(mcfqspi, t->len, t->tx_buf,
                                        t->rx_buf);
                else
index acb1e1935c5aedf2ebe7ae1e9ad82aa69bab1506..aecbff16ad60ca3e1f99a3b8692a6a0b3b5ca7ac 100644 (file)
@@ -446,7 +446,7 @@ static inline int bits_per_word(const struct ep93xx_spi *espi)
        struct spi_message *msg = espi->current_msg;
        struct spi_transfer *t = msg->state;
 
-       return t->bits_per_word ? t->bits_per_word : msg->spi->bits_per_word;
+       return t->bits_per_word;
 }
 
 static void ep93xx_do_write(struct ep93xx_spi *espi, struct spi_transfer *t)
index ad93231a8038dd9ae9adf3f5ea611ebd9c785758..d77b6560b67f87a1a6c5c92fda9cafd74811811c 100644 (file)
@@ -697,7 +697,7 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master,
                INIT_COMPLETION(sdd->xfer_completion);
 
                /* Only BPW and Speed may change across transfers */
-               bpw = xfer->bits_per_word ? : spi->bits_per_word;
+               bpw = xfer->bits_per_word;
                speed = xfer->speed_hz ? : spi->max_speed_hz;
 
                if (xfer->len % (bpw / 8)) {
index e0f43a512e8484353cacc4ca3a4e93eab8873a25..750666751efd1ce56a34ff1b6ca68f4d9a16472b 100644 (file)
@@ -382,8 +382,7 @@ spi_sirfsoc_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
 
        sspi = spi_master_get_devdata(spi->master);
 
-       bits_per_word = t && t->bits_per_word ? t->bits_per_word :
-               spi->bits_per_word;
+       bits_per_word = (t) ? t->bits_per_word : spi->bits_per_word;
        hz = t && t->speed_hz ? t->speed_hz : spi->max_speed_hz;
 
        /* Enable IO mode for RX, TX */
index 651167f2e0afbafbeab8ded7fac067923d41f910..7a95bddfb604ddfb46af25136236ad0e9b61c307 100644 (file)
@@ -284,8 +284,7 @@ static unsigned tegra_slink_calculate_curr_xfer_param(
        unsigned max_len;
        unsigned total_fifo_words;
 
-       bits_per_word = t->bits_per_word ? t->bits_per_word :
-                                               spi->bits_per_word;
+       bits_per_word = t->bits_per_word;
        tspi->bytes_per_word = (bits_per_word - 1) / 8 + 1;
 
        if (bits_per_word == 8 || bits_per_word == 16) {
@@ -378,8 +377,7 @@ static unsigned int tegra_slink_read_rx_fifo_to_client_rxbuf(
        } else {
                unsigned int bits_per_word;
 
-               bits_per_word = t->bits_per_word ? t->bits_per_word :
-                                               tspi->cur_spi->bits_per_word;
+               bits_per_word = t->bits_per_word;
                for (count = 0; count < rx_full_count; count++) {
                        x = tegra_slink_readl(tspi, SLINK_RX_FIFO);
                        for (i = 0; (i < tspi->bytes_per_word); i++)
@@ -444,8 +442,7 @@ static void tegra_slink_copy_spi_rxbuf_to_client_rxbuf(
                unsigned int x;
                unsigned int rx_mask, bits_per_word;
 
-               bits_per_word = t->bits_per_word ? t->bits_per_word :
-                                               tspi->cur_spi->bits_per_word;
+               bits_per_word = t->bits_per_word;
                rx_mask = (1 << bits_per_word) - 1;
                for (count = 0; count < tspi->curr_dma_words; count++) {
                        x = tspi->rx_dma_buf[count];
index d5a3cbb646cb45a3e3dbd97adb8f6b163f7220c2..550b5f48fd8f259964cee8970808660ef59d73fe 100644 (file)
@@ -189,9 +189,8 @@ static void txx9spi_work_one(struct txx9spi *c, struct spi_message *m)
                unsigned int len = t->len;
                unsigned int wsize;
                u32 speed_hz = t->speed_hz ? : spi->max_speed_hz;
-               u8 bits_per_word = t->bits_per_word ? : spi->bits_per_word;
+               u8 bits_per_word = t->bits_per_word;
 
-               bits_per_word = bits_per_word ? : 8;
                wsize = bits_per_word >> 3; /* in bytes */
 
                if (prev_speed_hz != speed_hz
@@ -316,9 +315,8 @@ static int txx9spi_transfer(struct spi_device *spi, struct spi_message *m)
        /* check each transfer's parameters */
        list_for_each_entry (t, &m->transfers, transfer_list) {
                u32 speed_hz = t->speed_hz ? : spi->max_speed_hz;
-               u8 bits_per_word = t->bits_per_word ? : spi->bits_per_word;
+               u8 bits_per_word = t->bits_per_word;
 
-               bits_per_word = bits_per_word ? : 8;
                if (!t->tx_buf && !t->rx_buf && t->len)
                        return -EINVAL;
                if (bits_per_word != 8 && bits_per_word != 16)