diff options
author | Ricardo Salveti <ricardo.salveti@linaro.org> | 2017-01-25 23:26:10 -0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2017-01-28 08:43:41 +0200 |
commit | 2569e2e8d1f690ca9f095b9346f4c4d13b6253e0 (patch) | |
tree | d0a22113380add49d26ca76eaedc0afd95aa1531 | |
parent | f27d8eef395ef79ec0c20ac1a2967402f292293d (diff) |
Bluetooth: SPI: retry spi_transceive calls if invalid
spi_transceive can return successfuly even if the data provided by the
slave is invalid, so check if the content is correct and retry until a
valid data is available.
Change-Id: Ia951de391e0b24c5b41eeabfb5c10b056d32b62e
Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
-rw-r--r-- | drivers/bluetooth/hci/spi.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/bluetooth/hci/spi.c b/drivers/bluetooth/hci/spi.c index c7377614c..08e977818 100644 --- a/drivers/bluetooth/hci/spi.c +++ b/drivers/bluetooth/hci/spi.c @@ -155,7 +155,9 @@ static void bt_spi_rx_thread(void) header_slave[STATUS_HEADER_TOREAD] == 0xFF); size = header_slave[STATUS_HEADER_TOREAD]; - spi_transceive(spi_dev, &txmsg, size, &rxmsg, size); + do { + spi_transceive(spi_dev, &txmsg, size, &rxmsg, size); + } while (rxmsg[0] == 0); #if defined(CONFIG_BLUETOOTH_SPI_BLUENRG) gpio_pin_write(cs_dev, GPIO_CS_PIN, 1); @@ -251,7 +253,9 @@ static int bt_spi_send(struct net_buf *buf) (rxmsg[1] | rxmsg[2] | rxmsg[3] | rxmsg[4]) == 0); /* Transmit the message */ - spi_transceive(spi_dev, buf->data, buf->len, rxmsg, buf->len); + do { + spi_transceive(spi_dev, buf->data, buf->len, rxmsg, buf->len); + } while (rxmsg[0] == 0); #if defined(CONFIG_BLUETOOTH_SPI_BLUENRG) /* Deselect chip */ |