net: ieee802154: adf7242: Avoid redundant RC_READY polling
authorMichael Hennerich <michael.hennerich@analog.com>
Tue, 28 Nov 2017 12:53:14 +0000 (13:53 +0100)
committerStefan Schmidt <stefan@osg.samsung.com>
Wed, 29 Nov 2017 15:49:41 +0000 (16:49 +0100)
READ/WRITE register and packet buffer can be done anytime as long
as SPI_READY. Only CMD transactions require RC_READY && SPI_READY.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
drivers/net/ieee802154/adf7242.c

index ce1a6d2..548bec1 100644 (file)
@@ -344,12 +344,18 @@ static int adf7242_wait_status(struct adf7242_local *lp, unsigned int status,
        return ret;
 }
 
-static int adf7242_wait_ready(struct adf7242_local *lp, int line)
+static int adf7242_wait_rc_ready(struct adf7242_local *lp, int line)
 {
        return adf7242_wait_status(lp, STAT_RC_READY | STAT_SPI_READY,
                                   STAT_RC_READY | STAT_SPI_READY, line);
 }
 
+static int adf7242_wait_spi_ready(struct adf7242_local *lp, int line)
+{
+       return adf7242_wait_status(lp, STAT_SPI_READY,
+                                  STAT_SPI_READY, line);
+}
+
 static int adf7242_write_fbuf(struct adf7242_local *lp, u8 *data, u8 len)
 {
        u8 *buf = lp->buf;
@@ -369,7 +375,7 @@ static int adf7242_write_fbuf(struct adf7242_local *lp, u8 *data, u8 len)
        spi_message_add_tail(&xfer_head, &msg);
        spi_message_add_tail(&xfer_buf, &msg);
 
-       adf7242_wait_ready(lp, __LINE__);
+       adf7242_wait_spi_ready(lp, __LINE__);
 
        mutex_lock(&lp->bmux);
        buf[0] = CMD_SPI_PKT_WR;
@@ -401,7 +407,7 @@ static int adf7242_read_fbuf(struct adf7242_local *lp,
        spi_message_add_tail(&xfer_head, &msg);
        spi_message_add_tail(&xfer_buf, &msg);
 
-       adf7242_wait_ready(lp, __LINE__);
+       adf7242_wait_spi_ready(lp, __LINE__);
 
        mutex_lock(&lp->bmux);
        if (packet_read) {
@@ -432,7 +438,7 @@ static int adf7242_read_reg(struct adf7242_local *lp, u16 addr, u8 *data)
                .rx_buf = lp->buf_read_rx,
        };
 
-       adf7242_wait_ready(lp, __LINE__);
+       adf7242_wait_spi_ready(lp, __LINE__);
 
        mutex_lock(&lp->bmux);
        lp->buf_read_tx[0] = CMD_SPI_MEM_RD(addr);
@@ -462,7 +468,7 @@ static int adf7242_write_reg(struct adf7242_local *lp, u16 addr, u8 data)
 {
        int status;
 
-       adf7242_wait_ready(lp, __LINE__);
+       adf7242_wait_spi_ready(lp, __LINE__);
 
        mutex_lock(&lp->bmux);
        lp->buf_reg_tx[0] = CMD_SPI_MEM_WR(addr);
@@ -484,7 +490,7 @@ static int adf7242_cmd(struct adf7242_local *lp, unsigned int cmd)
        dev_vdbg(&lp->spi->dev, "%s : CMD=0x%X\n", __func__, cmd);
 
        if (cmd != CMD_RC_PC_RESET_NO_WAIT)
-               adf7242_wait_ready(lp, __LINE__);
+               adf7242_wait_rc_ready(lp, __LINE__);
 
        mutex_lock(&lp->bmux);
        lp->buf_cmd = cmd;