2021-09-23 07:33:26

by Sidong Yang

[permalink] [raw]
Subject: [PATCH] staging: pi433: goto abort when setting failed in tx_thread

tx_thread in pi433 works for transmitting. it reads tx_cfg and data
stored in kfifo put in pi433_write() and transmits. If it exits,
pi433_write() just store its data and no one transmits data. So,
tx_thread should not exit even when it failed for setting registers.
It seems that it's okay to go to abort and continue to loop and wait for
writing.

Signed-off-by: Sidong Yang <[email protected]>
---
drivers/staging/pi433/pi433_if.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index c8d0c63fdd1d..29bd37669059 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -649,7 +649,7 @@ pi433_tx_thread(void *data)
/* clear fifo, set fifo threshold, set payload length */
retval = rf69_set_mode(spi, standby); /* this clears the fifo */
if (retval < 0)
- return retval;
+ goto abort;

if (device->rx_active && !rx_interrupted) {
/*
@@ -661,33 +661,33 @@ pi433_tx_thread(void *data)

retval = rf69_set_fifo_threshold(spi, FIFO_THRESHOLD);
if (retval < 0)
- return retval;
+ goto abort;
if (tx_cfg.enable_length_byte == OPTION_ON) {
retval = rf69_set_payload_length(spi, size * tx_cfg.repetitions);
if (retval < 0)
- return retval;
+ goto abort;
} else {
retval = rf69_set_payload_length(spi, 0);
if (retval < 0)
- return retval;
+ goto abort;
}

/* configure the rf chip */
retval = rf69_set_tx_cfg(device, &tx_cfg);
if (retval < 0)
- return retval;
+ goto abort;

/* enable fifo level interrupt */
retval = rf69_set_dio_mapping(spi, DIO1, DIO_FIFO_LEVEL);
if (retval < 0)
- return retval;
+ goto abort;
device->irq_state[DIO1] = DIO_FIFO_LEVEL;
irq_set_irq_type(device->irq_num[DIO1], IRQ_TYPE_EDGE_FALLING);

/* enable packet sent interrupt */
retval = rf69_set_dio_mapping(spi, DIO0, DIO_PACKET_SENT);
if (retval < 0)
- return retval;
+ goto abort;
device->irq_state[DIO0] = DIO_PACKET_SENT;
irq_set_irq_type(device->irq_num[DIO0], IRQ_TYPE_EDGE_RISING);
enable_irq(device->irq_num[DIO0]); /* was disabled by rx active check */
@@ -695,7 +695,7 @@ pi433_tx_thread(void *data)
/* enable transmission */
retval = rf69_set_mode(spi, transmit);
if (retval < 0)
- return retval;
+ goto abort;

/* transfer this msg (and repetitions) to chip fifo */
device->free_in_fifo = FIFO_SIZE;
@@ -742,7 +742,7 @@ pi433_tx_thread(void *data)
dev_dbg(device->dev, "thread: Packet sent. Set mode to stby.");
retval = rf69_set_mode(spi, standby);
if (retval < 0)
- return retval;
+ goto abort;

/* everything sent? */
if (kfifo_is_empty(&device->tx_fifo)) {
--
2.20.1