Re: [PATCH v2 5/7] pinctrl: renesas: rzg2l: Split SoC-specific masks in struct rzg2l_register_masks
From: Geert Uytterhoeven
Date: Thu Dec 03 2026 - 05:11:05 EST
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@xxxxxxxxxxx>
>>> --- 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@xxxxxxxxxxxxxx
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