Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7289602rwb; Tue, 6 Dec 2022 03:59:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf70Y6KVMzK4jvzB3CZesJwAJZfvyC3rU/msvMWxTiPwVAxKN7hU4eJlMSFjX6Mhu2XjRLS+ X-Received: by 2002:a63:ff0e:0:b0:434:aa69:bba2 with SMTP id k14-20020a63ff0e000000b00434aa69bba2mr75818806pgi.567.1670327998097; Tue, 06 Dec 2022 03:59:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670327998; cv=none; d=google.com; s=arc-20160816; b=eTQumzWRKLJB4X3EQPw1WDPQdPaG45uxDzR2zFCCAx8BfduPuxXnUOm2JLhxF2I5Ps f7W7VoUzF6eIACyx3RBuivX6uhNhIle+d4SFcJzwZy8gaf6i+f8PqJ3tdClTC2XXbtVH 7R+ZDemqS6IqFdk5VmYRbh/NoKs2Fm0RkkHTCgKoHsuwbb6F3Oxhcvt3NXQqqby0WMLo p1Z5zRrXrX84wyLeS9JjLmQmlYMCL8K79AJvfZEg/BYu6C8xTf2RHA1b8xjs95ngLyfz zpfVFQCRy/FyOrTL8xHltrbbe/EyL5bYToE8ix80Sc3JNdTqqCjocvrRhcWs8gSH+1Ag xLOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Jg8CR20tG79djQpdFo8U0Y6E9PQi/JvNHqoQZx2uO1Q=; b=Lg4Qn47FPw3A99jEM6ah8tkCFA2cBQNzoD4lMur3Zl7NlZ8KbKqNceN7uI/SdiiZd+ WSzesXGpbn8fcnQd0awLeb21zkUteWQhNy7Nx7+dhghPvXMdHIEe+bKdm3tcu/c/pwED 5mYrJbxzPcOw3cJfMfPI52bMYt/PKhJLWl2FMBdCfijK45O5rb6oVO+JrP0TLN+3rYQq SHcGpvzqDggthg2NW/Iyivv2QmoE8yVVWzrZVfyplEQ1Wuj6f6/XtYTK0aD9mVXGriXJ fRF3gL1pHsNq2TALmZR+zvvxehqQbx+jQtqmjZri1ZT5Rynx9eoN8lj/Bip5hf8yFDhr U07A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=zELG2lnh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s7-20020a639247000000b00477b371dc7bsi17095490pgn.536.2022.12.06.03.59.47; Tue, 06 Dec 2022 03:59:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=zELG2lnh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234242AbiLFL55 (ORCPT + 80 others); Tue, 6 Dec 2022 06:57:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229780AbiLFL5o (ORCPT ); Tue, 6 Dec 2022 06:57:44 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD18F958C for ; Tue, 6 Dec 2022 03:57:40 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id ud5so5617872ejc.4 for ; Tue, 06 Dec 2022 03:57:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; 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=Jg8CR20tG79djQpdFo8U0Y6E9PQi/JvNHqoQZx2uO1Q=; b=zELG2lnh50u90Jp2YLLVqH4yZCkDv7zMa535EWcQPw1JEmENJog2b3Vqaw170TwLzo Mz0Z8SmeWTO+dx1Wuqlpp0fYpWLBXeqtfqlcCQZ70JmisGnxHt9gDi7T3KbSDRq/ytP9 hOJ1oP74mxN+w1SRByUuzSSnFrUwbbjXn5/yUDUm5d+yU+2mw2E8sTLFVTMtLfuaVQCE w9JaR1YlrXSrq2LmYnEkm41ANlQdDqwshQbgkP3nVdbMCwXWNo8ur1m++gxNIw1Je89n Fj1r+UbVNA+7252hQFEO7reV7YGsMfRiDo7pj5nAZKquSRfB/BQZxVhRqEzcqJfFlJaT GPzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Jg8CR20tG79djQpdFo8U0Y6E9PQi/JvNHqoQZx2uO1Q=; b=CpLzQxnBsTxOF1C/PdEaF0s6E/A7V9dLBtnt9A2ESBekq5Kcd5DE7Cgq9+TqeXAx89 BmHuAcwPE8a0aLN4szybsIBsjiHQ1kUGDrf0kRwHARt6kE5sMqn6KMmrW8IqicSprJGu vJQsGVsxcobI31JGlmoaxLLlNyuwe7tvAyusdm8ZJ/r2W/COKU/j7wXa4PC4ghS+LNCp LpPb/e73dhM33sEnGPocFq1ub951kIk04YzL+bygP/z6H09RK22pRcAxYTYr+OEQeLbg RjAwmb7ztdYMuj1GqNdB1BQ78jPHhWsWDE+yMmRx3mcxQWbZXwHZoBAnj8HRvewSy/ir I8CA== X-Gm-Message-State: ANoB5pnys4pGYCa/+MhE0l77bTMlHVW06hJECGNWwKnoqSJ5Yuzex1OU bvzdZbYm8dVVs2YnF/EOQ99zPA== X-Received: by 2002:a17:906:444b:b0:7ad:dd43:5d53 with SMTP id i11-20020a170906444b00b007addd435d53mr54435818ejp.376.1670327859238; Tue, 06 Dec 2022 03:57:39 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a245:805c:8713:84e4:2a9e:cbe8]) by smtp.gmail.com with ESMTPSA id ky20-20020a170907779400b007c0ac4e6b6esm6472076ejc.143.2022.12.06.03.57.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 03:57:38 -0800 (PST) From: Markus Schneider-Pargmann To: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Wolfgang Grandegger Cc: linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v2 04/11] can: m_can: Count TXE FIFO getidx in the driver Date: Tue, 6 Dec 2022 12:57:21 +0100 Message-Id: <20221206115728.1056014-5-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221206115728.1056014-1-msp@baylibre.com> References: <20221206115728.1056014-1-msp@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The getindex simply increases by one for every iteration. There is no need to get the current getidx every time from a register. Instead we can just count and wrap if necessary. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 45c718413abf..a133f15fb90a 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1020,15 +1020,13 @@ static int m_can_echo_tx_event(struct net_device *dev) /* Get Tx Event fifo element count */ txe_count = FIELD_GET(TXEFS_EFFL_MASK, m_can_txefs); + fgi = FIELD_GET(TXEFS_EFGI_MASK, m_can_txefs); /* Get and process all sent elements */ for (i = 0; i < txe_count; i++) { u32 txe, timestamp = 0; int err; - /* retrieve get index */ - fgi = FIELD_GET(TXEFS_EFGI_MASK, m_can_read(cdev, M_CAN_TXEFS)); - /* get message marker, timestamp */ err = m_can_txe_fifo_read(cdev, fgi, 4, &txe); if (err) { @@ -1042,6 +1040,7 @@ static int m_can_echo_tx_event(struct net_device *dev) /* ack txe element */ m_can_write(cdev, M_CAN_TXEFA, FIELD_PREP(TXEFA_EFAI_MASK, fgi)); + fgi = (++fgi >= cdev->mcfg[MRAM_TXE].num ? 0 : fgi); /* update stats */ m_can_tx_update_stats(cdev, msg_mark, timestamp); -- 2.38.1