From: Andrew Lunn <andrew@lunn.ch>
To: "Jörg Sommer" <joerg@jo-so.de>
Cc: Dong Yibo <dong100@mucse.com>,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
corbet@lwn.net, gur.stavi@huawei.com, maddy@linux.ibm.com,
mpe@ellerman.id.au, danishanwar@ti.com, lee@trager.us,
gongfan1@huawei.com, lorenzo@kernel.org, geert+renesas@glider.be,
Parthiban.Veerasooran@microchip.com, lukas.bulwahn@redhat.com,
alexanderduyck@fb.com, richardcochran@gmail.com, kees@kernel.org,
gustavoars@kernel.org, rdunlap@infradead.org,
vadim.fedorenko@linux.dev, netdev@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH net-next v12 3/5] net: rnpgbe: Add basic mbx ops support
Date: Tue, 16 Sep 2025 21:33:36 +0200 [thread overview]
Message-ID: <5a942120-fe95-4d6a-a2cf-ef832f65343e@lunn.ch> (raw)
In-Reply-To: <7d4olrtuyagvcma5sspca6urmkjotkjtthbbekkeqltnd6mgq6@pn4smgsdaf4c>
> > + if (fw_req != 0 && fw_req != hw->mbx.fw_req) {
> > + hw->mbx.stats.reqs++;
> > + return 0;
> > + }
> > +
> > + return -EIO;
>
> Only a suggestion: Might it be clearer to flip the cases and handle the if
> as error case and continue with the success case?
>
> if (fw_req == 0 || fw_req == hw->mbx.fw_req)
> return -EIO;
>
> hw->mbx.stats.reqs++;
> return 0;
That would by the usual pattern in the kernel. It is good to follow
usual patterns.
> > +static void mucse_mbx_inc_pf_req(struct mucse_hw *hw)
> > +{
> > + struct mucse_mbx_info *mbx = &hw->mbx;
> > + u16 req;
> > + u32 val;
> > +
> > + val = mbx_data_rd32(mbx, MUCSE_MBX_PF2FW_CNT);
> > + req = FIELD_GET(GENMASK_U32(15, 0), val);
>
> Why not assign the values in the declaration like done with mbx?
Reverse Christmas tree.
struct mucse_mbx_info *mbx = &hw->mbx;
u32 val = mbx_data_rd32(mbx, MUCSE_MBX_PF2FW_CNT);
u16 req = FIELD_GET(GENMASK_U32(15, 0), val);
This is not reverse christmas tree. Sometimes you need to put
assignments into the body of the function.
Andrew
next prev parent reply other threads:[~2025-09-16 19:34 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-16 11:29 [PATCH net-next v12 0/5] Add driver for 1Gbe network chips from MUCSE Dong Yibo
2025-09-16 11:29 ` [PATCH net-next v12 1/5] net: rnpgbe: Add build support for rnpgbe Dong Yibo
2025-09-16 19:00 ` Jörg Sommer
2025-09-17 1:37 ` Yibo Dong
2025-09-17 7:01 ` MD Danish Anwar
2025-09-16 11:29 ` [PATCH net-next v12 2/5] net: rnpgbe: Add n500/n210 chip support with BAR2 mapping Dong Yibo
2025-09-16 19:20 ` Jörg Sommer
2025-09-17 7:02 ` MD Danish Anwar
2025-09-16 11:29 ` [PATCH net-next v12 3/5] net: rnpgbe: Add basic mbx ops support Dong Yibo
2025-09-16 18:42 ` Jörg Sommer
2025-09-16 19:33 ` Andrew Lunn [this message]
2025-09-17 2:55 ` Yibo Dong
2025-09-16 11:29 ` [PATCH net-next v12 4/5] net: rnpgbe: Add basic mbx_fw support Dong Yibo
2025-09-17 10:45 ` Vadim Fedorenko
2025-09-17 11:05 ` Yibo Dong
2025-09-17 14:02 ` Vadim Fedorenko
2025-09-19 1:17 ` Yibo Dong
2025-09-16 11:29 ` [PATCH net-next v12 5/5] net: rnpgbe: Add register_netdev Dong Yibo
2025-09-16 15:19 ` Vadim Fedorenko
2025-09-17 7:09 ` MD Danish Anwar
2025-09-17 8:33 ` Yibo Dong
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=5a942120-fe95-4d6a-a2cf-ef832f65343e@lunn.ch \
--to=andrew@lunn.ch \
--cc=Parthiban.Veerasooran@microchip.com \
--cc=alexanderduyck@fb.com \
--cc=andrew+netdev@lunn.ch \
--cc=corbet@lwn.net \
--cc=danishanwar@ti.com \
--cc=davem@davemloft.net \
--cc=dong100@mucse.com \
--cc=edumazet@google.com \
--cc=geert+renesas@glider.be \
--cc=gongfan1@huawei.com \
--cc=gur.stavi@huawei.com \
--cc=gustavoars@kernel.org \
--cc=horms@kernel.org \
--cc=joerg@jo-so.de \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=lee@trager.us \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=lukas.bulwahn@redhat.com \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rdunlap@infradead.org \
--cc=richardcochran@gmail.com \
--cc=vadim.fedorenko@linux.dev \
/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
all inboxes | Powered by JetHome®