[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-spi
Subject: [PATCH 13/23] spi: fsl-espi: merge fsl_espi_cmd_trans and fsl_espi_rw_trans
From: Heiner Kallweit <hkallweit1 () gmail ! com>
Date: 2016-08-25 4:48:40
Message-ID: 597abb06-ec63-ace4-d400-a8040fea3c2d () gmail ! com
[Download RAW message or body]
fsl_espi_cmd_trans and fsl_espi_rw_trans share most of the code so
we can merge them.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/spi/spi-fsl-espi.c | 32 ++++++--------------------------
1 file changed, 6 insertions(+), 26 deletions(-)
diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index 4c36a5d..6d06e14 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -301,22 +301,8 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans)
return ret;
}
-static int fsl_espi_cmd_trans(struct spi_message *m,
- struct spi_transfer *trans, u8 *rx_buff)
-{
- struct mpc8xxx_spi *mspi = spi_master_get_devdata(m->spi->master);
- int ret;
-
- fsl_espi_copy_to_buf(m, mspi);
-
- trans->tx_buf = trans->rx_buf = mspi->local_buf;
- ret = fsl_espi_do_trans(m, trans);
-
- return ret;
-}
-
-static int fsl_espi_rw_trans(struct spi_message *m,
- struct spi_transfer *trans, u8 *rx_buff)
+static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans,
+ u8 *rx_buff)
{
struct mpc8xxx_spi *mspi = spi_master_get_devdata(m->spi->master);
unsigned int tx_only;
@@ -327,12 +313,9 @@ static int fsl_espi_rw_trans(struct spi_message *m,
trans->tx_buf = trans->rx_buf = mspi->local_buf;
ret = fsl_espi_do_trans(m, trans);
- if (!ret) {
- /* If there is at least one RX byte then copy it to rx_buff */
- if (trans->len > tx_only)
- memcpy(rx_buff, trans->rx_buf + tx_only,
- trans->len - tx_only);
- }
+ /* If there is at least one RX byte then copy it to rx_buff */
+ if (!ret && rx_buff && trans->len > tx_only)
+ memcpy(rx_buff, trans->rx_buf + tx_only, trans->len - tx_only);
return ret;
}
@@ -354,10 +337,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master,
trans.len = xfer_len;
- if (!rx_buf)
- ret = fsl_espi_cmd_trans(m, &trans, NULL);
- else
- ret = fsl_espi_rw_trans(m, &trans, rx_buf);
+ ret = fsl_espi_trans(m, &trans, rx_buf);
m->actual_length = ret ? 0 : trans.len;
--
2.9.2
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic