From patchwork Thu Sep 12 13:28:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11142765 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF3CA1599 for ; Thu, 12 Sep 2019 10:29:07 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9CB3520692 for ; Thu, 12 Sep 2019 10:29:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="R7cbXKrL"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="qxKgbsPJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9CB3520692 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=analog.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=9nHzLBOvdYw+w1mROOg3El5PUw+vEpAF6YKS5Oizihs=; b=R7cbXKrLga9Zkj 21/TuBfcFWgW+46lSvIfgIasivev7HfCwIugIPIcZDZyQksa7rj1PV4s7Hg+na9znxKNNoczIP9XT 4zHdOQ+etqfIlqy/7YylOSLEYRaVNq0AM7e0v3Dh+qQxe06tTj/FxKzrlnsNrrmmaurLuLXdcZbSO F91TCH6FiFXNsr0ip6O5lGicOf/W/wZP81Z3O7DlzFfOVJV/F9f85xFnMnkB05Eck7NYG58GVukdC IYAaT77O+28nWk5nB9fFoWqfmZ1F5CYVBrBPvwWrTY1WLV1AoSfYyNaBXY3hRBbqRm1wQcmmatAMl Yudom1Kb/vyC1Sllt39A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1i8MLZ-0002XW-VR; Thu, 12 Sep 2019 10:29:05 +0000 Received: from mx0b-00128a01.pphosted.com ([148.163.139.77]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1i8MLV-0002WW-Qd for linux-arm-kernel@lists.infradead.org; Thu, 12 Sep 2019 10:29:03 +0000 Received: from pps.filterd (m0167091.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8CASlIH024068; Thu, 12 Sep 2019 06:28:56 -0400 Received: from nam03-dm3-obe.outbound.protection.outlook.com (mail-dm3nam03lp2057.outbound.protection.outlook.com [104.47.41.57]) by mx0b-00128a01.pphosted.com with ESMTP id 2uv6a9r64v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 12 Sep 2019 06:28:56 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y2XWlC1g1TLRG8FkO4MqGYK8W8UBkh+RlaBsYbmN50rfY7wpr8q/vUta4UmEj1Mbz38tUcBsrxYxiK4DcyxfbcgmA7RhQSgXdhhBq4L1WSYuikXFRM+YsnW5kpyOvP0KyS6LVDICHe5wIuuj0MYqLIfBRQpOxyh+iN3d81lt1Nnebgv42QFGBizaMZLayFOD4WKKxkaZM1Ue48UYiMHVzvhXkDwoJdWZVwtfgvwLRZ6dyX70h0uQ1degUYfhvW8sz8CC/4kChqOyXt/rkYYTJSgIluZ0OeeRvbhHYxtMvnBTsE1ziobDNL1A5EQpo995/ZOpGjCCtuiRKJIHBWaL6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RQ0uzHRZGaUQlzUs+HXy+tvbdQgya2t3zqjsiawQh2E=; b=bxPpVBf1iq3kzAm8YhmUEIbpvSJqDSYxaBmlpi1i/cR9j/hePd7ZDGtAR4FocV2AooOWea5zAYrS4u2N0SXcmm0vkRdJQU9akzpDxwFBYP7TweqEFalfGpG5QrJD4dZ7ZQt7O3NHAz0es5NnvpiPfsqTKDaoKFJS8PMsfYSId/3Vz3tvbNTiGcfMRS101VGKkA/ygahMj5hN+Yg07oGZGSH3JxFhlr4JDJhKa1Cws4YZdd+tDCSFEwCJQGQQF4yxBdJqixFASoQ4bFkk5WtDx1S3Q+TJzUDbHzQccqiZ51OnjDZpdc1wP3omzQ5AA7HUptNltPer4HJf36jbIk2WZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RQ0uzHRZGaUQlzUs+HXy+tvbdQgya2t3zqjsiawQh2E=; b=qxKgbsPJzfrxOONGgtzTuotRJpWoYrlVUe08lyW/vRJ0RaGSmOD01UQVKVdRjrQ6fUR79V2852WxWOye7j8E2zNPA5/rg0Yzrd1OapNNf4eDixDF314A0313vZzmy130X4ZzrPUNHfeScaADDJUzwqkDhFcekAxjmnbv1MTFrok= Received: from BN8PR03CA0034.namprd03.prod.outlook.com (2603:10b6:408:94::47) by BN3PR03MB2227.namprd03.prod.outlook.com (2a01:111:e400:7bba::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.17; Thu, 12 Sep 2019 10:28:55 +0000 Received: from CY1NAM02FT004.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e45::201) by BN8PR03CA0034.outlook.office365.com (2603:10b6:408:94::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2199.21 via Frontend Transport; Thu, 12 Sep 2019 10:28:55 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by CY1NAM02FT004.mail.protection.outlook.com (10.152.74.112) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2241.14 via Frontend Transport; Thu, 12 Sep 2019 10:28:54 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8CASndV012000 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Thu, 12 Sep 2019 03:28:49 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Thu, 12 Sep 2019 06:28:53 -0400 From: Alexandru Ardelean To: , , , Subject: [PATCH v2] net: stmmac: socfpga: re-use the `interface` parameter from platform data Date: Thu, 12 Sep 2019 16:28:50 +0300 Message-ID: <20190912132850.10585-1-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(346002)(376002)(39860400002)(396003)(136003)(189003)(199004)(54534003)(336012)(305945005)(44832011)(36756003)(476003)(478600001)(5660300002)(486006)(70206006)(8936002)(26005)(70586007)(50466002)(7636002)(426003)(107886003)(186003)(48376002)(86362001)(2616005)(8676002)(126002)(2201001)(246002)(2870700001)(316002)(4326008)(51416003)(50226002)(7696005)(1076003)(47776003)(54906003)(110136005)(106002)(2906002)(356004)(81973001)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR03MB2227; H:nwd2mta2.analog.com; FPR:; SPF:Pass; LANG:en; PTR:nwd2mail11.analog.com; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d139b25e-fb44-4f23-be7a-08d7376c035c X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600166)(711020)(4605104)(4709080)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328); SRVR:BN3PR03MB2227; X-MS-TrafficTypeDiagnostic: BN3PR03MB2227: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-Forefront-PRVS: 01583E185C X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: dR5zoj/n96O+PARMvuXpRTEyu9AunmOyaCMJx9fmpm14Ywqk+4gqUQzrtOaR6bjiD40IXlBkZS3Nka/ZUoRSbqD45v7A0iUtYf5exOYk1f7KgX3j1Y/6E3B+CBDvKyrI8vDFY1dGaQ43k6b2UpxeIc973eqM3UbmjHV9ATOKJBf7IolloE73mfOkba1PryNvIZSpR+y5Q68QXj8Iat94UHuU+iO68m5TJ2uRdS7eWevAg7I6b2I2BwJhh7cEYdh6SX/EkX9TOGcUT/PWR3BxsH2bloH18GRx1ei1e43qxzlr1MyfYSBhbt8ixNyFa4b8fYsoOD2Hrj66AGSBo5dCjkBvFW9ngHkShtxJJdduLv+FSiiAxSW8eOJrx/bCbPr6lY04+qmTL3X3tGrNerobuM8ov2QOcntmuDBzxp5/F7U= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2019 10:28:54.7368 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d139b25e-fb44-4f23-be7a-08d7376c035c X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a; Ip=[137.71.25.57]; Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR03MB2227 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-09-12_05:2019-09-11,2019-09-12 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 phishscore=0 suspectscore=0 priorityscore=1501 impostorscore=0 mlxlogscore=889 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1906280000 definitions=main-1909120111 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190912_032902_136002_021C2054 X-CRM114-Status: GOOD ( 12.64 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [148.163.139.77 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alexandre.torgue@st.com, joabreu@synopsys.com, mcoquelin.stm32@gmail.com, peppe.cavallaro@st.com, Alexandru Ardelean , davem@davemloft.net Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The socfpga sub-driver defines an `interface` field in the `socfpga_dwmac` struct and parses it on init. The shared `stmmac_probe_config_dt()` function also parses this from the device-tree and makes it available on the returned `plat_data` (which is the same data available via `netdev_priv()`). All that's needed now is to dig that information out, via some `dev_get_drvdata()` && `netdev_priv()` calls and re-use it. Signed-off-by: Alexandru Ardelean --- Changelog v1 -> v2: * initially, this patch was developed on a 4.14 kernel, and adapted (badly) to `net-next`, so it did not build ; the v2 has been fixed and adapted correctly .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c index c141fe783e87..5b6213207c43 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c @@ -46,7 +46,6 @@ struct socfpga_dwmac_ops { }; struct socfpga_dwmac { - int interface; u32 reg_offset; u32 reg_shift; struct device *dev; @@ -110,8 +109,6 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac *dwmac, struct device * struct resource res_tse_pcs; struct resource res_sgmii_adapter; - dwmac->interface = of_get_phy_mode(np); - sys_mgr_base_addr = altr_sysmgr_regmap_lookup_by_phandle(np, "altr,sysmgr-syscon"); if (IS_ERR(sys_mgr_base_addr)) { @@ -231,6 +228,14 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac *dwmac, struct device * return ret; } +static inline int socfpga_get_plat_phymode(struct socfpga_dwmac *dwmac) +{ + struct net_device *ndev = dev_get_drvdata(dwmac->dev); + struct stmmac_priv *priv = netdev_priv(ndev); + + return priv->plat->interface; +} + static int socfpga_set_phy_mode_common(int phymode, u32 *val) { switch (phymode) { @@ -255,7 +260,7 @@ static int socfpga_set_phy_mode_common(int phymode, u32 *val) static int socfpga_gen5_set_phy_mode(struct socfpga_dwmac *dwmac) { struct regmap *sys_mgr_base_addr = dwmac->sys_mgr_base_addr; - int phymode = dwmac->interface; + int phymode = socfpga_get_plat_phymode(dwmac); u32 reg_offset = dwmac->reg_offset; u32 reg_shift = dwmac->reg_shift; u32 ctrl, val, module; @@ -314,7 +319,7 @@ static int socfpga_gen5_set_phy_mode(struct socfpga_dwmac *dwmac) static int socfpga_gen10_set_phy_mode(struct socfpga_dwmac *dwmac) { struct regmap *sys_mgr_base_addr = dwmac->sys_mgr_base_addr; - int phymode = dwmac->interface; + int phymode = socfpga_get_plat_phymode(dwmac); u32 reg_offset = dwmac->reg_offset; u32 reg_shift = dwmac->reg_shift; u32 ctrl, val, module;