Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: "Geert Uytterhoeven" <geert+renesas@glider.be>
To: "Diogo Ivo" <diogo.ivo.sx@renesas.com>
Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	linux-clk@vger.kernel.org, linux-gpio@vger.kernel.org,
	"claudiu beznea" <claudiu.beznea@tuxon.dev>,
	"Wolfram Sang" <wsa+renesas@sang-engineering.com>,
	"Tommaso Merciai" <tommaso.merciai.xr@bp.renesas.com>,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	"Frank Li" <Frank.Li@nxp.com>, "Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Magnus Damm" <magnus.damm@gmail.com>,
	"Stephen Boyd" <sboyd@kernel.org>,
	"Brian Masney" <bmasney+clk@redhat.com>,
	"Jerome Brunet" <jbrunet+clk@baylibre.com>,
	"Linus Walleij" <linusw@kernel.org>
Subject: Re: [PATCH v2 5/7] pinctrl: renesas: rzg2l: Split SoC-specific masks in struct rzg2l_register_masks
Date: Thu, 03 Dec 2026 11:10:21 +0100	[thread overview]
Message-ID: <91df9c96-b023-4717-a476-e500034ec9ea@app.fastmail.com> (raw)
In-Reply-To: <5689301f-f7b0-43ce-9555-22faa7af965d@renesas.com>

Hi Diogo,

Thanks for your patch!

On Fri, Nov 27, 2026, at 15:03, Diogo Ivo wrote:
> On 11/27/2026 10:16 AM, claudiu beznea wrote:
>> On 10/26/26 13:35, Diogo Ivo wrote:
>>> struct rzg2l_register_masks declares the masks of the OTHER_POC register
>>> of RZ/G3L and of the I3C_SET_POC register of RZ/G3S in two branches of an
>>> anonymous union. As both branches share the same storage, initializing 
>>> both
>>> other_poc_pvdd1833_oth_awo_poc and i3c_set_poc on RZ/G3L would have the
>>> designated initializers override each other, ending up with the 
>>> I3C_SET_POC
>>> value in the PVDD1833_OTH_AWO_POC mask.
>>>
>>> Split the union into a common area, for masks shared by multiple SoCs, 
>>> and
>>> per-SoC areas: the RZ/G3S and RZ/G3L I3C_SET_POC mask moves to the common
>>> area, and the RZ/G3L OTHER_POC masks stay in a dedicated RZ/G3L area. 
>>> This
>>> way every mask gets its own member,
>> 
>>  > and new SoCs can be described by> adding their own struct
>>> (possibly inside a union).
>> 
>> That may be missed by the next person adding it...
>
> Ack, that is a good point. I will add it to v2 if Geert is ok with this 
> approach.
>
>>>
>>> The existing RZ/G3S data only initializes i3c_set_poc, so it is not
>>> affected by this change.
>>>
>>> Signed-off-by: Diogo Ivo <diogo.ivo.sx@renesas.com>

