mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v7 00/12] gpio: mxc: probe cleanup
@ 2026-10-27 12:09 Peng Fan (OSS)
  2026-10-27 12:09 ` [PATCH v7 01/12] gpio: mxc: use irq_set_irq_wake() to simplify code Peng Fan (OSS)
                   ` (11 more replies)
  0 siblings, 12 replies; 20+ messages in thread
From: Peng Fan (OSS) @ 2026-10-27 12:09 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Frank Li, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam
  Cc: linux-kernel, linux-gpio, imx, linux-arm-kernel, Peng Fan,
	Andy Shevchenko

This is the cleanup portion of the gpio-mxc series, following the bug
fixes merged in [1].

For Linus's comment in [2], I will use a follow up patch set to
update pinctrl-imx and gpio-mxc.

Patches 1-2 are wakeup_pads cleanups: consolidate enable/disable_irq_wake
into irq_set_irq_wake(), and use for_each_set_bit() for the pad wakeup
iteration.

Patch 3 fixes bare 'unsigned' to 'unsigned int' per coding style.

Patches 4-5 replace runtime of_device_is_compatible() calls with static
per-compatible hwdata flags, eliminating repeated string comparisons in
the suspend/resume path.

Patch 6 introduces a local dev variable for readability.

Patch 7 uses a driver-local cleanup guard to disable runtime PM and drop
the probe-scoped pm_runtime_get_noresume() reference on error paths.

Patch 8 converts the remaining probe resources to devres.

Patch 9 switches selected probe error paths to dev_err_probe().

Patches 10-11 are cosmetic: MXC_ICR macros with icr_update_edge()/
icr_get_edge() helpers using field_prep/field_get, and BIT() macro for
single-bit shifts.

Patch 12 adds a maintainer entry for the driver.

[1] https://lore.kernel.org/all/179206687877.10309.9401675786609225009.b4-ty@oss.qualcomm.com/#r
[2] https://lore.kernel.org/all/CAD++jL=tKnT0qr5chD-fhxgTM-f9kcdFRsKVBbbqionBp9iTyw@mail.gmail.com/

Changes in v7:
- Drop the three bug-fix patches merged separately; this series contains
  cleanup patches only.
- New patch 3: fix bare 'unsigned' to 'unsigned int' (Andy Shevchenko).
- Patch 7: combine pm_runtime_disable() and pm_runtime_put_noidle() into
  a driver-local cleanup guard, so runtime PM is disabled before the
  probe reference is dropped. Keep the cleanup helper local to gpio-mxc
  instead of adding it to pm_runtime.h.
- Patch 8: convert the remaining probe resources to devres and drop the
  devm_pm_runtime_set_active_enabled() conversion; runtime PM stays
  non-managed.
- Patch 9: also use dev_err_probe() for the platform_irq_count() and
  devm_clk_get_optional_enabled() failures, while leaving helpers that
  already report errors alone.
- Patch 12: add a MAINTAINERS entry for gpio-mxc.
- Link to v6: https://lore.kernel.org/all/20261011-gpio-mxc-cleanup-v6-0-cb47ce2ad758@nxp.com/

Changes in v6:
- Patch 9: use retain_and_null_ptr() instead of no_free_ptr() to disarm
  the pm_runtime cleanup guard, as the return value is unused (Frank Li).
- Minor commit message rewording for patches 10-12.
- Collect R-b from Frank Li.
- Link to v5: https://patch.msgid.link/20261010-gpio-mxc-cleanup-v5-0-1e59e6ddfa00@nxp.com

Changes in v5:
- New patch 2: fix both_edges race using atomic bitops (set_bit/
  clear_bit/test_bit), prompted by review feedback on the BIT() patch.
- Patch 3 (wakeup_pads fix): split the irq_set_irq_wake()
  consolidation and for_each_set_bit() conversion into separate cleanup
  patches (4-5) for bisectability.
- Patch 7 (pad wakeup hwdata): renamed MXC_GPIO_IS_IMX8QM to
  MXC_GPIO_FALL_EDGE_WAKEUP_BROKEN to describe the property, not the
  SoC.
- Patch 9 (new): use __free cleanup guard for pm_runtime_get_noresume()
  balance instead of devm_pm_runtime_get_noresume(), which would cause a
  usage counter underflow on unbind due to the double put (devres +
  success-path pm_runtime_put_autosuspend).
- Patch 10 (devres): dropped devm_pm_runtime_get_noresume(); the __free
  guard from patch 9 handles the usage counter balance.  Fixed stale
  &pdev->dev references that should use the local dev variable.
