From: David Laight <david.laight.linux@gmail.com>
To: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Cc: "Yury Norov" <ynorov@nvidia.com>, "Andrew Lunn" <andrew@lunn.ch>,
"Vladimir Oltean" <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Simon Horman" <horms@kernel.org>,
"Linus Walleij" <linusw@kernel.org>,
"Alvin Šipraga" <alsi@bang-olufsen.dk>,
"Yury Norov" <yury.norov@gmail.com>,
"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
"Russell King" <linux@armlinux.org.uk>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [net-next PATCH 04/10] bitfield.h: add FIELD_WIDTH()
Date: Sat, 4 Apr 2026 16:12:11 +0100 [thread overview]
Message-ID: <20260404161211.47d8a05b@pumpkin> (raw)
In-Reply-To: <CAJq09z5kMu4ANp3n2Q0C1j8TULdCKW_yPM=nN78mNupAt51YGQ@mail.gmail.com>
On Fri, 3 Apr 2026 11:09:30 -0300
Luiz Angelo Daros de Luca <luizluca@gmail.com> wrote:
> Thanks David and Yuri,
>
> This patch was originally intended to reconstruct a value split across
> multiple registers. Originally:
>
> vlan4k->member =
> FIELD_GET(RTL8365MB_CVLAN_ENTRY_D0_MBR_MASK, data[0]) |
> (FIELD_GET(RTL8365MB_CVLAN_ENTRY_D2_MBR_EXT_MASK, data[2])
> << FIELD_WIDTH(RTL8365MB_CVLAN_ENTRY_D0_MBR_MASK));
That calculation isn't even really correct.
It is only right if the low bit of the last mask is set.
I'm not a big fan of FIELD_GET/PREP - they have their use, but get
overused.
David
>
> However, as Yuri pointed out, I can use FIELD_PREP() to align the bits
> into the final struct member without manual bitops. While less common,
> this pattern is used elsewhere (e.g., drivers/clk/clk-lmk04832.c). The
> updated approach would be:
>
> vlan4k->member =
> FIELD_PREP(RTL8365MB_CVLAN_MBR_LO_MASK,
> FIELD_GET(RTL8365MB_CVLAN_ENTRY_D0_MBR_MASK,
> data[0])) |
> FIELD_PREP(RTL8365MB_CVLAN_MBR_HI_MASK,
>
> FIELD_GET(RTL8365MB_CVLAN_ENTRY_D2_MBR_EXT_MASK, data[2]));
>
> If this use of FIELD_PREP is preferred, I will drop this FIELD_WIDTH
> patch from the series as it would no longer have any users.
>
> Regards,
>
> Luiz
>
next prev parent reply other threads:[~2026-04-04 15:12 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 23:00 [net-next PATCH 00/10] net: dsa: realtek: rtl8365mb: bridge offloading and VLAN support Luiz Angelo Daros de Luca
2026-03-31 23:00 ` [net-next PATCH 01/10] net: dsa: tag_rtl8_4: update format description Luiz Angelo Daros de Luca
2026-03-31 23:00 ` [net-next PATCH 02/10] net: dsa: realtek: rtl8365mb: set STP state to disabled early Luiz Angelo Daros de Luca
2026-03-31 23:00 ` [net-next PATCH 03/10] net: dsa: realtek: rtl8365mb: prepare for multiple source files Luiz Angelo Daros de Luca
2026-03-31 23:00 ` [net-next PATCH 04/10] bitfield.h: add FIELD_WIDTH() Luiz Angelo Daros de Luca
2026-04-01 2:15 ` Yury Norov
2026-04-02 4:00 ` Luiz Angelo Daros de Luca
2026-04-02 9:27 ` David Laight
2026-04-02 13:52 ` Yury Norov
2026-04-02 22:21 ` David Laight
2026-04-03 14:09 ` Luiz Angelo Daros de Luca
2026-04-03 16:18 ` Yury Norov
2026-04-04 14:54 ` David Laight
2026-04-04 15:12 ` David Laight [this message]
2026-04-02 13:45 ` Yury Norov
2026-03-31 23:00 ` [net-next PATCH 05/10] net: dsa: realtek: rtl8365mb: add table lookup interface Luiz Angelo Daros de Luca
2026-03-31 23:00 ` [net-next PATCH 06/10] net: dsa: realtek: rtl8365mb: add VLAN support Luiz Angelo Daros de Luca
2026-04-01 2:27 ` Yury Norov
2026-04-02 2:45 ` Luiz Angelo Daros de Luca
2026-04-02 14:22 ` Yury Norov
2026-03-31 23:00 ` [net-next PATCH 07/10] net: dsa: realtek: rtl8365mb: add port_bridge_{join,leave} Luiz Angelo Daros de Luca
2026-03-31 23:00 ` [net-next PATCH 08/10] net: dsa: realtek: rtl8365mb: add FDB support Luiz Angelo Daros de Luca
2026-03-31 23:00 ` [net-next PATCH 09/10] net: dsa: realtek: rtl8365mb: add bridge port flags Luiz Angelo Daros de Luca
2026-03-31 23:00 ` [net-next PATCH 10/10] net: dsa: tag_rtl8_4: set KEEP flag Luiz Angelo Daros de Luca
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=20260404161211.47d8a05b@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=alsi@bang-olufsen.dk \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linux@rasmusvillemoes.dk \
--cc=luizluca@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=ynorov@nvidia.com \
--cc=yury.norov@gmail.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