From patchwork Thu Mar 3 18:25:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12767908 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 F148DC43217 for ; Thu, 3 Mar 2022 18:25:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235757AbiCCS0O (ORCPT ); Thu, 3 Mar 2022 13:26:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235762AbiCCS0L (ORCPT ); Thu, 3 Mar 2022 13:26:11 -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 52A571A58EA; Thu, 3 Mar 2022 10:25:25 -0800 (PST) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id BB76F20011; Thu, 3 Mar 2022 18:25:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1646331922; 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=regqtWdmmr7YwP29eVg+fqSTAspcC6y2WbxEFTy5muw=; b=mdKlb9kgwh3LLXPCZJ/K2YDn63AOlIxD1hlzJh34PEY0fa2IS0IHSUwXMHCJDb82bLJVPn x4rdaE6/TXvqGJKFKTL+48BvgiL1M7XazEYnhIUHx/XvFrfHjucy9dTZDvbhYKjvHdd2hU 7q4NczKx/FVZ59KZRmBLy0KDI2K6RkcxZBzqO2j4nlA1Zt9EJZDrhwmAttX50EcyyquIwF EXVOy67vo/RULj6S2YGhok9T1FPH1wavvwtymwb6pvXT1AIC+0r2zFWV1IFWglmO+1pvBv MbzZYf06Kv+7IIq44YxVWmr8KkbqIskqSPuL9V+kb+sHFzhskrxTOsS5rGBMUw== 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 08/11] net: ieee802154: at86rf230: Call _xmit_error() when a transmission fails Date: Thu, 3 Mar 2022 19:25:05 +0100 Message-Id: <20220303182508.288136-9-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 ieee802154_xmit_error() is the right helper to call when a transmission has failed. Let's use it instead of open-coding it. As the error helper also requires an error code, save the error from the previous helper in order to give this value to the core when opportunate. Signed-off-by: Miquel Raynal --- drivers/net/ieee802154/at86rf230.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c index 5f19266b3045..9cc272e3460a 100644 --- a/drivers/net/ieee802154/at86rf230.c +++ b/drivers/net/ieee802154/at86rf230.c @@ -74,6 +74,7 @@ struct at86rf230_state_change { u8 to_state; bool free; + int reason; }; struct at86rf230_trac { @@ -340,14 +341,14 @@ at86rf230_async_error_recover_complete(void *context) { struct at86rf230_state_change *ctx = context; struct at86rf230_local *lp = ctx->lp; + int reason = ctx->reason; if (ctx->free) kfree(ctx); if (lp->was_tx) { lp->was_tx = 0; - dev_kfree_skb_any(lp->tx_skb); - ieee802154_wake_queue(lp->hw); + ieee802154_xmit_error(lp->hw, lp->tx_skb, reason); } } @@ -370,27 +371,24 @@ static inline void at86rf230_async_error(struct at86rf230_local *lp, struct at86rf230_state_change *ctx, int rc) { - int reason; - switch (rc) { case TRAC_CHANNEL_ACCESS_FAILURE: - reason = IEEE802154_CHANNEL_ACCESS_FAILURE; + ctx->reason = IEEE802154_CHANNEL_ACCESS_FAILURE; break; case TRAC_NO_ACK: - reason = IEEE802154_NO_ACK; + ctx->reason = IEEE802154_NO_ACK; break; case TRAC_INVALID: - reason = IEEE802154_SYSTEM_ERROR; + ctx->reason = IEEE802154_SYSTEM_ERROR; break; default: - reason = rc; + ctx->reason = rc; } - if (reason < 0) - dev_err(&lp->spi->dev, "spi_async error %d\n", reason); + if (ctx->reason < 0) + dev_err(&lp->spi->dev, "spi_async error %d\n", ctx->reason); else - dev_err(&lp->spi->dev, "xceiver error %d\n", reason); - + dev_err(&lp->spi->dev, "xceiver error %d\n", ctx->reason); at86rf230_async_state_change(lp, ctx, STATE_FORCE_TRX_OFF, at86rf230_async_error_recover);