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

Marco Scardovi (scardracs) posted 12 patches 6 days, 21 hours ago
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
[PATCH 00/12] gpiolib: acpi: Refactor, harden, and modularize ACPI GPIO support
Posted by Marco Scardovi (scardracs) 6 days, 21 hours ago
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@gmail.com>

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
Re: [PATCH 00/12] gpiolib: acpi: Refactor, harden, and modularize ACPI GPIO support
Posted by Andy Shevchenko 6 days, 20 hours ago
On Mon, May 18, 2026 at 09:53:45AM +0200, Marco Scardovi (scardracs) wrote:
> Good morning everyone,
> 
> This patch series took fairly a bit of time because, well,

It needs more work. Please, take your time to get familiar with the Linux
kernel process and patches requirements (read Submitting Patches and related
documentation).

> 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.

Start from fixing critical issues first.

> 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.

I didn't get the point of the whole series. It also gets +80 or so LoC.

-- 
With Best Regards,
Andy Shevchenko