From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 94FD1EEAA4F for ; Thu, 14 Sep 2023 15:13:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NyRp1yVTEz26FQb0mi1fJU/yQkt/Ppf9Lbd3IwXN6Vs=; b=dBRGv5J+HQKoHE Dl74VyjGqjrpNlE1vTx+uVOghk6S97sudtfQTb7tasyvFmEJeEXCY7FNTz7zlNT/YWGucrQZcBFcO abxgdviVB+P/LiFa3B4WkPr9/XBpnddVs+fDUkt2hDs69dXk1xo6tYn9LMe/06vDcKo06p5EDvlLu xgnPXxvD50kPbGwmLtnDkcp/DVU0c4eIeYaEEb50up8sJjT/FzUgUEN1u3bl39Zap1bdLaDhvupkb me7GtaDdHoiSkXoSgW7Ry72RCF/u8coIdz6i05gyWi4AzC6WD3CzPMQsrbA/pgO3k1bu3m4ogN5r3 1h6NbFMBDo6Z76fHyaDA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qgo1C-008l6h-16; Thu, 14 Sep 2023 15:12:34 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qgo17-008l4z-2m for linux-arm-kernel@lists.infradead.org; Thu, 14 Sep 2023 15:12:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=JCzR9bnKdQWaES21IE+SF94nKQUXujpbyIjqGFP/0Oc=; b=DocVKf/DEW9GRSxUzKW453infY 3tYI+lAYsKsAnPVa7L81GtPxGu/JHmN0CUL5NnFS5ySgtVc0fm7xGOTr/TlNJz+qFOaxnb2S9YCLa xM/M+3/QGiaZJ3iIWQNW2T09x4tADGJD/aDNbarS7hf46Gy9NH411PTGoI6Zl+XttLd8Yi/6cexjh KAkiikxKjDnuZxrk3vLO2r/ak/Oz8I2NbDpgRuopWXji7UCf9N2hl2dLZYhiIsiQHw0hv+cl8URyC bh4xBVakhyntjhPPVqeBZvQ8ckzeO2McAI6zEDpVO6AkjJTIArjD2rcGxa7mmop04lraEZo5pU1fb Ioank7rA==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:40360) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qgo0u-0004Sf-1Y; Thu, 14 Sep 2023 16:12:16 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qgo0r-0004s6-VM; Thu, 14 Sep 2023 16:12:13 +0100 Date: Thu, 14 Sep 2023 16:12:13 +0100 From: "Russell King (Oracle)" To: Serge Semin Cc: Alexandre Torgue , Jose Abreu , Alexei Starovoitov , bpf@vger.kernel.org, Daniel Borkmann , "David S. Miller" , Emil Renner Berthing , Eric Dumazet , Fabio Estevam , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, NXP Linux Team , Paolo Abeni , Pengutronix Kernel Team , Samin Guo , Sascha Hauer , Shawn Guo Subject: Re: [PATCH net-next 1/6] net: stmmac: add stmmac_set_tx_clk_gmii() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230914_081229_896916_478AA346 X-CRM114-Status: GOOD ( 24.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Sep 14, 2023 at 05:54:09PM +0300, Serge Semin wrote: > On Thu, Sep 14, 2023 at 02:51:20PM +0100, Russell King (Oracle) wrote: > > Add a helper function for setting the transmit clock for GMII > > interfaces. This handles 1G, 100M and 10M using the standard clock > > rates of 125MHz, 25MHz and 2.5MHz. > > > > Signed-off-by: Russell King (Oracle) > > --- > > .../ethernet/stmicro/stmmac/stmmac_platform.c | 25 +++++++++++++++++++ > > .../ethernet/stmicro/stmmac/stmmac_platform.h | 1 + > > 2 files changed, 26 insertions(+) > > > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c > > index 0f28795e581c..f7635ed2b255 100644 > > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c > > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c > > @@ -700,6 +700,31 @@ EXPORT_SYMBOL_GPL(stmmac_probe_config_dt); > > EXPORT_SYMBOL_GPL(devm_stmmac_probe_config_dt); > > EXPORT_SYMBOL_GPL(stmmac_remove_config_dt); > > > > > +int stmmac_set_tx_clk_gmii(struct clk *tx_clk, unsigned int speed) > > +{ > > + unsigned long rate; > > + > > + switch (speed) { > > + case SPEED_1000: > > + rate = 125000000; > > + break; > > + > > + case SPEED_100: > > + rate = 25000000; > > + break; > > + > > + case SPEED_10: > > + rate = 2500000; > > + break; > > + > > + default: > > + return -ENOTSUPP; > > + } > > + > > + return clk_set_rate(tx_clk, rate); > > +} > > +EXPORT_SYMBOL_GPL(stmmac_set_tx_clk_gmii); > > As I already noted in v1 normally the switch-case operations are > defined with no additional line separating the cases. I would have > dropped them here too especially seeing the stmmac core driver mainly > follow that implicit convention. It's rather haphazard whether there are blank lines or not between case statements. > Additionally I suggest to move the method to being defined at the head > of the file. Thus a more natural order normally utilized in the kernel > drivers would be preserved: all functional implementations go first, > the platform-specific things are placed below like probe()/remove() > and their sub-functions, suspend()/resume() and PM descriptors, > (device IDs table, driver descriptor, etc). stmmac_set_tx_clk_gmii() > looks as a functional helper which is normally utilized on the network > device open() stage in the framework of the fix_mac_speed() callback. > Moreover my suggestion gets to be even more justified seeing you > placed the method prototype at the head of the prototypes list in the > stmmac_platform.h file. How is one supposed to know about this? I did my best trying to work out where they should've gone... If it's that important, maybe add some /* Comments */ to state that there are separate sections to the file? -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel