[PATCH wpan-next v4 07/11] net: ieee802154: at86rf230: Provide meaningful error codes when possible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Either the spi operation failed, or the offloaded transmit operation
failed and returned a TRAC value. Use this value when available or use
the default "SYSTEM_ERROR" otherwise, in order to propagate one step
above the error.

Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>
---
 drivers/net/ieee802154/at86rf230.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index d3cf6d23b57e..34d199f597c9 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -358,7 +358,23 @@ static inline void
 at86rf230_async_error(struct at86rf230_local *lp,
 		      struct at86rf230_state_change *ctx, int rc)
 {
-	dev_err(&lp->spi->dev, "spi_async error %d\n", rc);
+	int reason;
+
+	switch (rc) {
+	case TRAC_CHANNEL_ACCESS_FAILURE:
+		reason = IEEE802154_CHANNEL_ACCESS_FAILURE;
+		break;
+	case TRAC_NO_ACK:
+		reason = IEEE802154_NO_ACK;
+		break;
+	default:
+		reason = IEEE802154_SYSTEM_ERROR;
+	}
+
+	if (rc < 0)
+		dev_err(&lp->spi->dev, "spi_async error %d\n", rc);
+	else
+		dev_err(&lp->spi->dev, "xceiver error %d\n", reason);
 
 	at86rf230_async_state_change(lp, ctx, STATE_FORCE_TRX_OFF,
 				     at86rf230_async_error_recover);
@@ -666,10 +682,15 @@ at86rf230_tx_trac_check(void *context)
 	case TRAC_SUCCESS:
 	case TRAC_SUCCESS_DATA_PENDING:
 		at86rf230_async_state_change(lp, ctx, STATE_TX_ON, at86rf230_tx_on);
+		return;
+	case TRAC_CHANNEL_ACCESS_FAILURE:
+	case TRAC_NO_ACK:
 		break;
 	default:
-		at86rf230_async_error(lp, ctx, -EIO);
+		trac = TRAC_INVALID;
 	}
+
+	at86rf230_async_error(lp, ctx, trac);
 }
 
 static void
-- 
2.27.0




[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux