get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/1.1/patches/2233348/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2233348,
    "url": "http://patchwork.ozlabs.org/api/1.1/patches/2233348/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linux-gpio/patch/59174ed2-dc3a-4891-929f-bf513deecdc2@gmail.com/",
    "project": {
        "id": 42,
        "url": "http://patchwork.ozlabs.org/api/1.1/projects/42/?format=api",
        "name": "Linux GPIO development",
        "link_name": "linux-gpio",
        "list_id": "linux-gpio.vger.kernel.org",
        "list_email": "linux-gpio@vger.kernel.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<59174ed2-dc3a-4891-929f-bf513deecdc2@gmail.com>",
    "date": "2026-05-06T09:29:36",
    "name": "gpio: acpi: modernize resource management using cleanup.h",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "c9042e9709e3a3ff41187692a488721efcac90e3",
    "submitter": {
        "id": 93312,
        "url": "http://patchwork.ozlabs.org/api/1.1/people/93312/?format=api",
        "name": "Marco Scardovi",
        "email": "mscardovi95@gmail.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/linux-gpio/patch/59174ed2-dc3a-4891-929f-bf513deecdc2@gmail.com/mbox/",
    "series": [
        {
            "id": 502945,
            "url": "http://patchwork.ozlabs.org/api/1.1/series/502945/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/linux-gpio/list/?series=502945",
            "date": "2026-05-06T09:29:36",
            "name": "gpio: acpi: modernize resource management using cleanup.h",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/502945/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2233348/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2233348/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "\n <linux-gpio+bounces-36272-incoming=patchwork.ozlabs.org@vger.kernel.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "linux-gpio@vger.kernel.org"
        ],
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=BjGFkPW/;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org;\n envelope-from=linux-gpio+bounces-36272-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)",
            "smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=\"BjGFkPW/\"",
            "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.128.47",
            "smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com",
            "smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=gmail.com"
        ],
        "Received": [
            "from tor.lore.kernel.org (tor.lore.kernel.org\n [IPv6:2600:3c04:e001:36c::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g9VTW2p56z1yJq\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 06 May 2026 19:29:51 +1000 (AEST)",
            "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id 35460300F944\n\tfor <incoming@patchwork.ozlabs.org>; Wed,  6 May 2026 09:29:42 +0000 (UTC)",
            "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 1E7C03E5579;\n\tWed,  6 May 2026 09:29:41 +0000 (UTC)",
            "from mail-wm1-f47.google.com (mail-wm1-f47.google.com\n [209.85.128.47])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 43B403E1D01\n\tfor <linux-gpio@vger.kernel.org>; Wed,  6 May 2026 09:29:39 +0000 (UTC)",
            "by mail-wm1-f47.google.com with SMTP id\n 5b1f17b1804b1-4852a9c6309so49739945e9.0\n        for <linux-gpio@vger.kernel.org>;\n Wed, 06 May 2026 02:29:39 -0700 (PDT)",
            "from ?IPV6:2a01:e11:202b:40:68b1:8d59:e348:c16e?\n ([2a01:e11:202b:40:68b1:8d59:e348:c16e])\n        by smtp.gmail.com with ESMTPSA id\n 5b1f17b1804b1-48e538a547bsm38017295e9.5.2026.05.06.02.29.36\n        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n        Wed, 06 May 2026 02:29:36 -0700 (PDT)"
        ],
        "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1778059780; cv=none;\n b=Q5SjFws5ahTXmuskKQ8jwqWpQRffmCZNY4P1v7bKjSRUdEBrsVOh6LNGAxtmGp14+EwnQzWt5m3fdEE8lEEWlvVkdu7C5ggN/0K3CknQPPbGpHgSayhOzAfp1SahN7KtKTSweCH12zrwKdtxfC5t3KlHqk/Vkr4/bGeQRGjcx0c=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1778059780; c=relaxed/simple;\n\tbh=b6KDebbwB9y2ayWmTDcDF7ZXzrnROwC7atimGy8vf0g=;\n\th=Message-ID:Date:MIME-Version:To:From:Subject:Cc:Content-Type;\n b=jgdChDsX0Efa0K47SnjtXB5PYr/xzQd8KuM8+hqUlnwGRDzYa04HDiNQ/+3m/LDIiUtpRCA2eluOUA2qJ74DZw0r4qGvMzJwS3a4qtuEGb/7FYQb6rjKVlsyio3OQVWOvuWuEhGzD4erWTPi0QvSvPak+fpQZWViWdxyD298dRI=",
        "ARC-Authentication-Results": "i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com;\n spf=pass smtp.mailfrom=gmail.com;\n dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=BjGFkPW/; arc=none smtp.client-ip=209.85.128.47",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=gmail.com; s=20251104; t=1778059778; x=1778664578;\n darn=vger.kernel.org;\n        h=content-transfer-encoding:cc:subject:from:to:content-language\n         :user-agent:mime-version:date:message-id:from:to:cc:subject:date\n         :message-id:reply-to;\n        bh=U/I8gmtTJP4V7dsNote1TQ7GwmlIxPNJ693ojN9z7bA=;\n        b=BjGFkPW/6bSGbXo3NSVroU6XqXBQIXXcmCw+xNmUY3StCPVICQornGq/IpS7rY29ej\n         hvseDjPgmP9O9TTpsoFB7uQ8rLgsLKsylGyg2MzPBPdOc7ZoEfmFu/CGLF8YcoUzRP5V\n         meJauL5a2/a0bc0vwlrce915K4tgqG3gU5qeQEXE6svMBvKibSPKpFdUSFjtcVYZzrg1\n         AJW4Pihm6bTj94XL691TOLRAXv25NPV9Y5SMvvhTqP5rmPtNwZfR6fQ5ShGxwoio1AZS\n         E+9rJNb7SF+MlSuhr0SxpyZZRFm1yaorVkga1MeBExBnEeU5zrXJsfeOZ7ziHV6NcBiL\n         omaw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1778059778; x=1778664578;\n        h=content-transfer-encoding:cc:subject:from:to:content-language\n         :user-agent:mime-version:date:message-id:x-gm-gg:x-gm-message-state\n         :from:to:cc:subject:date:message-id:reply-to;\n        bh=U/I8gmtTJP4V7dsNote1TQ7GwmlIxPNJ693ojN9z7bA=;\n        b=TLGT9Ot+hY0Qllsc9mhjvaJvrwwnJRv6lk9oLSLQwV7BapMmPRVOsguWrrpXsJ8v99\n         56F8+o0EH/XWN5uneXS5r61U+E/OBmwms8GqNInn/4Jz8cdzEvR+aWt9ZrJEHUuLClXM\n         I4mkvogOKc+5B3+Dfvz6KIJ8AMMO/G2mbJzAm9Mvz4pV3+8vjbsACYfCm7xrBNVoHUQ0\n         MlrVDC0xkzW4k/QDRxFZysxwfe1Uz48Ytn37ns+S7FxJHQ5ZNkvli06XzMYH9y5/Etmy\n         KnVTFV8FYJHynMqXa9L35X9/P5die+7vx3asz/QNyLvPJ+xVFB8YfPuoYoC5v519c6bq\n         3qMA==",
        "X-Gm-Message-State": "AOJu0Yx4VM0pT3mcJcEgOQTN2fgOI+wL3/MnNwGBp7IgsK3XOjUp4qLW\n\totg90AB+PXGiN7HivwwTqXmdRTLPres0lNzL20mfDKXYH5AgBEMj6FgJB4PCUkhHrT+JWmwC",
        "X-Gm-Gg": "AeBDiescFqF+A/ko63RyLvmvDDfmj4ux3DSi6q0DVZHo5oDZNV369Q91ZdQVaJWXefl\n\tn5OqWRp7I+dMroZsn6iQgPOg4HrFu1j9qXyZTiNNksQ/6T3GywDBOtCsUhd+I7Vng94ZLYAl21d\n\t/MEpC8Wy80Ccv17/Odi+/KjobxGHVE6zLeJX03GMAksD0xiOj2CWcjYVTZsYep9uPz0uMMx04E6\n\toCQB40vxu40CdUHt89Hy8bQ5Z9HTmp5u/X4XZUGmIDZVM8Hjx5xsEFbETWkuquQI8O+5XU0SZj5\n\toFcy8VatZdzOOzJbgahzOB1kucKegkdBrYdHWTlvlBgg3Tg83LV8dsw3jlay8ECyBCYqR/65VaV\n\tyGvd2pdmBPJB+HuSPANd96TUliIOz+rL/p3+i4S4vPT/taYdSD3aTpxYGAds3PvTsWg32HRK5RN\n\teBcmF0hGebpIdqqHjbUBmG6TPhZZ23sb1CgKnjfrkB69TbgQeiOSqp4x4fSmolp7U2OYK1LB2ZT\n\t0o3PF8=",
        "X-Received": "by 2002:a05:600c:34ca:b0:489:1f08:91b with SMTP id\n 5b1f17b1804b1-48e521e6085mr44681375e9.16.1778059777373;\n        Wed, 06 May 2026 02:29:37 -0700 (PDT)",
        "Message-ID": "<59174ed2-dc3a-4891-929f-bf513deecdc2@gmail.com>",
        "Date": "Wed, 6 May 2026 11:29:36 +0200",
        "Precedence": "bulk",
        "X-Mailing-List": "linux-gpio@vger.kernel.org",
        "List-Id": "<linux-gpio.vger.kernel.org>",
        "List-Subscribe": "<mailto:linux-gpio+subscribe@vger.kernel.org>",
        "List-Unsubscribe": "<mailto:linux-gpio+unsubscribe@vger.kernel.org>",
        "MIME-Version": "1.0",
        "User-Agent": "Mozilla Thunderbird",
        "Content-Language": "en-US",
        "To": "mika.westerberg@linux.intel.com, mathias.nyman@linux.intel.com",
        "From": "Marco Scardovi <mscardovi95@gmail.com>",
        "Subject": "[PATCH] gpio: acpi: modernize resource management using cleanup.h",
        "Cc": "linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org,\n linux-kernel@vger.kernel.org",
        "Content-Type": "text/plain; charset=UTF-8; format=flowed",
        "Content-Transfer-Encoding": "8bit"
    },
    "content": "Hi everyone,\n\nI was looking for ways to switch to modern cleanup guards and auto-freeing\npointers to simplify error paths and synchronization in gpiolib-acpi-core.c\nso I came up with the patch you can find below.\n\nHere you can see the main points I've worked on:\n- Use DEFINE_FREE() for gpio_desc and ACPI resources.\n- Use guard(mutex)() within the OpRegion handler loop for automatic locking.\n- Use __free() for automatic descriptor and memory cleanup.\n- Fix off-by-one error in GPIO pin bounds check.\n- Return AE_OK on out-of-range pins to allow processing other resources\n   even if one is misconfigured in firmware.\n- Use break instead of goto in OpRegion handler for cleaner control flow\n   leveraging auto-cleanup.\n\nI've tested it (both build and functionality) against linux-next-20260430.\n\nSigned-off-by: Marco Scardovi <mscardovi95@gmail.com>\n---\n  drivers/gpio/gpiolib-acpi-core.c | 94 \n+++++++++++++++++++---------------------\n  1 file changed, 43 insertions(+), 51 deletions(-)\n\n\n@@ -370,6 +384,11 @@ static acpi_status acpi_gpiochip_alloc_event(struct \nacpi_resource *ares,\n      handle = ACPI_HANDLE(chip->parent);\n      pin = agpio->pin_table[0];\n\n+    if (pin >= chip->ngpio) {\n+        dev_err(chip->parent, \"Failed to request GPIO for pin 0x%04X, \nout of range\\n\", pin);\n+        return AE_OK;\n+    }\n+\n      if (pin <= 255) {\n          char ev_name[8];\n          sprintf(ev_name, \"_%c%02X\",\n@@ -392,31 +411,26 @@ static acpi_status \nacpi_gpiochip_alloc_event(struct acpi_resource *ares,\n\n      desc = acpi_request_own_gpiod(chip, agpio, 0, \"ACPI:Event\");\n      if (IS_ERR(desc)) {\n-        dev_err(chip->parent,\n-            \"Failed to request GPIO for pin 0x%04X, err %pe\\n\",\n-            pin, desc);\n+        dev_err(chip->parent, \"Failed to request GPIO for pin 0x%04X, \nerr %pe\\n\", pin, desc);\n          return AE_OK;\n      }\n+    desc_guard = desc;\n\n      ret = gpiochip_lock_as_irq(chip, pin);\n      if (ret) {\n-        dev_err(chip->parent,\n-            \"Failed to lock GPIO pin 0x%04X as interrupt, err %d\\n\",\n-            pin, ret);\n-        goto fail_free_desc;\n+        dev_err(chip->parent, \"Failed to lock GPIO pin 0x%04X as \ninterrupt, err %d\\n\", pin, ret);\n+        return AE_OK;\n      }\n\n      irq = gpiod_to_irq(desc);\n      if (irq < 0) {\n-        dev_err(chip->parent,\n-            \"Failed to translate GPIO pin 0x%04X to IRQ, err %d\\n\",\n-            pin, irq);\n-        goto fail_unlock_irq;\n+        dev_err(chip->parent, \"Failed to translate GPIO pin 0x%04X to \nIRQ, err %d\\n\", pin, irq);\n+        goto err_unlock;\n      }\n\n      event = kzalloc_obj(*event);\n      if (!event)\n-        goto fail_unlock_irq;\n+        goto err_unlock;\n\n      event->irqflags = IRQF_ONESHOT;\n      if (agpio->triggering == ACPI_LEVEL_SENSITIVE) {\n@@ -444,17 +458,15 @@ static acpi_status \nacpi_gpiochip_alloc_event(struct acpi_resource *ares,\n      event->irq = irq;\n      event->irq_is_wake = acpi_gpio_irq_is_wake(chip->parent, agpio);\n      event->pin = pin;\n-    event->desc = desc;\n+    /* Transfer ownership to event, prevent auto-free */\n+    event->desc = no_free_ptr(desc_guard);\n\n      list_add_tail(&event->node, &acpi_gpio->events);\n\n      return AE_OK;\n\n-fail_unlock_irq:\n+err_unlock:\n      gpiochip_unlock_as_irq(chip, pin);\n-fail_free_desc:\n-    gpiochip_free_own_desc(desc);\n-\n      return AE_OK;\n  }\n\n@@ -1086,7 +1098,7 @@ acpi_gpio_adr_space_handler(u32 function, \nacpi_physical_address address,\n      struct acpi_gpio_chip *achip = region_context;\n      struct gpio_chip *chip = achip->chip;\n      struct acpi_resource_gpio *agpio;\n-    struct acpi_resource *ares;\n+    struct acpi_resource *ares __free(acpi_free) = NULL;\n      u16 pin_index = address;\n      acpi_status status;\n      int length;\n@@ -1097,20 +1109,17 @@ acpi_gpio_adr_space_handler(u32 function, \nacpi_physical_address address,\n      if (ACPI_FAILURE(status))\n          return status;\n\n-    if (WARN_ON(ares->type != ACPI_RESOURCE_TYPE_GPIO)) {\n-        ACPI_FREE(ares);\n+    if (WARN_ON(ares->type != ACPI_RESOURCE_TYPE_GPIO))\n          return AE_BAD_PARAMETER;\n-    }\n\n      agpio = &ares->data.gpio;\n\n      if (WARN_ON(agpio->io_restriction == ACPI_IO_RESTRICT_INPUT &&\n-        function == ACPI_WRITE)) {\n-        ACPI_FREE(ares);\n+        function == ACPI_WRITE))\n          return AE_BAD_PARAMETER;\n-    }\n\n      length = min(agpio->pin_table_length, pin_index + bits);\n+    status = AE_OK;\n      for (i = pin_index; i < length; ++i) {\n          unsigned int pin = agpio->pin_table[i];\n          struct acpi_gpio_connection *conn;\n@@ -1118,7 +1127,7 @@ acpi_gpio_adr_space_handler(u32 function, \nacpi_physical_address address,\n          u16 word, shift;\n          bool found;\n\n-        mutex_lock(&achip->conn_lock);\n+        guard(mutex)(&achip->conn_lock);\n\n          found = false;\n          list_for_each_entry(conn, &achip->conns, node) {\n@@ -1150,17 +1159,15 @@ acpi_gpio_adr_space_handler(u32 function, \nacpi_physical_address address,\n          if (!found) {\n              desc = acpi_request_own_gpiod(chip, agpio, i, \n\"ACPI:OpRegion\");\n              if (IS_ERR(desc)) {\n-                mutex_unlock(&achip->conn_lock);\n                  status = AE_ERROR;\n-                goto out;\n+                break;\n              }\n\n              conn = kzalloc_obj(*conn);\n              if (!conn) {\n                  gpiochip_free_own_desc(desc);\n-                mutex_unlock(&achip->conn_lock);\n                  status = AE_NO_MEMORY;\n-                goto out;\n+                break;\n              }\n\n              conn->pin = pin;\n@@ -1168,8 +1175,6 @@ acpi_gpio_adr_space_handler(u32 function, \nacpi_physical_address address,\n              list_add_tail(&conn->node, &achip->conns);\n          }\n\n-        mutex_unlock(&achip->conn_lock);\n-\n          /*\n           * For the cases when OperationRegion() consists of more than\n           * 64 bits calculate the word and bit shift to use that one to\n@@ -1188,8 +1193,6 @@ acpi_gpio_adr_space_handler(u32 function, \nacpi_physical_address address,\n          }\n      }\n\n-out:\n-    ACPI_FREE(ares);\n      return status;\n  }",
    "diff": "diff --git a/drivers/gpio/gpiolib-acpi-core.c \nb/drivers/gpio/gpiolib-acpi-core.c\nindex eb8a40cfb7a9..19a18222b7b2 100644\n--- a/drivers/gpio/gpiolib-acpi-core.c\n+++ b/drivers/gpio/gpiolib-acpi-core.c\n@@ -7,6 +7,9 @@\n   *          Mika Westerberg <mika.westerberg@linux.intel.com>\n   */\n\n+#include <linux/cleanup.h>\n+#include <linux/slab.h>\n+\n  #include <linux/acpi.h>\n  #include <linux/dmi.h>\n  #include <linux/errno.h>\n@@ -23,6 +26,16 @@\n  #include \"gpiolib.h\"\n  #include \"gpiolib-acpi.h\"\n\n+DEFINE_FREE(free_gpio_desc, struct gpio_desc *, {\n+    if (_T)\n+        gpiochip_free_own_desc(_T);\n+})\n+\n+DEFINE_FREE(acpi_free, void *, {\n+    if (_T)\n+        ACPI_FREE(_T);\n+})\n+\n  /**\n   * struct acpi_gpio_event - ACPI GPIO event handler data\n   *\n@@ -361,6 +374,7 @@ static acpi_status acpi_gpiochip_alloc_event(struct \nacpi_resource *ares,\n      struct acpi_gpio_event *event;\n      irq_handler_t handler = NULL;\n      struct gpio_desc *desc;\n+    struct gpio_desc *desc_guard __free(free_gpio_desc) = NULL;\n      unsigned int pin;\n      int ret, irq;\n",
    "prefixes": []
}