- Patch 11 (dev_err_probe): fixed &pdev->dev references to use dev.
- Reordered series: moved "use local dev variable" before the devres
  and dev_err_probe patches so the local variable is available.
- Link to v4: https://patch.msgid.link/20261007-gpio-mxc-cleanup-v4-0-c9f5a8b50df9@nxp.com

Changes in v4:
- Just a resend of V3 with below changes.
  Add R-b from Linus for patch 10.
  Update commit for patch 2 and drop empty line and separate
  for_each_set_bit changes into a new patch Per Andy.
- Link to v3: https://lore.kernel.org/all/20261006-gpio-mxc-cleanup-v3-0-129f93302a90@nxp.com/

Changes in v3:
- Patch ("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 ("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@nxp.com

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@nxp.com

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
Peng Fan (12):
      gpio: mxc: use irq_set_irq_wake() to simplify code
      gpio: mxc: use for_each_set_bit() to iterate wakeup pads
      gpio: mxc: use 'unsigned int' instead of bare 'unsigned'
      gpio: mxc: replace of_device_is_compatible() with hwdata flags
      gpio: mxc: convert pad wakeup compatible checks to hwdata flags
      gpio: mxc: use local dev variable
      gpio: mxc: use __free guard for runtime PM cleanup
      gpio: mxc: use devres functions to simplify probe code
      gpio: mxc: add dev_err_probe() for error paths to help diagnostics
      gpio: mxc: introduce MXC_ICR macros and use field_prep/field_get
      gpio: mxc: use BIT() macro for single-bit operations
      MAINTAINERS: Add an entry for gpio-mxc

 MAINTAINERS             |   8 ++
 drivers/gpio/gpio-mxc.c | 295 ++++++++++++++++++++++++++++--------------------
 2 files changed, 181 insertions(+), 122 deletions(-)
---
base-commit: f1ac44c32cba88ad65dcecd4a279661d14e93651
change-id: 20261027-gpio-mxc-cleanup-v7-4-f1163de27591

Best regards,
--  
Peng Fan <peng.fan@nxp.com>


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2026-10-27 16:36 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-27 12:09 [PATCH v7 00/12] gpio: mxc: probe cleanup Peng Fan (OSS)
2026-10-27 12:09 ` [PATCH v7 01/12] gpio: mxc: use irq_set_irq_wake() to simplify code Peng Fan (OSS)
2026-10-27 14:09   ` Frank Li
2026-10-27 12:09 ` [PATCH v7 02/12] gpio: mxc: use for_each_set_bit() to iterate wakeup pads Peng Fan (OSS)
2026-10-27 16:35   ` Andy Shevchenko
2026-10-27 12:09 ` [PATCH v7 03/12] gpio: mxc: use 'unsigned int' instead of bare 'unsigned' Peng Fan (OSS)
2026-10-27 14:10   ` Frank Li
2026-10-27 16:36   ` Andy Shevchenko
2026-10-27 12:09 ` [PATCH v7 04/12] gpio: mxc: replace of_device_is_compatible() with hwdata flags Peng Fan (OSS)
2026-10-27 12:09 ` [PATCH v7 05/12] gpio: mxc: convert pad wakeup compatible checks to " Peng Fan (OSS)
2026-10-27 12:09 ` [PATCH v7 06/12] gpio: mxc: use local dev variable Peng Fan (OSS)
2026-10-27 12:09 ` [PATCH v7 07/12] gpio: mxc: use __free guard for runtime PM cleanup Peng Fan (OSS)
2026-10-27 14:12   ` Frank Li
2026-10-27 12:09 ` [PATCH v7 08/12] gpio: mxc: use devres functions to simplify probe code Peng Fan (OSS)
2026-10-27 12:09 ` [PATCH v7 09/12] gpio: mxc: add dev_err_probe() for error paths to help diagnostics Peng Fan (OSS)
2026-10-27 14:13   ` Frank Li
2026-10-27 12:09 ` [PATCH v7 10/12] gpio: mxc: introduce MXC_ICR macros and use field_prep/field_get Peng Fan (OSS)
2026-10-27 12:09 ` [PATCH v7 11/12] gpio: mxc: use BIT() macro for single-bit operations Peng Fan (OSS)
2026-10-27 12:09 ` [PATCH v7 12/12] MAINTAINERS: Add an entry for gpio-mxc Peng Fan (OSS)
2026-10-27 14:14   ` Frank Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®