Re: [PATCH v1 1/2] pinctrl: core: Allow drivers to keep "init" pinctrl state after probe

From: Andy Shevchenko

Date: Mon Aug 10 2026 - 14:15:59 EST


On Mon, Aug 10, 2026 at 01:06:34PM +0000, Michał Kardaś wrote:
> During device probe, pinctrl_bind_pins() binds pins to their "init" state
> if specified in Device Tree. When probe finishes, pinctrl_init_done()
> automatically transitions the pins from "init" to "default" state.
>
> While this auto-transition works well for devices that are immediately
> active upon driver binding, certain peripherals (such as power-sequenced
> devices connected over UART, SPI, or other buses) remain unpowered until
> userspace explicitly opens the device node or attaches a protocol driver.
>
> On board designs where the connected peripheral is kept unpowered during
> boot, auto-selecting "default" or "sleep" pin states (where signals such
> as TXD or RTS may be driven high or pulled up) can cause parasitic
> back-powering into the unpowered peripheral through its ESD protection
> diodes.
>
> Allow drivers to explicitly opt out of the automatic "init" -> "default"
> transition by calling pinctrl_keep_init_state(dev) during probe. When this
> helper is called, pinctrl_init_done() leaves the pins in their "init"
> state upon probe completion. The driver can then transition to the
> "default" state when the device is first opened by calling
> pinctrl_pm_select_default_state(dev).

...

> +/**
> + * pinctrl_keep_init_state() - mark pinctrl handle to stay in init state after probe
> + * @dev: device to keep init state for
> + *
> + * Return: true if the device has a valid init state and keep_init flag was set,
> + * false otherwise.
> + */
> +bool pinctrl_keep_init_state(struct device *dev)
> +{
> + if (!dev->pins || IS_ERR(dev->pins->init_state))
> + return false;

The above keeps_init in the initial state which may or may not be wrong.
I would avoid the ambiguity by rewriting this as

> + dev->pins->keep_init = true;
> + return true;

dev->pins->keep_init = dev->pins && !IS_ERR(dev->pins->init_state);

return dev->pins->keep_init;

But please, check if that is what you want.

> +}

...

> + bool keep_init:1;

What is ':1' supposed to mean (for boolean)? I understand that for say
unsigned int.

--
With Best Regards,
Andy Shevchenko