[PATCH 00/12] gpiolib: acpi: Refactor, harden, and modularize ACPI GPIO support

From: Marco Scardovi (scardracs)

Date: Mon May 18 2026 - 04:02:37 EST


Good morning everyone,

This patch series took fairly a bit of time because, well, it ended up going a "bit"
out of hand. It improves style, robustness, resource safety, and modularity
of the ACPI GPIO subsystem. The massive gpiolib-acpi-core.c driver (previously
well over 1400 lines) has been significantly refactored, reducing its footprint
by separating concerns into distinct, dedicated modules for ACPI Operation Region
handling and ACPI Event/Interrupt processing.

Key changes and structure of the series:
1. Hardening & Correctness (Patches 1-4):
- Style adjustments to match Linux Kernel coding standard.
- Modernized parsing in quirks using standard sysfs/kstrto helpers.
- Added robust bounds checking for ACPI GPIO resource pin ranges.
- Fixed a critical memory resource leak in the OpRegion cleanup path.

2. ACPI Operation Region Modularization (Patches 5-9):
- Declared shared data structures in the local header.
- Exposed private-to-core registration helpers by making them non-static.
- Extracted Operation Region handling logic to gpiolib-acpi-opregion.c.
- Diverted callback registration to the new OpRegion module.
- Removed the unused static emulation handlers from the core driver.

3. ACPI Event & Interrupt Handling Modularization (Patches 10-12):
- Declared shared helper prototypes in the local header.
- Extracted Event/Interrupt logic to gpiolib-acpi-events.c.
- Fully decoupled static event handlers and event structures from the core.

Build correctness and functional behavior were validated on x86 virtual
platforms using virtme-ng under KASAN and kmemleak with successful boot,
execution, and zero resource leaks.

Assisted-by: Antigravity:gemini-3-flash
Signed-off-by: Marco Scardovi <mscardovi95@xxxxxxxxx>

Marco Scardovi (scardracs) (12):
gpiolib: acpi: Fix style and formatting issues in core
gpiolib: acpi: Modernize string parsing in quirks layer
gpiolib: acpi: Add robust bounds-checking for GPIO pin resources
gpiolib: acpi: Fix resource leak in OpRegion cleanup path
gpiolib: acpi: Declare shared structures in gpiolib-acpi.h
gpiolib: acpi: Expose core GPIO resource and OpRegion helpers
gpiolib: acpi: Add dedicated Operation Region module
gpiolib: acpi: Divert OpRegion registration callbacks from core
gpiolib: acpi: Remove unused static address space emulation from core
gpiolib: acpi: Declare shared event helpers in gpiolib-acpi.h
gpiolib: acpi: Add dedicated ACPI GPIO events module
gpiolib: acpi: Decouple Event and Interrupt handling from core

drivers/gpio/Makefile | 2 +-
drivers/gpio/gpiolib-acpi-core.c | 488 +--------------------------
drivers/gpio/gpiolib-acpi-events.c | 309 +++++++++++++++++
drivers/gpio/gpiolib-acpi-opregion.c | 175 ++++++++++
drivers/gpio/gpiolib-acpi-quirks.c | 23 +-
drivers/gpio/gpiolib-acpi.h | 50 ++-
6 files changed, 561 insertions(+), 486 deletions(-)
create mode 100644 drivers/gpio/gpiolib-acpi-events.c
create mode 100644 drivers/gpio/gpiolib-acpi-opregion.c

--
2.54.0