Re: [PATCH] pinctrl: pinconf-generic: widen the packed config argument to unsigned long
From: Bartosz Golaszewski
Date: Mon Nov 09 2026 - 11:13:25 EST
On Mon, Nov 09, 2026 at 08:27:55PM +0800, Peng Fan wrote:
> From: Peng Fan <peng.fan@xxxxxxx>
>
> The packed pin configuration stores the parameter in the lower 8 bits and
> the argument in the remaining bits of an unsigned long. However, the
> argument was limited to 24 bits: pinconf_to_config_argument() masked it
> with 0xffffff, and pinconf_to_config_packed() took a u32 argument, so even
> on 64-bit systems the left shift in PIN_CONF_PACKED() discarded the upper
> bits. For example, the pad configuration value 0x1080000 used by a new
> i.MX SoC was packed as 0x08000000 and read back as 0x80000.
>
> Allow the argument to use the full width of unsigned long so that such
> values survive the pack/unpack round trip. Cast the argument in
> PIN_CONF_PACKED() to unsigned long to keep direct users of the macro
> consistent with pinconf_to_config_packed(), and print the full argument
> in the debugfs dumps.
>
> The packed argument only has BITS_PER_LONG - 8 bits available, so on
> 32-bit systems values above 0xffffff still cannot be represented. Reject
> such firmware properties instead of silently truncating them.
>
> Signed-off-by: Peng Fan <peng.fan@xxxxxxx>
> ---
I think it makes sense.
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>