From patchwork Fri Nov 22 22:15:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 13883660 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 40A76E6ADCB for ; Fri, 22 Nov 2024 22:19:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6HrdX116se3rn9QRZsQ51ceQKyywuhiVyeVP2xiWD4c=; b=c3mMa/45FGKB96DcaVkbHHs3iO OsfJ0mjwY6V1+ctMXviltLUIbRIM1rgSkFIvw7nC3xjj4sdIrdCS1WSrFYhkztLK9VvuWlyTgUZnM ypgCtQgLfMBKyCvdd2C0SV9LNciLtT64jHcIMTcj2YJilzqcLVNQbEa4PaxGhg+kzrKf15UKJLMiT A2LlKRcAll2yzZSPr09Ra0bFgUVVdPGVCOxP4sKJBD0u49GvJvzJx/MH6/flbaFgXYTQTug6RG52q v4ddfpO/Ztob9vpIkmQ1UZNitTyc+YYD99ki1ITTbE9Yw7YAxsQVKMeZGMldFPgOdtV6/D/2HmUVs y3Z7tVfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tEbzJ-00000003Oug-3YAE; Fri, 22 Nov 2024 22:18:53 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tEbxS-00000003OSz-1zH1 for linux-arm-kernel@lists.infradead.org; Fri, 22 Nov 2024 22:16:59 +0000 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-aa52edbcb63so51200066b.1 for ; Fri, 22 Nov 2024 14:16:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1732313817; x=1732918617; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6HrdX116se3rn9QRZsQ51ceQKyywuhiVyeVP2xiWD4c=; b=RgLRghQWUXlhTVNQ3YU6IRIv0MncJJhwnRf+HH9KE9mGhFVg7g5/Y21RxCyfQXd9tI qWvkKvWe24S7itOP+x6hg/1AI+8YzQ/8Dc4yfCmWPneTCxGsjn7eJRwnSl4M8TGhYfX5 MpIKzZtmwEI9X7HMJdWuXM8IN457u04VSHFvk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732313817; x=1732918617; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6HrdX116se3rn9QRZsQ51ceQKyywuhiVyeVP2xiWD4c=; b=jISJeB6XWhErZcLGkcTspUZGC7Eh2F8WOehP3R4wtScdPkQpP7NJ3oAhevnBCUYpI9 S1jVSeX2eLnqfPV1ldxMYL9D6esmVNsM8HaJYS7s5lUIBDoGxsMGj0s9DfCUMN1UzmQI 6/MTzSRPEQXQajkxsQEOeTSA7O4bF8oosnlxYBsjTMy3bC+JxSF2x5efeoEcIkBCWQs2 W/EzwI5NLrnnjju2UZQbFeWNmQnUnUlug0YrwdaSiYyUq0sbDIcgDfSHauIvgP3t/Pa3 MyI7Rv0ANMZsvAXxbZjgJeBaewdtc0f20rBDosTtO6QsCxrrG3f0n+B92nYtRSXuskwW LUaA== X-Forwarded-Encrypted: i=1; AJvYcCUlzhJkdTaHQbFLOTPfNKVkxcJSKmazwk86NPvr7qsQPcpFzupIJLvcsfNi5Gwu7HQ1oLfZLrVpDFgkAN8d+tVg@lists.infradead.org X-Gm-Message-State: AOJu0YzrxC1hAo9LYXnNZiRZI1JgysGjLnJQCk9+Xmt8rPRdA6+KvG1M wjluYKpRWmNgZpOAwQzKp82DbqUAjVf2l4ukjsoYxYMBvXbyZcROSSiE67PdRgU= X-Gm-Gg: ASbGncu9PPpMkjoDMhfZr7MBj+b9Wg/fswiCiADUX1UCLLb9JKcbvK0U09UDFjTrgtR 9+e6lgp/EJ5pSbNlyqpHse/YliGwquA9fv9PrHwVrMTPUT80ymewxWL0kSVdb58PF4LKlIUSNk4 tcnpI9+ylIxfa+Ns6wqZzuBoOWuSz3Qx7/cyoNGjSrkG2RhzzFxLoMn1J3LVFeR+7/KMB4P+l5O w2/ONH2pTosB1INGR+Oiv+MxsMCEYj8W7Kh0yaKYED0pS7noZZRG/7HOPtYKGJuvA/NE78Tx5b5 0MHHuWYS0YmBuf3OQiPeQ7qZfmMkM/Fotd2o9dWUjGkQkEPs93Zv3aZIe1+eGrZ3fxAgt/2zFqV ydya3CB+SB28dWgfS X-Google-Smtp-Source: AGHT+IHRSafR/Hd70o+h3rYpO/7VHYMjBwxEdj1MERjp9IAi6352iOe+u8OcuPheRZbM1LDn8364LQ== X-Received: by 2002:a17:906:31c1:b0:aa5:24df:ca8 with SMTP id a640c23a62f3a-aa524df1311mr297959966b.18.1732313816670; Fri, 22 Nov 2024 14:16:56 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-82-54-94-193.retail.telecomitalia.it. [82.54.94.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa50b52fcebsm148226466b.127.2024.11.22.14.16.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 14:16:56 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Chen-Yu Tsai , Gerhard Bertelsmann , Jernej Skrabec , Marc Kleine-Budde , Maxime Ripard , Samuel Holland , Vincent Mailhol , linux-arm-kernel@lists.infradead.org, linux-can@vger.kernel.org, linux-sunxi@lists.linux.dev Subject: [PATCH v2 02/12] can: sun4i_can: call can_change_state() even if cf is NULL Date: Fri, 22 Nov 2024 23:15:43 +0100 Message-ID: <20241122221650.633981-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241122221650.633981-1-dario.binacchi@amarulasolutions.com> References: <20241122221650.633981-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241122_141658_508451_9B7A57AA X-CRM114-Status: GOOD ( 12.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The function can_change_state() can also be called if the allocation of the skb fails, as it handles the cf parameter when it is null. Additionally, this ensures that the statistics related to state error counters (i. e. warning, passive, and bus-off) are updated. Fixes: 0738eff14d81 ("can: Allwinner A10/A20 CAN Controller support - Kernel module") Signed-off-by: Dario Binacchi --- Changes in v2: - Added in v2 drivers/net/can/sun4i_can.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c index 360158c295d3..17f94cca93fb 100644 --- a/drivers/net/can/sun4i_can.c +++ b/drivers/net/can/sun4i_can.c @@ -629,10 +629,10 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status) tx_state = txerr >= rxerr ? state : 0; rx_state = txerr <= rxerr ? state : 0; - if (likely(skb)) - can_change_state(dev, cf, tx_state, rx_state); - else - priv->can.state = state; + /* The skb allocation might fail, but can_change_state() + * handles cf == NULL. + */ + can_change_state(dev, cf, tx_state, rx_state); if (state == CAN_STATE_BUS_OFF) can_bus_off(dev); } From patchwork Fri Nov 22 22:15:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 13883661 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0EEFFE6ADCA for ; Fri, 22 Nov 2024 22:20:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=da17qF15VPZTU2YSYHqLzMcyFK3KqWPtGcD0XFwPoOY=; b=v+0/BMyP81yiTaFNHOfTf2Ern/ QgxT/Hxi529GjiuMO9oWrgWQ8s5nr8S+JLAicszMSb1G5eMiLyEy57ZUz1BFjIWSaXOT3PJuUHkfN fjqaYDy7/5fscRQpWn55gTsrLA+7pXGuu1GueOpP3a4WCmjpj/cHS6kUA1W9/ALjTroaSqrsaFflu SHYyIQGXNSXvbISj46UYDB2E9Cn4FMLTSUiKzx0QC/7bqSu/IPMekiDnxiRo2tYgK0AwGPORot5A+ Fv+jKsRnrRIO7MA9xu+98g1TwariPOtowKcVcG7RJAlO7/uIOhqCvdEx/78hPdHBCnF+Jm18xi+s6 +e9W1UIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tEc0F-00000003P95-1oUY; Fri, 22 Nov 2024 22:19:51 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tEbxT-00000003OT8-0bvE for linux-arm-kernel@lists.infradead.org; Fri, 22 Nov 2024 22:17:00 +0000 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-aa51bf95ce1so146066566b.3 for ; Fri, 22 Nov 2024 14:16:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1732313818; x=1732918618; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=da17qF15VPZTU2YSYHqLzMcyFK3KqWPtGcD0XFwPoOY=; b=j/t7s+koGOtkMjPo+Xju/uPsxg/fZGiys1uu/PKH3vIu8rbgnnCHMI9lCC/2pqwGlZ NhcKyUYxDS0mXg24fS/iHHnyMgza0lZXqlbfCwCldBa0FZ1SGHUwldYNRkazUcgM40Qz yOvm5qesdkoZre2CnRamrV2rm87mKJGcFBKKM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732313818; x=1732918618; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=da17qF15VPZTU2YSYHqLzMcyFK3KqWPtGcD0XFwPoOY=; b=KPMAHtezIINjJVoVigfwxHtP7M/sy4gjOV0p4LCcFcQd/pwxGmbyVa47ajHQ17sTUr dEIxsf8Qe2oFTfGtWNTmGStY4z0rJZ+34lu7mVwPmml+et+RCMDPdZKInSJHOuKIyJ/s CdaQWUYX1D4jWbT7xzKZbhZgCicKoEnl5eY/2ReuN9hXrtEj6mNXVuFbVi8O8aOqogJd 4P8HURZHmqUMaxXv2l+Qwvsa0aCkJEe/Acy1XL9b5iR08Swy+DdAx36eQi+TWt0+EUU1 ypl6c1vTK9NoriDnhuIrPTNhehV6dbh+Wu5GQmccy8OB91VrmzpQpMm4KDuk/e94XwG7 Tg+g== X-Forwarded-Encrypted: i=1; AJvYcCVW6d4k4fU7e0tQgOPgtOTWT8LfFKRChgsIJKCfLCR+/8Jk6JZkJONmRmqpIk1LU8ZYBeT1yhx3Gzj/PJK+MzBs@lists.infradead.org X-Gm-Message-State: AOJu0YwgnnVAMwCQD137y4sLlU9/cbkTNK4U8mt4JVfKUaVtIidCwHSs IeCvyEG2qmMVFA70O5UEAHIKk+obP5NN7ZUNJ6ZJh8oJzsup833XJu+jlAt8cMo= X-Gm-Gg: ASbGncu9cyT+2V/cMH2OZ5QgJqiI4+/+/XpF813q97sU0di5MQzKUzqMcndsk5FxnNs O2P5I45pdVthO/ZD0JL1SjCf6S/1ciS9W57YSIb52XBTsaeAsWvetpwa7JJHKvcOQcDUxHwqEFW iA8B3lvaxTb/ui15/CLRCuKXtUWTsL1d9NLi7GCdtH+aSSGLs6OPjEXzqpagiCweTifRBsB9iwJ DFcNbPkN7oRVxwvBL9nOpyBJnr3h376W/+B07xhxh1QdCBdI15xXvkws5aPy5tyzA3tdy8gTaos aktmV7Acf+AdAlp7yYIy16lRuajBCoNoymoPLu1r90LzyCWH3LXAEuH20WTVe2GznaoN7ogm8B4 l4WKGotI9HqvWK313 X-Google-Smtp-Source: AGHT+IFqavb84q465UWZ6gGwXgO+FxfrEo4gdscEtW86lZSTJTKpRR6rT4g7qMsIZYvAutdo4gpnMQ== X-Received: by 2002:a17:906:4c9:b0:aa5:cec:2785 with SMTP id a640c23a62f3a-aa50cec28b3mr343858766b.25.1732313817919; Fri, 22 Nov 2024 14:16:57 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-82-54-94-193.retail.telecomitalia.it. [82.54.94.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa50b52fcebsm148226466b.127.2024.11.22.14.16.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 14:16:57 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Chen-Yu Tsai , Jernej Skrabec , Marc Kleine-Budde , Samuel Holland , Vincent Mailhol , linux-arm-kernel@lists.infradead.org, linux-can@vger.kernel.org, linux-sunxi@lists.linux.dev Subject: [PATCH v2 03/12] can: sun4i_can: continue to use likely() to check skb Date: Fri, 22 Nov 2024 23:15:44 +0100 Message-ID: <20241122221650.633981-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241122221650.633981-1-dario.binacchi@amarulasolutions.com> References: <20241122221650.633981-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241122_141659_179755_E0D0E1A6 X-CRM114-Status: GOOD ( 13.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Throughout the sun4i_can_err() function, the likely() macro is used to check the skb buffer, except in one instance. This patch makes the code consistent by using the macro in that case as well. Signed-off-by: Dario Binacchi --- Changes in v2: - Added in v2 drivers/net/can/sun4i_can.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c index 17f94cca93fb..840b972498c1 100644 --- a/drivers/net/can/sun4i_can.c +++ b/drivers/net/can/sun4i_can.c @@ -570,7 +570,7 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status) else state = CAN_STATE_ERROR_ACTIVE; } - if (skb && state != CAN_STATE_BUS_OFF) { + if (likely(skb) && state != CAN_STATE_BUS_OFF) { cf->can_id |= CAN_ERR_CNT; cf->data[6] = txerr; cf->data[7] = rxerr; From patchwork Fri Nov 22 22:15:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 13883662 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 72668E6ADCB for ; Fri, 22 Nov 2024 22:20:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=koSu2Qr3uUTmv0FA1/R7W/a8VprfWgcqXI/05k6MgFU=; b=t/frJYwlaWOTC0AD1GMRuFIybu 9U33h7aUO2C1GbmyynEB5HPn+39w6S/ggV8oP6485uhMd2C72tu6ZkSdJg9/cF+5Pef8+a4HjkL8B iCo9dz8owI4Z627mGMcVksmOXLDFWn7d+qX1+Sxi+jWrJmY85NiqrPrmYVYBb+e6+nYyzSxbRaDIP x70HOtNTs/4CfKST9vw3qUlNiHTszsHsiZW9xn7ouy3xb4adWkfAnszaTNsH7M+Rob3HExH1u2ZOj 35O8Pu3ZoVp7dvZrIYCw6y2h6nTRfOQB+D8KG856u0qw5vRT7hGmCrtyfUM1hhTF+LmXSL+KWGAC5 F0TBH5dA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tEc1B-00000003POV-0exr; Fri, 22 Nov 2024 22:20:49 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tEbxc-00000003OU8-0JyS for linux-arm-kernel@lists.infradead.org; Fri, 22 Nov 2024 22:17:09 +0000 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a9e44654ae3so358182666b.1 for ; Fri, 22 Nov 2024 14:17:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1732313826; x=1732918626; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=koSu2Qr3uUTmv0FA1/R7W/a8VprfWgcqXI/05k6MgFU=; b=jgEIT7k1z5uVUUDknb07a9q5JclczcYkjGLNINt9p8e9vi82QWCnEeZOUtUjDHJQGW b2Ro3z4XDJlNvJQXLsTZoZSrTiD9SQeIMCM76V3JLdEZEE+ASoZq4QZRLQGh7AV49Kzp Ubp8/MTYurnOYh0L8GVL15nMz/lYw6NxWvdKQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732313826; x=1732918626; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=koSu2Qr3uUTmv0FA1/R7W/a8VprfWgcqXI/05k6MgFU=; b=CAPPQrLRTxpK6Kb5Dm3VsokA0xwOTLJgH0cH66XtI2MRI+LyP9GLpiZJp+u16q7ydR augJLbeJTLzyfCXnawik2WBiIRXHjM7Lv+xyKOftR+c7A4w/J76LwRbU+K3dQMhrbhu1 XAAK/Jl25mn78z6z+qDDH6BBj4KBES22RUKqMfT9gVU2FgRqY6vDJ+QDGFfs5f/8IaOW rLIBt/KZVIF4MiLp6fb8LdB+yYoa5qSBdh0vtLfL0FzoKuksWYnMgnJdUQFrcsDQL0qw qgtr+itUXvQ7c3cwcCgS86E0GBlMOCHNV0OJX6aTlEb7hjq+TFKef0pdZAIGwjJYUITb OEGg== X-Forwarded-Encrypted: i=1; AJvYcCVGtIpozuzgzRaGyWOzsU2jhXJexZLNfZiIAECD9/5xA6eQJNiWhk5z4SHPAMwSp/y7KzCxFQYeZSw/0MitEoW/@lists.infradead.org X-Gm-Message-State: AOJu0YycDIdrXHuxDXj4fj9X6VM3d6vJPpRUE+xFjXIBgMMItdaNoL/b aYtVwKSqg87229VqXQbIh5QooIyLkfGcRiibsBsRyh9/VS/jx355Y7aP/YfrstM= X-Gm-Gg: ASbGncsIu7YXDLiYdhpAMpGSmA6ncfq4HV70wOdYIqvO5FMCFyMCx2K9/31/mB1Wbdv vvAGVGrIT/IF3VZ7zb4rCtbMB9S5LNHLeIuCXhyfZFts7ioFq+gpwgG7BxR1eBTsZZ2tXLAo0Tc LRL9u/+/sSkG9jHIM/pqzqDOR1TsyGF/vuKOATH+snGEptSo3bIBnUn5jUiYxr1XqQrk8+EbspK jc8XzwaGhoJqleva53h67Xrds0LLYiLTzjS3jWIYp1015QpvGyLSVoyNDOocNuzNl7shz9kuQbr Q81okh6yFnvEnw4HTtAWF+04P3wukDJeQRM7sSQUN5funoG89rjSlz0BVLJB5jmoEpHE8APBcwA 8crG/XR9V1wQgbEps X-Google-Smtp-Source: AGHT+IGzFnZJs4h2n/iV/ioahj7WXElDTwCpUUULB2OBEylU5ouM6Ybr9FJMu/M15S4g4KqefHT26Q== X-Received: by 2002:a17:906:31da:b0:aa5:30c0:384b with SMTP id a640c23a62f3a-aa530c03aecmr47395466b.24.1732313826492; Fri, 22 Nov 2024 14:17:06 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-82-54-94-193.retail.telecomitalia.it. [82.54.94.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa50b52fcebsm148226466b.127.2024.11.22.14.17.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 14:17:06 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Chen-Yu Tsai , Gerhard Bertelsmann , Jernej Skrabec , Marc Kleine-Budde , Maxime Ripard , Samuel Holland , Vincent Mailhol , linux-arm-kernel@lists.infradead.org, linux-can@vger.kernel.org, linux-sunxi@lists.linux.dev Subject: [PATCH v2 10/12] can: sun4i_can: fix {rx,tx}_errors statistics Date: Fri, 22 Nov 2024 23:15:51 +0100 Message-ID: <20241122221650.633981-11-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241122221650.633981-1-dario.binacchi@amarulasolutions.com> References: <20241122221650.633981-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241122_141708_110021_936C55B2 X-CRM114-Status: GOOD ( 14.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The sun4i_can_err() function only incremented the receive error counter and never the transmit error counter, even if the STA_ERR_DIR flag reported that an error had occurred during transmission. Increment the receive/transmit error counter based on the value of the STA_ERR_DIR flag. Fixes: 0738eff14d81 ("can: Allwinner A10/A20 CAN Controller support - Kernel module") Signed-off-by: Dario Binacchi --- Changes in v2: - Update statistics even if skb allocation fails drivers/net/can/sun4i_can.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c index 840b972498c1..5285bb0b7c69 100644 --- a/drivers/net/can/sun4i_can.c +++ b/drivers/net/can/sun4i_can.c @@ -579,7 +579,6 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status) /* bus error interrupt */ netdev_dbg(dev, "bus error interrupt\n"); priv->can.can_stats.bus_error++; - stats->rx_errors++; if (likely(skb)) { ecc = readl(priv->base + SUN4I_REG_STA_ADDR); @@ -601,9 +600,15 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status) >> 16; break; } - /* error occurred during transmission? */ - if ((ecc & SUN4I_STA_ERR_DIR) == 0) + } + + /* error occurred during transmission? */ + if ((ecc & SUN4I_STA_ERR_DIR) == 0) { + if (likely(skb)) cf->data[2] |= CAN_ERR_PROT_TX; + stats->tx_errors++; + } else { + stats->rx_errors++; } } if (isrc & SUN4I_INT_ERR_PASSIVE) {