diff mbox series

[wpan-next,v3,06/11] net: ieee802154: at86rf230: Return early in case of error

Message ID 20220303182508.288136-7-miquel.raynal@bootlin.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series ieee802154: Better Tx error handling | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 59 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Miquel Raynal March 3, 2022, 6:25 p.m. UTC
The TRAC register is only parsed in the Tx path if the debugfs entry is
enabled. This does not look like a good idea because this register gives
us the actual status of the transmitted packet.

Let's always check the content of this register and error out when
appropriate.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/net/ieee802154/at86rf230.c | 49 ++++++++++++++++--------------
 1 file changed, 26 insertions(+), 23 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 616acfa8cd28..12ee071057d2 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -673,33 +673,36 @@  at86rf230_tx_trac_check(void *context)
 	struct at86rf230_state_change *ctx = context;
 	struct at86rf230_local *lp = ctx->lp;
 
-	if (IS_ENABLED(CONFIG_IEEE802154_AT86RF230_DEBUGFS)) {
-		u8 trac = TRAC_MASK(ctx->buf[1]);
+	u8 trac = TRAC_MASK(ctx->buf[1]);
 
-		switch (trac) {
-		case TRAC_SUCCESS:
-			lp->trac.success++;
-			break;
-		case TRAC_SUCCESS_DATA_PENDING:
-			lp->trac.success_data_pending++;
-			break;
-		case TRAC_CHANNEL_ACCESS_FAILURE:
-			lp->trac.channel_access_failure++;
-			break;
-		case TRAC_NO_ACK:
-			lp->trac.no_ack++;
-			break;
-		case TRAC_INVALID:
-			lp->trac.invalid++;
-			break;
-		default:
-			WARN_ONCE(1, "received tx trac status %d\n", trac);
-			lp->trac.invalid++;
-			break;
-		}
+	switch (trac) {
+	case TRAC_SUCCESS:
+		lp->trac.success++;
+		break;
+	case TRAC_SUCCESS_DATA_PENDING:
+		lp->trac.success_data_pending++;
+		break;
+	case TRAC_CHANNEL_ACCESS_FAILURE:
+		lp->trac.channel_access_failure++;
+		goto failure;
+	case TRAC_NO_ACK:
+		lp->trac.no_ack++;
+		goto failure;
+	case TRAC_INVALID:
+		lp->trac.invalid++;
+		goto failure;
+	default:
+		WARN_ONCE(1, "received tx trac status %d\n", trac);
+		lp->trac.invalid++;
+		goto failure;
 	}
 
 	at86rf230_async_state_change(lp, ctx, STATE_TX_ON, at86rf230_tx_on);
+
+	return;
+
+failure:
+	at86rf230_async_error(lp, ctx, -EIO);
 }
 
 static void