From patchwork Thu Mar 9 10:58:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 66814 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp235632wrd; Thu, 9 Mar 2023 03:31:43 -0800 (PST) X-Google-Smtp-Source: AK7set+PG4fOJdIgXGWjKpspKLyy/5oJwwLyhr8Ka1oCj/ie/Vr6H1+FGrxakg66FTXUr1UgPuwz X-Received: by 2002:a05:6a20:918a:b0:be:ea27:3c16 with SMTP id v10-20020a056a20918a00b000beea273c16mr19877161pzd.35.1678361502759; Thu, 09 Mar 2023 03:31:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678361502; cv=none; d=google.com; s=arc-20160816; b=f9bmTErF0eP/nbDPSdFwrWjdj6KvJtivQkVgD8tPGRwjkiCz7QzbODNkMoaJXAHfMl TKMyzhILq+SH4isVDxHkNq8evlXadbNL0w0DbumfG42A0144zswgO5CWKc+C4aOjJqRT 6eT0YzTOsXvhfem01BqViXuvyxePQuw0bGGtnkJIY0ScMRXu/Rw6BJ1LYHuaFbyDBqSK Eb4e/V3vogOMeBszfpTMgqiRttzJHjpRt1TPXbqmcTZriM64jaPhdsxnz04udefazJKa Q0P5Lj+PMPA+zBf66TbtvgVV/0zcy7CvQF1EGSUv+IjhbQ7v9cFIsySzNYdsfl/cq6p1 hbiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=nEP8nAmqQW6VQMCsSbLux6EAVUvcWyZJb4B7gESQ6AI=; b=niFNd1ANzrSC2db2zilKvomNa6v2VtHNf9p3Io/fNs7GoFTz2p2A6RdvJ+DooDnQv+ zAlEKSDLco6wU3CHK8JogSWYSuOjnf795Idh0Ha70ID3hRl7Vv7OVwY/R+EaVlD2dCtU PO6YxKS4UIhqMKvSx7p414POOt/gV/TwKbPpLA+EfJim/+icipWy7rRGbQtVWBtVZhjl 9tydFTqShp8xqjwD42fHXOAw2Oa9AyhIEZcnZ8eiBxGyZ2FuhGoLunlNV/rYfTJ5FRU/ VgrKIa+Wdowj3I9R7IKlMChvuASOCAHTRBcwUdBAw5kHAuVyJh8ssSteGM1HrjQ1Qwh0 Zdmg== 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 f21-20020a63de15000000b004de7c3add77si16418752pgg.262.2023.03.09.03.31.28; Thu, 09 Mar 2023 03:31:42 -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; 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 S231433AbjCILFx (ORCPT + 99 others); Thu, 9 Mar 2023 06:05:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231513AbjCILEx (ORCPT ); Thu, 9 Mar 2023 06:04:53 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA90FEABA7; Thu, 9 Mar 2023 03:00:04 -0800 (PST) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1paE0B-0003fM-0z; Thu, 09 Mar 2023 12:00:03 +0100 Date: Thu, 9 Mar 2023 10:58:25 +0000 From: Daniel Golle To: netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Russell King , Heiner Kallweit , Lorenzo Bianconi , Mark Lee , John Crispin , Felix Fietkau , AngeloGioacchino Del Regno , Matthias Brugger , DENG Qingfang , Landen Chao , Sean Wang , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Vladimir Oltean , Florian Fainelli , Andrew Lunn , Vladimir Oltean Cc: =?iso-8859-1?q?Bj=F8rn?= Mork , Frank Wunderlich , Alexander Couzens Subject: [PATCH net-next v13 14/16] net: ethernet: mtk_eth_soc: rely on num_devs and remove MTK_MAC_COUNT Message-ID: <539c90308a48fe9e2be4e8935c582bbded69f71b.1678357225.git.daniel@makrotopia.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759889591595346209?= X-GMAIL-MSGID: =?utf-8?q?1759889591595346209?= 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 | 30 ++++++++++----------- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 - 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 95a9764b4c70..ce4f2eb3ed0d 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]); @@ -1943,7 +1943,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; @@ -2923,7 +2923,7 @@ static int mtk_set_features(struct net_device *dev, netdev_features_t features) MTK_CDMP_EG_CTRL); /* sync features with other MAC */ - for (i = 0; i < MTK_MAC_COUNT; i++) { + for (i = 0; i < eth->soc->num_devs; i++) { if (!eth->netdev[i] || eth->netdev[i] == dev) continue; eth->netdev[i]->features &= ~NETIF_F_HW_VLAN_CTAG_RX; @@ -3013,7 +3013,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) { @@ -3167,7 +3167,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 */ @@ -3771,7 +3771,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)); @@ -3977,7 +3977,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; @@ -3993,7 +3993,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; @@ -4021,7 +4021,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]); @@ -4040,7 +4040,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; @@ -4346,7 +4346,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; } @@ -4491,7 +4491,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)) @@ -4815,7 +4815,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 f0c38c856cd0..8c5f72603604 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