From patchwork Thu Mar 3 18:25:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12767910 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D45ABC433EF for ; Thu, 3 Mar 2022 18:25:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235766AbiCCS0S (ORCPT ); Thu, 3 Mar 2022 13:26:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235755AbiCCS0K (ORCPT ); Thu, 3 Mar 2022 13:26:10 -0500 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE96E1A58E4; Thu, 3 Mar 2022 10:25:22 -0800 (PST) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 3246D2000E; Thu, 3 Mar 2022 18:25:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1646331919; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YJXbl6AYQi16uRc3GrKH3BgZvJvVjapvU0fhtBE7LcY=; b=WF+7s/bSIFt9w8pGKpgjBN708I8BeoCChdW1hmuA8ejyKgKpaqUH/p50acY0ljrkaMlhHq A7V4Cq2DaxP24WkDGAxBb93n/OEp1eKfotCaEv4ng5v7ogkgNS+WOpg5+XXlc4/7ZI8k/G 47+Tk6Q2APocd3y3RCe+/DNRj83iA9q6Ak0lMPmc7NVrYUNvymu3Faytl0+8ne7qUlEbTk XPH59tbXmUIZL9YzS+gpZBQE58g0em6naIpyJI3RQQEbVwxr2wVbMtficWzp1Yh6dhqLX5 22I2+MTqfkCRHA8d7q+SOYPKpuLM8WIcICjN+9IScX8mn4kMAqwMIwFMk9J85A== From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Thomas Petazzoni , Miquel Raynal Subject: [PATCH wpan-next v3 06/11] net: ieee802154: at86rf230: Return early in case of error Date: Thu, 3 Mar 2022 19:25:03 +0100 Message-Id: <20220303182508.288136-7-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220303182508.288136-1-miquel.raynal@bootlin.com> References: <20220303182508.288136-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 --- drivers/net/ieee802154/at86rf230.c | 49 ++++++++++++++++-------------- 1 file changed, 26 insertions(+), 23 deletions(-) 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