From patchwork Sun Jun 11 00:36:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 106036 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1814128vqr; Sat, 10 Jun 2023 18:36:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5FU5yAS2zyHTIxaiZ/WIPfbN/FJfWwsGd53HsiMhJqbI/uJXBj66cJsY49iOTy7gy94PaO X-Received: by 2002:a17:902:da90:b0:1ae:10a5:8349 with SMTP id j16-20020a170902da9000b001ae10a58349mr3473744plx.23.1686447366383; Sat, 10 Jun 2023 18:36:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686447366; cv=none; d=google.com; s=arc-20160816; b=cS7lHHDwPOeYuRfGokYhC310Jv4Oh1pyKQSpRLJUNzCWR1njT6X7Eil9/aVyfT/4pF 42rWILHywUzk8qqlpYhm7wCH9lgNVLlsnQOcPjl0bBuubGlpwju4gTDR53aSH8qqzDKC t36+kdSolpSv+v86t/bYnI2ZPNg0h4l6unBj/zx7YT8fHTLRmOU71yE+vgYLEhtSY1hU Ht+Y6p+DE+rWsYZMCD10Qp4VOatH3ehHKATFbvjNhwXuhefMsDTrzYsjK6X+Elw+rTJ1 deSa1AxlVWJPc7VMYBepWwUPsc8vyyR1urgyoKyPSxB4OiboSUFP9t40aJQ0q0QJx+Vy ZBGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date; bh=W5LZSmfCfVpXI8639uShuCMPilYDNDD+l493iJilJdw=; b=N7BINfpBPOAdKCs2pu4ZJBwHVz3MeEV8kI7c/jv+pf4gVje//U5hr0aF9HkePRCyQG by6+I/Ubo17CdHOTRwYEALuH3JS6B+OG0MYhbO8kYl1bhgPGLJerScYOBEppyJbW8mxY n1r+oyc6EbeNB9jowubfKI90iIuTkUMhEaD9Obqlt8xgJiaeLkWeq8/5FxmWaSTb8aa1 i42xUffEoK3fsshMeYAzqotfBEfohlbj7JB/h6Suj4Hnpaw4QiTCUoIpIWLOn/h2Un5e Xj+UgnklrPsUDBKXhJoa5h37Cwb9xfBfqbzo1DkJQTg0/UCTYRHvdIreWPYDIlhluuQX 1a2w== ARC-Authentication-Results: i=1; mx.google.com; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n7-20020a170902e54700b0019931c82e24si5227384plf.195.2023.06.10.18.35.54; Sat, 10 Jun 2023 18:36:06 -0700 (PDT) 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; 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 S232693AbjFKAhc (ORCPT + 99 others); Sat, 10 Jun 2023 20:37:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229622AbjFKAhb (ORCPT ); Sat, 10 Jun 2023 20:37:31 -0400 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D32A930F6; Sat, 10 Jun 2023 17:37:29 -0700 (PDT) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1q895E-0005Da-15; Sun, 11 Jun 2023 00:37:28 +0000 Date: Sun, 11 Jun 2023 01:36:45 +0100 From: Daniel Golle To: netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Russell King , AngeloGioacchino Del Regno , Matthias Brugger , Lorenzo Bianconi , Mark Lee , Sean Wang , John Crispin , Felix Fietkau , Conor Dooley , Krzysztof Kozlowski , Rob Herring , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Sam Shih Subject: [PATCH net-next 4/8] net: ethernet: mtk_eth_soc: rely on num_devs and remove MTK_MAC_COUNT Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768368233577602996?= X-GMAIL-MSGID: =?utf-8?q?1768368233577602996?= From: Lorenzo Bianconi Get rid of MTK_MAC_COUNT since it is a duplicated of eth->soc->num_devs. Signed-off-by: Lorenzo Bianconi Signed-off-by: Daniel Golle --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 28 ++++++++++----------- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 - 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index f91b661379a94..45b6f85f0822c 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -963,7 +963,7 @@ static void mtk_stats_update(struct mtk_eth *eth) { int i; - for (i = 0; i < MTK_MAC_COUNT; i++) { + for (i = 0; i < eth->soc->num_devs; i++) { if (!eth->mac[i] || !eth->mac[i]->hw_stats) continue; if (spin_trylock(ð->mac[i]->hw_stats->stats_lock)) { @@ -1468,7 +1468,7 @@ static int mtk_queue_stopped(struct mtk_eth *eth) { int i; - for (i = 0; i < MTK_MAC_COUNT; i++) { + for (i = 0; i < eth->soc->num_devs; i++) { if (!eth->netdev[i]) continue; if (netif_queue_stopped(eth->netdev[i])) @@ -1482,7 +1482,7 @@ static void mtk_wake_queue(struct mtk_eth *eth) { int i; - for (i = 0; i < MTK_MAC_COUNT; i++) { + for (i = 0; i < eth->soc->num_devs; i++) { if (!eth->netdev[i]) continue; netif_tx_wake_all_queues(eth->netdev[i]); @@ -1941,7 +1941,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, !(trxd.rxd4 & RX_DMA_SPECIAL_TAG)) mac = RX_DMA_GET_SPORT(trxd.rxd4) - 1; - if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT || + if (unlikely(mac < 0 || mac >= eth->soc->num_devs || !eth->netdev[mac])) goto release_desc; @@ -2978,7 +2978,7 @@ static void mtk_dma_free(struct mtk_eth *eth) const struct mtk_soc_data *soc = eth->soc; int i; - for (i = 0; i < MTK_MAC_COUNT; i++) + for (i = 0; i < soc->num_devs; i++) if (eth->netdev[i]) netdev_reset_queue(eth->netdev[i]); if (eth->scratch_ring) { @@ -3132,7 +3132,7 @@ static void mtk_gdm_config(struct mtk_eth *eth, u32 config) if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) return; - for (i = 0; i < MTK_MAC_COUNT; i++) { + for (i = 0; i < eth->soc->num_devs; i++) { u32 val = mtk_r32(eth, MTK_GDMA_FWD_CFG(i)); /* default setup the forward port to send frame to PDMA */ @@ -3745,7 +3745,7 @@ static int mtk_hw_init(struct mtk_eth *eth, bool reset) * up with the more appropriate value when mtk_mac_config call is being * invoked. */ - for (i = 0; i < MTK_MAC_COUNT; i++) { + for (i = 0; i < eth->soc->num_devs; i++) { struct net_device *dev = eth->netdev[i]; mtk_w32(eth, MAC_MCR_FORCE_LINK_DOWN, MTK_MAC_MCR(i)); @@ -3950,7 +3950,7 @@ static void mtk_pending_work(struct work_struct *work) mtk_prepare_for_reset(eth); /* stop all devices to make sure that dma is properly shut down */ - for (i = 0; i < MTK_MAC_COUNT; i++) { + for (i = 0; i < eth->soc->num_devs; i++) { if (!eth->netdev[i] || !netif_running(eth->netdev[i])) continue; @@ -3966,7 +3966,7 @@ static void mtk_pending_work(struct work_struct *work) mtk_hw_init(eth, true); /* restart DMA and enable IRQs */ - for (i = 0; i < MTK_MAC_COUNT; i++) { + for (i = 0; i < eth->soc->num_devs; i++) { if (!test_bit(i, &restart)) continue; @@ -3994,7 +3994,7 @@ static int mtk_free_dev(struct mtk_eth *eth) { int i; - for (i = 0; i < MTK_MAC_COUNT; i++) { + for (i = 0; i < eth->soc->num_devs; i++) { if (!eth->netdev[i]) continue; free_netdev(eth->netdev[i]); @@ -4013,7 +4013,7 @@ static int mtk_unreg_dev(struct mtk_eth *eth) { int i; - for (i = 0; i < MTK_MAC_COUNT; i++) { + for (i = 0; i < eth->soc->num_devs; i++) { struct mtk_mac *mac; if (!eth->netdev[i]) continue; @@ -4319,7 +4319,7 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) } id = be32_to_cpup(_id); - if (id >= MTK_MAC_COUNT) { + if (id >= eth->soc->num_devs) { dev_err(eth->dev, "%d is not a valid mac id\n", id); return -EINVAL; } @@ -4464,7 +4464,7 @@ void mtk_eth_set_dma_device(struct mtk_eth *eth, struct device *dma_dev) rtnl_lock(); - for (i = 0; i < MTK_MAC_COUNT; i++) { + for (i = 0; i < eth->soc->num_devs; i++) { dev = eth->netdev[i]; if (!dev || !(dev->flags & IFF_UP)) @@ -4788,7 +4788,7 @@ static int mtk_remove(struct platform_device *pdev) int i; /* stop all devices to make sure that dma is properly shut down */ - for (i = 0; i < MTK_MAC_COUNT; i++) { + for (i = 0; i < eth->soc->num_devs; i++) { if (!eth->netdev[i]) continue; mtk_stop(eth->netdev[i]); diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 62981e00be7e7..2af7e46cadcbb 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -33,7 +33,6 @@ #define MTK_TX_DMA_BUF_LEN_V2 0xffff #define MTK_QDMA_RING_SIZE 2048 #define MTK_DMA_SIZE 512 -#define MTK_MAC_COUNT 2 #define MTK_RX_ETH_HLEN (ETH_HLEN + ETH_FCS_LEN) #define MTK_RX_HLEN (NET_SKB_PAD + MTK_RX_ETH_HLEN + NET_IP_ALIGN) #define MTK_DMA_DUMMY_DESC 0xffffffff