Re: [PATCH v3 0/9] gpio: mxc: bug fixes and probe cleanup

From: Peng Fan

Date: Tue Oct 06 2026 - 08:40:08 EST


Ignore this V3 patchset. This is not a complete version.

Thanks
Peng

On Tue, Oct 06, 2026 at 08:31:05PM +0800, Peng Fan (OSS) wrote:
>This series cleans up the gpio-mxc driver in several incremental steps:
>bug fixes, converting runtime state to static per-compatible data,
>modernizing resource management with devres, and cleaning up
>register access patterns.
>
>Patches 1-2 are bug fixes:
> - Fix a race where the chained IRQ handler is installed before probe
> completes, allowing interrupts to fire on a half-initialized port.
> - Fix wakeup_pads bit operations that used wrong set_bit/clear_bit
> logic, folding in the assign_bit() simplification from V1.
>
>Patches 3-4 replace runtime of_device_is_compatible() calls with static
>per-compatible hwdata flags, eliminating repeated string comparisons in
>the suspend/resume path.
>
>Patches 5-6 convert probe error handling to devres and dev_err_probe().
>
>Patches 7-9 are cosmetic cleanups: local dev variable, MXC_ICR macros
>with field_prep/field_get, and BIT() macro for single-bit shifts.
>
>Signed-off-by: Peng Fan <peng.fan@xxxxxxx>
>---
>Changes in v3:
>- Patch 5/8 ("gpio: mxc: convert probe error handling to devres"):
> Replaced pm_runtime_get_noresume() with
> devm_pm_runtime_get_noresume() to fix a PM usage counter leak on
> probe error paths. The non-devm pm_runtime_get_noresume() was not
> balanced by any devres action, so any probe failure after the PM
> block (e.g. -EPROBE_DEFER from devm_gpiochip_add_data()) would
> leave usage_count permanently elevated, preventing runtime suspend
> on re-probe.
> Dropped the explicit pm_runtime_put_noidle() on
> devm_pm_runtime_set_active_enabled() failure - the devres
> registered by devm_pm_runtime_get_noresume() handles the balance
> automatically during probe unwind.
>- Patch 6/8 ("gpio: mxc: use local dev variable"):
> Keep of_device_is_compatible(), only focus on switching &pdev->dev to
> dev.
>- Link to v2: https://patch.msgid.link/20261005-gpio-mxc-cleanup-v2-0-bdc3afbb35e2@xxxxxxx
>
>Changes in V2:
>- Reworked compatible-string caching (V1 patch 3) from probe-time bools
> in mxc_gpio_port to static hwdata flags with per-compatible data
> instances. Split into two patches: one introducing the flags scheme
> with MXC_GPIO_HW_DATA_COMMON macro for power_off (patch 3), one
> extending it to pad_wakeup and imx8qm (patch 4). (Frank, bot review)
>- Replaced devm_pm_runtime_get_noresume() + pm_runtime_set_active() +
> devm_pm_runtime_enable() with devm_pm_runtime_set_active_enabled().
> Keep plain pm_runtime_get_noresume() (non-devm) for the probe-scoped
> reference to avoid usage_count underflow on unbind. (Frank, bot review)
>- Replaced irq_domain_create_legacy() + devm_add_action_or_reset() with
> devm_irq_domain_instantiate(). Squashed with the PM runtime devres
> conversion (V1 patches 4+5) into a single patch (patch 5), since the
> goto labels cannot be removed until both resources are devres-managed.
>- Split dev_err_probe() conversion into its own patch (patch 6) for
> bisectability — patch 5 uses bare returns with correct error values.
>- Folded gpio_set_wake_irq() assign_bit simplification (V1 patch 9) into
> the wakeup_pads fix (patch 2) where it belongs.
>- Used 0x3U (unsigned) in MXC_ICR_MASK() to avoid implementation-defined
> behavior when shifting by 30 bits.
>- Replaced linux/of.h with linux/property.h to match the
> of_device_is_compatible() → device_is_compatible() API change (patch 7).
>- Added return-value checks for devm_pm_runtime_set_active_enabled().
>- Fixed stale error code returns after devm_irq_alloc_descs() and
> devm_irq_domain_instantiate() in the devres conversion patch.
>- Link to v1: https://patch.msgid.link/20261003-gpio-mxc-cleanup-v1-0-dad728ce27f2@xxxxxxx
>
>---
>Peng Fan (9):
> gpio: mxc: fix race between chained IRQ handler install and probe completion
> gpio: mxc: fix wakeup_pads bit operations
> gpio: mxc: replace of_device_is_compatible() with hwdata flags
> gpio: mxc: convert pad wakeup compatible checks to hwdata flags
> gpio: mxc: convert probe error handling to devres
> gpio: mxc: switch probe error paths to dev_err_probe()
> gpio: mxc: use local dev variable
> gpio: mxc: introduce MXC_ICR macros and use field_prep/field_get
> gpio: mxc: use BIT() macro for single-bit operations
>
> drivers/gpio/gpio-mxc.c | 257 +++++++++++++++++++++++++++---------------------
> 1 file changed, 145 insertions(+), 112 deletions(-)
>---
>base-commit: f0406245cb9855e6318335a8a223551354291a46
>change-id: 20261003-gpio-mxc-cleanup-e49cc626c51e
>
>Best regards,
>--
>Peng Fan <peng.fan@xxxxxxx>
>
>