Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1613421imm; Fri, 27 Jul 2018 22:38:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd4z8nC0GZ1l1Dz44nbwIRPaTZLo7tJzyVbMOs0jiIsMBXeMW7uUpsnVMUaji1BbgczK7OQ X-Received: by 2002:a62:c8c2:: with SMTP id i63-v6mr9471963pfk.73.1532756313880; Fri, 27 Jul 2018 22:38:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532756313; cv=none; d=google.com; s=arc-20160816; b=CCt5yAM23pVhWV+XaZUuxFY4Hv+5bX3FRXc9iWX1xtaPmv2cQMDXgWu2hW6oiVpK67 VRdktr5PRiSlIRR5qkqBGO9jp23Gg5fd/MJpeoqzEPDDMA6gYB2o14qCEH8KxQJlCCwz X1qYXIZb95L0FUvkyptxI2390iCaSvX+F/40mCF7jO5azIGFpHtZU9jseHjW0P2v5fxn fgrdM//JrIAUQKbvcxDeNmPQfIBTv61Jhq5s9BllvPiiNZXdRbcWdQ8q1q150v91tkuQ nbWQitPz5B5uHb/keIhMzIf5SBPPkKjhFIO8UbTq4w7yVj2MsAdVozy2gYoxoq8PsaBE WcOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=Rpp+yOHsbvyGuNWXVu47cJGRCQQDJZlNj0s5RvwtsYY=; b=pKM8sKHN0b/r29EmqeK91Vi91en0AjFlO/BGSf4SCv/cSU0fXWdjtXj8A5o6cnr80l OCsx1fXCpwpSVzIRyrgDgAF9ySgcWMP1yfLNagZ6NUuaV2o8+uU856LEgTbC9XFcmKXE FWlE5MuRXNitFkh6pSHAyjOn5PDYhzld0hYqKfmexwKR9GwmqjRhGCyUlI2SgfY+xRaX l8jTI+SLN/Ng8lae0w4aRsTYLMHOOith23KvAcwfM7YOObhVfOWb4vR1ttjwTAw1BIhi FihfW4Q8YGo4FgBstcoLTqgVknHoauYhujAbbNv+IgyexpugySWZGX7xmtd7aRwZID8e yO7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t7-v6si5523209pfh.3.2018.07.27.22.38.19; Fri, 27 Jul 2018 22:38:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726155AbeG1HBV (ORCPT + 99 others); Sat, 28 Jul 2018 03:01:21 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:21200 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726052AbeG1HBV (ORCPT ); Sat, 28 Jul 2018 03:01:21 -0400 X-UUID: bd72859f023147c893f565fdbac925cc-20180728 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1367889538; Sat, 28 Jul 2018 13:36:06 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Sat, 28 Jul 2018 13:36:04 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Sat, 28 Jul 2018 13:36:04 +0800 From: To: , CC: , , , , Sean Wang Subject: [PATCH net-next 2/2] net-next: mediatek: cleanup unnecessary get chip id and its user Date: Sat, 28 Jul 2018 13:35:56 +0800 Message-ID: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <658dfd485c035cdae5452bc5d572125076b47a48.1532755541.git.sean.wang@mediatek.com> References: <658dfd485c035cdae5452bc5d572125076b47a48.1532755541.git.sean.wang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Wang Since driver is devicetree-based, all device type and charateristic can be determined by the compatible string and its data. It's unnecessary to create another dependent function to check chip ID and then decide whether the specific funciton is being supported on a certain device. It can be totally replaced by the existing flag, so a cleanup is made by removing the function and the only user, HWLRO. MT2701 also have a missing HWLRO support in old code, so add it the same patch. Signed-off-by: Sean Wang --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 48 +++-------------------------- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 +- 2 files changed, 5 insertions(+), 45 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 8c85a4b..6e6abdc 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -2458,42 +2458,6 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) return err; } -static int mtk_get_chip_id(struct mtk_eth *eth, u32 *chip_id) -{ - u32 val[2], id[4]; - - regmap_read(eth->ethsys, ETHSYS_CHIPID0_3, &val[0]); - regmap_read(eth->ethsys, ETHSYS_CHIPID4_7, &val[1]); - - id[3] = ((val[0] >> 16) & 0xff) - '0'; - id[2] = ((val[0] >> 24) & 0xff) - '0'; - id[1] = (val[1] & 0xff) - '0'; - id[0] = ((val[1] >> 8) & 0xff) - '0'; - - *chip_id = (id[3] * 1000) + (id[2] * 100) + - (id[1] * 10) + id[0]; - - if (!(*chip_id)) { - dev_err(eth->dev, "failed to get chip id\n"); - return -ENODEV; - } - - dev_info(eth->dev, "chip id = %d\n", *chip_id); - - return 0; -} - -static bool mtk_is_hwlro_supported(struct mtk_eth *eth) -{ - switch (eth->chip_id) { - case MT7622_ETH: - case MT7623_ETH: - return true; - } - - return false; -} - static int mtk_probe(struct platform_device *pdev) { struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -2572,11 +2536,7 @@ static int mtk_probe(struct platform_device *pdev) if (err) return err; - err = mtk_get_chip_id(eth, ð->chip_id); - if (err) - return err; - - eth->hwlro = mtk_is_hwlro_supported(eth); + eth->hwlro = MTK_HAS_CAPS(eth->soc->caps, MTK_HWLRO); for_each_child_of_node(pdev->dev.of_node, mac_np) { if (!of_device_is_compatible(mac_np, @@ -2665,19 +2625,19 @@ static int mtk_remove(struct platform_device *pdev) } static const struct mtk_soc_data mt2701_data = { - .caps = MTK_GMAC1_TRGMII, + .caps = MTK_GMAC1_TRGMII | MTK_HWLRO, .required_clks = MT7623_CLKS_BITMAP, .required_pctl = true, }; static const struct mtk_soc_data mt7622_data = { - .caps = MTK_DUAL_GMAC_SHARED_SGMII | MTK_GMAC1_ESW, + .caps = MTK_DUAL_GMAC_SHARED_SGMII | MTK_GMAC1_ESW | MTK_HWLRO, .required_clks = MT7622_CLKS_BITMAP, .required_pctl = false, }; static const struct mtk_soc_data mt7623_data = { - .caps = MTK_GMAC1_TRGMII, + .caps = MTK_GMAC1_TRGMII | MTK_HWLRO, .required_clks = MT7623_CLKS_BITMAP, .required_pctl = true, }; diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 672b8c3..4681929 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -566,6 +566,7 @@ struct mtk_rx_ring { #define MTK_GMAC2_SGMII (BIT(10) | MTK_SGMII) #define MTK_DUAL_GMAC_SHARED_SGMII (BIT(11) | MTK_GMAC1_SGMII | \ MTK_GMAC2_SGMII) +#define MTK_HWLRO BIT(12) #define MTK_HAS_CAPS(caps, _x) (((caps) & (_x)) == (_x)) /* struct mtk_eth_data - This is the structure holding all differences @@ -635,7 +636,6 @@ struct mtk_eth { struct regmap *ethsys; struct regmap *sgmiisys; struct regmap *pctl; - u32 chip_id; bool hwlro; refcount_t dma_refcnt; struct mtk_tx_ring tx_ring; -- 2.7.4