[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZQMmV2pSCAX8AJzz@shell.armlinux.org.uk>
Date: Thu, 14 Sep 2023 16:27:19 +0100
From: "Russell King (Oracle)" <linux@...linux.org.uk>
To: Serge Semin <fancer.lancer@...il.com>
Cc: Alexandre Torgue <alexandre.torgue@...s.st.com>,
Jose Abreu <joabreu@...opsys.com>,
Alexei Starovoitov <ast@...nel.org>, bpf@...r.kernel.org,
Daniel Borkmann <daniel@...earbox.net>,
"David S. Miller" <davem@...emloft.net>,
Emil Renner Berthing <kernel@...il.dk>,
Eric Dumazet <edumazet@...gle.com>,
Fabio Estevam <festevam@...il.com>,
Jakub Kicinski <kuba@...nel.org>,
Jesper Dangaard Brouer <hawk@...nel.org>,
John Fastabend <john.fastabend@...il.com>,
linux-arm-kernel@...ts.infradead.org,
linux-stm32@...md-mailman.stormreply.com,
Maxime Coquelin <mcoquelin.stm32@...il.com>, netdev@...r.kernel.org,
NXP Linux Team <linux-imx@....com>, Paolo Abeni <pabeni@...hat.com>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Samin Guo <samin.guo@...rfivetech.com>,
Sascha Hauer <s.hauer@...gutronix.de>,
Shawn Guo <shawnguo@...nel.org>
Subject: Re: [PATCH net-next 4/6] net: stmmac: rk: use
stmmac_set_tx_clk_gmii()
On Thu, Sep 14, 2023 at 06:22:33PM +0300, Serge Semin wrote:
> 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@...linux.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.
I won't be doing that, sorry. If that's not acceptable, then I'm
junking this series.
What I will be doing is getting rid of as many users of fix_mac_speed()
as possible, but that's for a future patch series.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Powered by blists - more mailing lists