>>> --- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c
>>> +++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c
>>> @@ -278,18 +278,14 @@ struct rzg2l_register_offsets {
>>>    * @i3c_set_poc: I3C_SET_POC mask
>>>    */
>>>   struct rzg2l_register_masks {
>>> -    union {
>>> -        /* RZ/G3L masks */
>>> -        struct {
>>> -            u8 other_poc_pvdd1833_oth_awo_poc;
>>> -            u8 other_poc_pvdd1833_oth_iso_poc;
>>> -            u8 other_poc_wdtovf_n_poc;
>>> -        };
>>> -
>>> -        /* RZ/G3S masks */
>>> -        struct {
>>> -            u8 i3c_set_poc;
>>> -        };
>>> +    /* Masks common to multiple SoCs */
>>> +    u8 i3c_set_poc; /* RZ/G3S, RZ/G3L */
>> 
>> I would drop the names of the SoCs close to the i3c_set_poc. That have 
>> the opportunity to grow over time. As Geert considers better.
>
> Ok, I will wait for feedback here then but I am ok with dropping the SoC 
> names.

Agreed.

>>> +
>>> +    /* RZ/G3L masks */
>>> +    struct {
>>> +        u8 other_poc_pvdd1833_oth_awo_poc;
>>> +        u8 other_poc_pvdd1833_oth_iso_poc;
>>> +        u8 other_poc_wdtovf_n_poc;
>>>       };
>> 
>> OK, we can drop the union but the next SoC addition may be:
>> 
>> /* New SoC masks */
>> struct {
>>      u8 x;
>>      u8 y;
>> };
>> 
>> If we want to keep the initial form we may need to pay attention.
>> 
>> Patch is OK for me, just with the mention that we need to pay attention 
>> if we want to keep, for the future, the approach before this patch.
>
> Ok, then if Geert is ok with removing the union for now and possibly 
> reviving it later I will state this clearly in the commit message.

All of this looks rather fragile and suboptimal to me.

The union avoids wasting space.  However, as soon as a member is
needed on more than one SoC, you have to move it to the common area,
and it starts wasting space again for all the SoCs that don't need it.
Of course that is just about the data: you are still wasting space
for the code that handles data you don't need.
As the waste of data is only a few bytes per SoC, does it matter
that much?

Gr{oetje,eeting}s,

                                                Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                                            -- Linus Torvalds

  reply	other threads:[~2026-12-03 10:10 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26 11:35 [PATCH v2 0/7] i3c: renesas: Add RZ/G3L support Diogo Ivo
2026-10-26 11:35 ` [PATCH v2 1/7] i3c: renesas: Fix zero I2C SCL rate on pure I3C buses Diogo Ivo
2026-10-26 20:24   ` Frank Li
2026-11-27  9:12   ` claudiu beznea
2026-11-27 13:51     ` Diogo Ivo
2026-12-02 10:21       ` claudiu beznea
2026-10-26 11:35 ` [PATCH v2 2/7] i3c: renesas: Drop comma after OF match table sentinel Diogo Ivo
2026-11-27  9:17   ` claudiu beznea
2026-10-26 11:35 ` [PATCH v2 3/7] dt-bindings: i3c: renesas,i3c: Add RZ/G3L support Diogo Ivo
2026-10-28 11:30   ` Krzysztof Kozlowski
2026-11-01 20:25   ` Wolfram Sang
2026-10-26 11:35 ` [PATCH v2 4/7] clk: renesas: r9a08g046: Add I3C clocks and resets Diogo Ivo
2026-11-02 15:34   ` Geert Uytterhoeven
2026-10-26 11:35 ` [PATCH v2 5/7] pinctrl: renesas: rzg2l: Split SoC-specific masks in struct rzg2l_register_masks Diogo Ivo
2026-11-27  9:16   ` claudiu beznea
2026-11-27 14:03     ` Diogo Ivo
2026-12-03 10:10       ` Geert Uytterhoeven [this message]
2026-10-26 11:35 ` [PATCH v2 6/7] pinctrl: renesas: rzg2l: Add RZ/G3L support for selecting I3C power source Diogo Ivo
2026-11-27  9:17   ` claudiu beznea
2026-12-03 10:23   ` Geert Uytterhoeven
2026-10-26 11:35 ` [PATCH v2 7/7] arm64: dts: renesas: r9a08g046: Add I3C support Diogo Ivo
2026-11-01 20:34   ` Wolfram Sang
2026-11-25 10:12 ` [PATCH v2 0/7] i3c: renesas: Add RZ/G3L support Diogo Ivo

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=91df9c96-b023-4717-a476-e500034ec9ea@app.fastmail.com \
    --to=geert+renesas@glider.be \
    --cc=Frank.Li@nxp.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=bmasney+clk@redhat.com \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=diogo.ivo.sx@renesas.com \
    --cc=jbrunet+clk@baylibre.com \
    --cc=krzk+dt@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-i3c@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=robh@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=tommaso.merciai.xr@bp.renesas.com \
    --cc=wsa+renesas@sang-engineering.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