Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp126953ybj; Wed, 6 May 2020 13:12:12 -0700 (PDT) X-Google-Smtp-Source: APiQypKEYpDtmgBcR8BXKtSffO3FoqaGExd9yYX4pqnIIiMcZVh9YtwrSR+mp5zgwSX/S5CjR9JD X-Received: by 2002:a17:906:c7c5:: with SMTP id dc5mr9185645ejb.50.1588795932743; Wed, 06 May 2020 13:12:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588795932; cv=none; d=google.com; s=arc-20160816; b=sHqEGEf6p3ECYIvYHY0tFtt5LO2Ioeef7PaHDSH5OY+CLPDQN61+3CXGTaDTD08Ih3 GWn4KZm++VEkv1OCptHmI+RCtl43i6h2ga4bt01pWQRzv9232w3Sc3s0v5kHKNAF4uUu GBcWjNE33HpFU8yrIbsDFzKqF+Pn5KkYbKx3HmqmHyhcebSwx/fcj6L33vi3nvJxGxej CQERgJPJ4N8ikJv2fkcTDTX8vlWrsw2dSq5U/sPrYc0qnT683/PKa7Znwk2f/7w5WGAa FHv/gT4v139wuWbBjWK5BAI3j+n18C7NvZ8+LZgn3r1DTehN4D6d54IjM4mfrg+ci4es UOKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=5yZ7JC4OWeyt8Rfs+b/8ZA/lxsiWV1eg54sWiXKTJX8=; b=tpgWtxaaGPd8jon17RnN1E6HHGFHsjmYlR2fQtbrACQoDSE2HD36/e+PuTVTBS8kpp foPJRb3ST/VG2GRqItcN1ONRpAdEvoBU/TkzdjyjEyGJ42G5SiyaWU5avWsP4dwGpcGU LqvIP1DfGBtQPko8OT3TEI5Q4s3WBZCrzG/yQvx+FMFjOtzIj+pXFAxNm7ZIvVB7hf/m TNO/56sMKl0WV+sS2AxTWB/TGVWtHu0no8llYyFdT0FmyRgHqmcdkukfx2NRmvJOICAY +xUASAOoVIh/1NhqNMILh+fu0l9whsPzxshRsda0qIWYuTN9AblC1RM9LVHs8G6y3sTt zjgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m4si1811997eje.107.2020.05.06.13.11.48; Wed, 06 May 2020 13:12:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728957AbgEFTYi (ORCPT + 99 others); Wed, 6 May 2020 15:24:38 -0400 Received: from smtprelay0110.hostedemail.com ([216.40.44.110]:52916 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728770AbgEFTYi (ORCPT ); Wed, 6 May 2020 15:24:38 -0400 Received: from smtprelay.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by smtpgrave05.hostedemail.com (Postfix) with ESMTP id E692F18289F65; Wed, 6 May 2020 19:24:36 +0000 (UTC) Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay06.hostedemail.com (Postfix) with ESMTP id D560118221882; Wed, 6 May 2020 19:24:35 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,,RULES_HIT:41:355:379:599:800:960:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:1801:2194:2199:2393:2553:2559:2562:2828:2901:2902:3138:3139:3140:3141:3142:3353:3622:3865:3870:4250:4321:4605:5007:6119:6742:7576:7875:8957:9149:10004:10400:10848:11026:11232:11233:11473:11657:11658:11914:12043:12296:12297:12740:12760:12895:13069:13311:13357:13439:14096:14097:14181:14659:14721:21080:21451:21627:21740:21939:21990:30012:30054:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:3,LUA_SUMMARY:none X-HE-Tag: group10_aa59a2ed6d34 X-Filterd-Recvd-Size: 3211 Received: from XPS-9350.home (unknown [47.151.136.130]) (Authenticated sender: joe@perches.com) by omf18.hostedemail.com (Postfix) with ESMTPA; Wed, 6 May 2020 19:24:33 +0000 (UTC) Message-ID: Subject: Re: [PATCH 06/11] net: ethernet: mtk-eth-mac: new driver From: Joe Perches To: Leon Romanovsky , Bartosz Golaszewski Cc: Rob Herring , "David S . Miller" , Matthias Brugger , Felix Fietkau , John Crispin , Sean Wang , Mark Lee , Jakub Kicinski , Arnd Bergmann , Fabien Parent , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-netdev , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Bartosz Golaszewski Date: Wed, 06 May 2020 12:24:31 -0700 In-Reply-To: References: <20200505140231.16600-1-brgl@bgdev.pl> <20200505140231.16600-7-brgl@bgdev.pl> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.36.1-2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2020-05-06 at 22:16 +0300, Leon Romanovsky wrote: > On Tue, May 5, 2020 at 5:03 PM Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski > > > > This adds the driver for the MediaTek Ethernet MAC used on the MT8* SoC > > family. For now we only support full-duplex. [] > > diff --git a/drivers/net/ethernet/mediatek/mtk_eth_mac.c b/drivers/net/ethernet/mediatek/mtk_eth_mac.c [] > > +struct mtk_mac_priv { > > + struct regmap *regs; > > + struct regmap *pericfg; > > + > > + struct clk_bulk_data clks[MTK_MAC_NCLKS]; > > + > > + void *ring_base; > > + struct mtk_mac_ring_desc *descs_base; > > + dma_addr_t dma_addr; > > + struct mtk_mac_ring tx_ring; > > + struct mtk_mac_ring rx_ring; > > + struct work_struct tx_work; > > + > > + struct mii_bus *mii; > > + struct napi_struct napi; > > + > > + struct device_node *phy_node; > > + phy_interface_t phy_intf; > > + struct phy_device *phydev; > > + unsigned int link; > > + int speed; > > + int duplex; > > + > > + /* Protects against concurrent descriptor access. */ > > + spinlock_t lock; > > + unsigned long lock_flags; > > + > > + struct rtnl_link_stats64 stats; > > +}; > > + > > +static struct net_device *mtk_mac_get_netdev(struct mtk_mac_priv *priv) > > +{ > > + char *ptr = (char *)priv; > > + > > + return (struct net_device *)(ptr - ALIGN(sizeof(struct net_device), > > + NETDEV_ALIGN)); > > +} This code looks ugly/fragile. Why not store the struct net_device * in struct mtk_mac_priv ?