Re: [PATCH v3 2/4] rtc: stm32: add pinctrl and pinmux interfaces

From: Linus Walleij
Date: Fri Jul 26 2024 - 16:47:01 EST


On Mon, Jul 22, 2024 at 6:02 PM Valentin Caron
<valentin.caron@xxxxxxxxxxx> wrote:

> STM32 RTC is capable to handle 3 specific pins of the soc.
> "out1, out2 and out2_rmp". To handle this, we use pinctrl framework.
> There is a single pin per group.
>
> Signed-off-by: Valentin Caron <valentin.caron@xxxxxxxxxxx>
(...)

> +/* STM32 RTC pinctrl helpers */
> +#define STM32_RTC_PINMUX(_name, _action, ...) { \
> + .name = (_name), \
> + .action = (_action), \
> + .groups = ((const char *[]){ __VA_ARGS__ }), \
> + .num_groups = ARRAY_SIZE(((const char *[]){ __VA_ARGS__ })), \
> +}

This is a very clever and clean macro.

We have PINCTRL_PINFUNCTION() in <linux/pinctrl/pinctrl.h> which isn't
smart enough to use VA_ARGS and ARRAY_SIZE.

Now you also need .action but if it wasn't for that I would have asked
for the macro to be made generic.

The implementation is clean and impeccable.
Reviewed-by: Linus Walleij <linus.walleij@xxxxxxxxxx>

Yours,
Linus Walleij