Re: [PATCH INTERNAL v1 2/3] pinctrl: tps6594: add for TPS6594 PMIC

From: Esteban Blanc
Date: Tue Mar 14 2023 - 13:30:56 EST


Hi Linus,

On Mon Mar 6, 2023 at 3:10 PM CET, Linus Walleij wrote:
> On Fri, Feb 24, 2023 at 2:31 PM Esteban Blanc <eblanc@xxxxxxxxxxxx> wrote:

> > TI TPS6594 PMIC has 11 GPIOs which can be used for different
> > functions
> >
> > This add a pinctrl and pinmux drivers in order to use those functions
> >
> > Signed-off-by: Esteban Blanc <eblanc@xxxxxxxxxxxx>
>
> > +config PINCTRL_TPS6594
> > + tristate "Pinctrl and GPIO driver for TI TPS6594 PMIC"
> > + depends on MFD_TPS6594
>
> I would add:
>
> default MFD_TPS6594
>
> so you always get this as module or built in along with the MFD.
> Otherwise Kconfig gets complicated and tedious for users.

I did not know this, thanks. I will add this to V2.

(...)

> > +#define DEBUG
>
> Don't put this in production code.
>
> Look in drivers/pinctrl/Kconfig.
>
> config DEBUG_PINCTRL
> bool "Debug PINCTRL calls"
> depends on DEBUG_KERNEL
> help
> Say Y here to add some extra checks and diagnostics to PINCTRL calls.
>
> Look in drivers/pinctrl/Makefile:
>
> subdir-ccflags-$(CONFIG_DEBUG_PINCTRL) += -DDEBUG
>
> Nifty eh? :D

Nifty indeed :D. #define DEBUG will be removed for V2, I should have
noticed it for V1...

> > +static const struct tps6594_pinctrl_function pinctrl_functions[] = {
> (...)
> > + { "scl_i2c2-cs_spi", TPS6594_PINCTRL_SCL_I2C2_CS_SPI_FUNCTION,
> > + (const char *[]){ "GPIO0", "GPIO1" }, 2 },
>
> Ow this is starting to look hairy.
>
> Is there some better way to get here?

I tried with a macro but I was not able to pass an array directly to
avoid both the cast and the hard coded length. I saw on other drivers
that I could generate the table dynamically but I'm not a huge fan of that
and I feel like it would look even more clunky...

>
> Other than this the code looks very nice.
>
> Yours,
> Linus Walleij