From: Serge Semin <fancer.lancer@gmail.com> To: "Russell King (Oracle)" <linux@armlinux.org.uk> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>, Jose Abreu <joabreu@synopsys.com>, Alexei Starovoitov <ast@kernel.org>, bpf@vger.kernel.org, Daniel Borkmann <daniel@iogearbox.net>, "David S. Miller" <davem@davemloft.net>, Emil Renner Berthing <kernel@esmil.dk>, Eric Dumazet <edumazet@google.com>, Fabio Estevam <festevam@gmail.com>, Jakub Kicinski <kuba@kernel.org>, Jesper Dangaard Brouer <hawk@kernel.org>, John Fastabend <john.fastabend@gmail.com>, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin <mcoquelin.stm32@gmail.com>, netdev@vger.kernel.org, NXP Linux Team <linux-imx@nxp.com>, Paolo Abeni <pabeni@redhat.com>, Pengutronix Kernel Team <kernel@pengutronix.de>, Samin Guo <samin.guo@starfivetech.com>, Sascha Hauer <s.hauer@pengutronix.de>, Shawn Guo <shawnguo@kernel.org> Subject: Re: [PATCH net-next 4/6] net: stmmac: rk: use stmmac_set_tx_clk_gmii() Date: Thu, 14 Sep 2023 18:22:33 +0300 [thread overview] Message-ID: <rene2x562lqsknmwpaxpu337mhl4bgynct6vcyryebvem2umso@2pjocnxluxgg> (raw) In-Reply-To: <ZQMgtXSTsNoZohnx@shell.armlinux.org.uk> On Thu, Sep 14, 2023 at 04:03:17PM +0100, Russell King (Oracle) wrote: > On Thu, Sep 14, 2023 at 05:37:13PM +0300, Serge Semin wrote: > > On Thu, Sep 14, 2023 at 02:51:35PM +0100, Russell King (Oracle) wrote: > > > Use stmmac_set_tx_clk_gmii(). > > > > > > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> > > > --- > > > .../net/ethernet/stmicro/stmmac/dwmac-rk.c | 60 +++++-------------- > > > 1 file changed, 16 insertions(+), 44 deletions(-) > > > > > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c > > > index d920a50dd16c..5731a73466eb 100644 > > > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c > > > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c > > > @@ -1081,28 +1081,14 @@ static void rk3568_set_gmac_speed(struct rk_priv_data *bsp_priv, int speed) > > > { > > > struct clk *clk_mac_speed = bsp_priv->clks[RK_CLK_MAC_SPEED].clk; > > > struct device *dev = &bsp_priv->pdev->dev; > > > - unsigned long rate; > > > - int ret; > > > - > > > - switch (speed) { > > > - case 10: > > > - rate = 2500000; > > > - break; > > > - case 100: > > > - rate = 25000000; > > > - break; > > > - case 1000: > > > - rate = 125000000; > > > - break; > > > - default: > > > - dev_err(dev, "unknown speed value for GMAC speed=%d", speed); > > > - return; > > > - } > > > - > > > - ret = clk_set_rate(clk_mac_speed, rate); > > > - if (ret) > > > - dev_err(dev, "%s: set clk_mac_speed rate %ld failed %d\n", > > > - __func__, rate, ret); > > > + int err; > > > + > > > + err = stmmac_set_tx_clk_gmii(clk_mac_speed, speed); > > > + if (err == -ENOTSUPP) > > > > > + dev_err(dev, "invalid speed %uMbps\n", speed); > > > + else if (err) > > > + dev_err(dev, "failed to set tx rate for speed %uMbps: %pe\n", > > > > These type specifiers should have been '%d' since the speed variable > > is of the signed integer type here. > > Okay, having re-reviewed the changes, I'm changing them _all_ back to > be %d, because that is the _right_ thing. It is *not* unsigned, even > if fix_mac_speed() thinks that it is. It isn't. It's signed, and it's > stmmac bollocks implicitly casting it to unsigned - and that is > _wrong_. Yes, stmmac is wrong in casting it to the unsigned type, but even seeing the original type is intended to be signed doesn't mean the qualifier should be fixed separately from the variables type and function prototypes. It will cause even more confusion. IMO the best way would be to fix the plat_stmmacenet_data->fix_mac_speed() prototype and the respective methods in the glue drivers. But it would be too bulky and most likely out of your interest to be done. So I would still have the variables type and the format qualifier type matching here and in the rest of the drivers especially seeing the original code in the imx, starfive, rk, QoS Eth LLDDs sticks to the convention described by me. -Serge(y) > > So, on that point, my original submission was more correct than this > one, and you led me astray. > > -- > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ > FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
WARNING: multiple messages have this Message-ID (diff)
From: Serge Semin <fancer.lancer@gmail.com> To: "Russell King (Oracle)" <linux@armlinux.org.uk> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>, Jose Abreu <joabreu@synopsys.com>, Alexei Starovoitov <ast@kernel.org>, bpf@vger.kernel.org, Daniel Borkmann <daniel@iogearbox.net>, "David S. Miller" <davem@davemloft.net>, Emil Renner Berthing <kernel@esmil.dk>, Eric Dumazet <edumazet@google.com>, Fabio Estevam <festevam@gmail.com>, Jakub Kicinski <kuba@kernel.org>, Jesper Dangaard Brouer <hawk@kernel.org>, John Fastabend <john.fastabend@gmail.com>, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin <mcoquelin.stm32@gmail.com>, netdev@vger.kernel.org, NXP Linux Team <linux-imx@nxp.com>, Paolo Abeni <pabeni@redhat.com>, Pengutronix Kernel Team <kernel@pengutronix.de>, Samin Guo <samin.guo@starfivetech.com>, Sascha Hauer <s.hauer@pengutronix.de>, Shawn Guo <shawnguo@kernel.org> Subject: Re: [PATCH net-next 4/6] net: stmmac: rk: use stmmac_set_tx_clk_gmii() Date: Thu, 14 Sep 2023 18:22:33 +0300 [thread overview] Message-ID: <rene2x562lqsknmwpaxpu337mhl4bgynct6vcyryebvem2umso@2pjocnxluxgg> (raw) In-Reply-To: <ZQMgtXSTsNoZohnx@shell.armlinux.org.uk> On Thu, Sep 14, 2023 at 04:03:17PM +0100, Russell King (Oracle) wrote: > On Thu, Sep 14, 2023 at 05:37:13PM +0300, Serge Semin wrote: > > On Thu, Sep 14, 2023 at 02:51:35PM +0100, Russell King (Oracle) wrote: > > > Use stmmac_set_tx_clk_gmii(). > > > > > > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> > > > --- > > > .../net/ethernet/stmicro/stmmac/dwmac-rk.c | 60 +++++-------------- > > > 1 file changed, 16 insertions(+), 44 deletions(-) > > > > > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c > > > index d920a50dd16c..5731a73466eb 100644 > > > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c > > > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c > > > @@ -1081,28 +1081,14 @@ static void rk3568_set_gmac_speed(struct rk_priv_data *bsp_priv, int speed) > > > { > > > struct clk *clk_mac_speed = bsp_priv->clks[RK_CLK_MAC_SPEED].clk; > > > struct device *dev = &bsp_priv->pdev->dev; > > > - unsigned long rate; > > > - int ret; > > > - > > > - switch (speed) { > > > - case 10: > > > - rate = 2500000; > > > - break; > > > - case 100: > > > - rate = 25000000; > > > - break; > > > - case 1000: > > > - rate = 125000000; > > > - break; > > > - default: > > > - dev_err(dev, "unknown speed value for GMAC speed=%d", speed); > > > - return; > > > - } > > > - > > > - ret = clk_set_rate(clk_mac_speed, rate); > > > - if (ret) > > > - dev_err(dev, "%s: set clk_mac_speed rate %ld failed %d\n", > > > - __func__, rate, ret); > > > + int err; > > > + > > > + err = stmmac_set_tx_clk_gmii(clk_mac_speed, speed); > > > + if (err == -ENOTSUPP) > > > > > + dev_err(dev, "invalid speed %uMbps\n", speed); > > > + else if (err) > > > + dev_err(dev, "failed to set tx rate for speed %uMbps: %pe\n", > > > > These type specifiers should have been '%d' since the speed variable > > is of the signed integer type here. > > Okay, having re-reviewed the changes, I'm changing them _all_ back to > be %d, because that is the _right_ thing. It is *not* unsigned, even > if fix_mac_speed() thinks that it is. It isn't. It's signed, and it's > stmmac bollocks implicitly casting it to unsigned - and that is > _wrong_. Yes, stmmac is wrong in casting it to the unsigned type, but even seeing the original type is intended to be signed doesn't mean the qualifier should be fixed separately from the variables type and function prototypes. It will cause even more confusion. IMO the best way would be to fix the plat_stmmacenet_data->fix_mac_speed() prototype and the respective methods in the glue drivers. But it would be too bulky and most likely out of your interest to be done. So I would still have the variables type and the format qualifier type matching here and in the rest of the drivers especially seeing the original code in the imx, starfive, rk, QoS Eth LLDDs sticks to the convention described by me. -Serge(y) > > So, on that point, my original submission was more correct than this > one, and you led me astray. > > -- > 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
next prev parent reply other threads:[~2023-09-14 15:22 UTC|newest] Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-09-14 13:50 [PATCH net-next v2 0/6] net: stmmac: add and use library for setting clock Russell King (Oracle) 2023-09-14 13:50 ` Russell King (Oracle) 2023-09-14 13:51 ` [PATCH net-next 1/6] net: stmmac: add stmmac_set_tx_clk_gmii() Russell King (Oracle) 2023-09-14 13:51 ` Russell King (Oracle) 2023-09-14 14:54 ` Serge Semin 2023-09-14 14:54 ` Serge Semin 2023-09-14 15:12 ` Russell King (Oracle) 2023-09-14 15:12 ` Russell King (Oracle) 2023-09-14 16:06 ` Serge Semin 2023-09-14 16:06 ` Serge Semin 2023-09-14 13:51 ` [PATCH net-next 2/6] net: stmmac: imx: use stmmac_set_tx_clk_gmii() Russell King (Oracle) 2023-09-14 13:51 ` Russell King (Oracle) 2023-09-14 14:59 ` Serge Semin 2023-09-14 14:59 ` Serge Semin 2023-09-14 13:51 ` [PATCH net-next 3/6] net: stmmac: intel-plat: " Russell King (Oracle) 2023-09-14 13:51 ` Russell King (Oracle) 2023-09-14 15:00 ` Serge Semin 2023-09-14 15:00 ` Serge Semin 2023-09-14 13:51 ` [PATCH net-next 4/6] net: stmmac: rk: " Russell King (Oracle) 2023-09-14 13:51 ` Russell King (Oracle) 2023-09-14 14:37 ` Serge Semin 2023-09-14 14:37 ` Serge Semin 2023-09-14 15:03 ` Russell King (Oracle) 2023-09-14 15:03 ` Russell King (Oracle) 2023-09-14 15:22 ` Serge Semin [this message] 2023-09-14 15:22 ` Serge Semin 2023-09-14 15:27 ` Russell King (Oracle) 2023-09-14 15:27 ` Russell King (Oracle) 2023-09-14 15:30 ` Russell King (Oracle) 2023-09-14 15:30 ` Russell King (Oracle) 2023-09-14 16:01 ` Jose Abreu 2023-09-14 16:01 ` Jose Abreu 2023-09-14 17:05 ` Serge Semin 2023-09-14 17:05 ` Serge Semin 2023-09-15 8:38 ` Jose Abreu 2023-09-15 8:38 ` Jose Abreu 2023-09-16 20:17 ` Serge Semin 2023-09-16 20:17 ` Serge Semin 2023-09-14 13:51 ` [PATCH net-next 5/6] net: stmmac: starfive: " Russell King (Oracle) 2023-09-14 13:51 ` Russell King (Oracle) 2023-09-14 15:04 ` Serge Semin 2023-09-14 15:04 ` Serge Semin 2023-09-14 13:51 ` [PATCH net-next 6/6] net: stmmac: qos-eth: " Russell King (Oracle) 2023-09-14 13:51 ` Russell King (Oracle)
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=rene2x562lqsknmwpaxpu337mhl4bgynct6vcyryebvem2umso@2pjocnxluxgg \ --to=fancer.lancer@gmail.com \ --cc=alexandre.torgue@foss.st.com \ --cc=ast@kernel.org \ --cc=bpf@vger.kernel.org \ --cc=daniel@iogearbox.net \ --cc=davem@davemloft.net \ --cc=edumazet@google.com \ --cc=festevam@gmail.com \ --cc=hawk@kernel.org \ --cc=joabreu@synopsys.com \ --cc=john.fastabend@gmail.com \ --cc=kernel@esmil.dk \ --cc=kernel@pengutronix.de \ --cc=kuba@kernel.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-imx@nxp.com \ --cc=linux-stm32@st-md-mailman.stormreply.com \ --cc=linux@armlinux.org.uk \ --cc=mcoquelin.stm32@gmail.com \ --cc=netdev@vger.kernel.org \ --cc=pabeni@redhat.com \ --cc=s.hauer@pengutronix.de \ --cc=samin.guo@starfivetech.com \ --cc=shawnguo@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.