devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guo Samin <samin.guo@starfivetech.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-riscv@lists.infradead.org>,
	<devicetree@vger.kernel.org>, <netdev@vger.kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>, Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Emil Renner Berthing <kernel@esmil.dk>,
	Jose Abreu <joabreu@synopsys.com>,
	Richard Cochran <richardcochran@gmail.com>,
	Conor Dooley <conor@kernel.org>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>, Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Peter Geis <pgwipeout@gmail.com>,
	Yanhong Wang <yanhong.wang@starfivetech.com>,
	Tommaso Merciai <tomm.merciai@gmail.com>
Subject: Re: [net-next v9 5/6] net: stmmac: Add glue layer for StarFive JH7110 SoC
Date: Wed, 29 Mar 2023 10:57:00 +0800	[thread overview]
Message-ID: <f8be0cf7-fe78-7e63-7fbc-78d083a9f186@starfivetech.com> (raw)
In-Reply-To: <20230328191716.18a302a1@kernel.org>


Re: [net-next v9 5/6] net: stmmac: Add glue layer for StarFive JH7110 SoC
From: Jakub Kicinski <kuba@kernel.org>
to: Samin Guo <samin.guo@starfivetech.com>
data: 2023/3/29

> On Tue, 28 Mar 2023 14:20:08 +0800 Samin Guo wrote:
>> This adds StarFive dwmac driver support on the StarFive JH7110 SoC.
>>
>> Tested-by: Tommaso Merciai <tomm.merciai@gmail.com>
>> Co-developed-by: Emil Renner Berthing <kernel@esmil.dk>
>> Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
>> Signed-off-by: Samin Guo <samin.guo@starfivetech.com>
> 
> Excellent, now it applies cleanly :)
> 
> Our clang build with W=1 complains that:
> 
> drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c:37:2: warning: variable 'rate' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
>         default:
>         ^~~~~~~
> drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c:42:36: note: uninitialized use occurs here
>         err = clk_set_rate(dwmac->clk_tx, rate);
>                                           ^~~~
> drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c:24:20: note: initialize the variable 'rate' to silence this warning
>         unsigned long rate;
>                           ^
>                            = 0
> 
> 
> not sure how you prefer to fix this. Maybe return early?

Hi Jakub,

Sorry, gcc I used does not report this error (:, and clang compile checks are more stringent.
Also, if return early at default node, Arun Ramadoss doesn't think it's a good idea because the function is a void type.

I think I can initialize the value of rate first by clk_get_rate (Intel did the same <dwmac-intel-plat.c: kmb_eth_fix_mac_speed >),
like this:


static void starfive_dwmac_fix_mac_speed(void *priv, unsigned int speed)
{
        struct starfive_dwmac *dwmac = priv;
        unsigned long rate;
        int err;

	rate = clk_get_rate(dwmac->tx_clk);

        switch (speed) {
        case SPEED_1000:
                rate = 125000000;
                break;
        case SPEED_100:
                rate = 25000000;
                break;
        case SPEED_10:
                rate = 2500000;
                break;
        default:
                dev_err(dwmac->dev, "invalid speed %u\n", speed);
                break;
        }   

        err = clk_set_rate(dwmac->clk_tx, rate);
        if (err)
                dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate);
}

What do you think?


Best regards,
Samin

  reply	other threads:[~2023-03-29  2:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-28  6:20 [net-next v9 0/6] Add Ethernet driver for StarFive JH7110 SoC Samin Guo
2023-03-28  6:20 ` [net-next v9 1/6] dt-bindings: net: snps,dwmac: Add dwmac-5.20 version Samin Guo
2023-03-28  6:20 ` [net-next v9 2/6] net: stmmac: platform: Add snps,dwmac-5.20 IP compatible string Samin Guo
2023-03-28  6:20 ` [net-next v9 3/6] dt-bindings: net: snps,dwmac: Add 'ahb' reset/reset-name Samin Guo
2023-03-28  6:20 ` [net-next v9 4/6] dt-bindings: net: Add support StarFive dwmac Samin Guo
2023-04-05  6:34   ` Krzysztof Kozlowski
2023-04-07  1:59     ` Guo Samin
2023-03-28  6:20 ` [net-next v9 5/6] net: stmmac: Add glue layer for StarFive JH7110 SoC Samin Guo
2023-03-29  2:17   ` Jakub Kicinski
2023-03-29  2:57     ` Guo Samin [this message]
2023-03-29  6:25       ` Jakub Kicinski
2023-03-28  6:20 ` [net-next v9 6/6] net: stmmac: starfive-dmac: Add phy interface settings Samin Guo

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=f8be0cf7-fe78-7e63-7fbc-78d083a9f186@starfivetech.com \
    --to=samin.guo@starfivetech.com \
    --cc=andrew@lunn.ch \
    --cc=aou@eecs.berkeley.edu \
    --cc=conor@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=joabreu@synopsys.com \
    --cc=kernel@esmil.dk \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=pgwipeout@gmail.com \
    --cc=richardcochran@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=tomm.merciai@gmail.com \
    --cc=yanhong.wang@starfivetech.com \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).