get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2234468,
    "url": "http://patchwork.ozlabs.org/api/1.2/patches/2234468/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linux-mtd/patch/20260507-winbond-v6-18-rc1-spi-nor-swp-v5-15-93453e1a9597@bootlin.com/",
    "project": {
        "id": 3,
        "url": "http://patchwork.ozlabs.org/api/1.2/projects/3/?format=api",
        "name": "Linux MTD development",
        "link_name": "linux-mtd",
        "list_id": "linux-mtd.lists.infradead.org",
        "list_email": "linux-mtd@lists.infradead.org",
        "web_url": null,
        "scm_url": null,
        "webscm_url": null,
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20260507-winbond-v6-18-rc1-spi-nor-swp-v5-15-93453e1a9597@bootlin.com>",
    "list_archive_url": null,
    "date": "2026-05-07T16:46:56",
    "name": "[v5,15/28] mtd: spi-nor: swp: Simplify checking the locked/unlocked range",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "b7efffb7c075e4c51929a4f7979e42f71355d4fa",
    "submitter": {
        "id": 73368,
        "url": "http://patchwork.ozlabs.org/api/1.2/people/73368/?format=api",
        "name": "Miquel Raynal",
        "email": "miquel.raynal@bootlin.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/linux-mtd/patch/20260507-winbond-v6-18-rc1-spi-nor-swp-v5-15-93453e1a9597@bootlin.com/mbox/",
    "series": [
        {
            "id": 503226,
            "url": "http://patchwork.ozlabs.org/api/1.2/series/503226/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/linux-mtd/list/?series=503226",
            "date": "2026-05-07T16:46:51",
            "name": "mtd: spi-nor: Enhance software protection",
            "version": 5,
            "mbox": "http://patchwork.ozlabs.org/series/503226/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2234468/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2234468/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "\n <linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=lists.infradead.org header.i=@lists.infradead.org\n header.a=rsa-sha256 header.s=bombadil.20210309 header.b=JKJYZPDd;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256\n header.s=dkim header.b=SvwCLcRl;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=none (no SPF record) smtp.mailfrom=lists.infradead.org\n (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org;\n envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n receiver=patchwork.ozlabs.org)"
        ],
        "Received": [
            "from bombadil.infradead.org (bombadil.infradead.org\n [IPv6:2607:7c80:54:3::133])\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 4gBJ832TC0z23ld\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 08 May 2026 02:47:31 +1000 (AEST)",
            "from localhost ([::1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux))\n\tid 1wL1sj-00000004NIs-1qYC;\n\tThu, 07 May 2026 16:47:25 +0000",
            "from smtpout-04.galae.net ([185.171.202.116])\n\tby bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux))\n\tid 1wL1sg-00000004NCl-3nta\n\tfor linux-mtd@lists.infradead.org;\n\tThu, 07 May 2026 16:47:24 +0000",
            "from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233])\n\tby smtpout-04.galae.net (Postfix) with ESMTPS id 21B48C5DC60;\n\tThu,  7 May 2026 16:48:09 +0000 (UTC)",
            "from mail.galae.net (mail.galae.net [212.83.136.155])\n\tby smtpout-01.galae.net (Postfix) with ESMTPS id 580C2605CF;\n\tThu,  7 May 2026 16:47:21 +0000 (UTC)",
            "from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon)\n with ESMTPSA id 282C6108194E4;\n\tThu,  7 May 2026 18:47:19 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20210309; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id\n\t:MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=tWwLh8XizfWSN9f+7OKkfLl1QDAYb/+skMo0F9QFrMs=; b=JKJYZPDdDjqo8q\n\tufjcw4/NKfyYMgQco7s3++ITuM9yE1uucLRHZDDVVXrOjHKUWLqGB0D3PBr33nqylxqw1/0HULYn7\n\tMX+pIoRCKr5NYUuFZ7fy6/N9DUdDWiI5QPBJQT4ioMnEjj8CKPsCHdtwjSQo6cfoQh0GjvupjRKqh\n\tA+LK29qL+qz36faMmPOtKOj5mvkPHNHZlwbIUeKnK76aq0UexMdNnSYwwvLUl1SfLI0AhuvJlXw4/\n\t7cHt5FH6SCX39ofU3jb5Mh8NaXR28KNCzUCFIYP8EA/AWejscKUjdifSrI8165S4UOtui7p4wDyud\n\tyPgJ01IPjlCpTye6SM3g==;",
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim;\n\tt=1778172440; h=from:subject:date:message-id:to:cc:mime-version:content-type:\n\t content-transfer-encoding:in-reply-to:references;\n\tbh=+w5oU3Gj7K2BYmqNI/4B+f1lhjNH9tKHYf4hS6Tqu1k=;\n\tb=SvwCLcRlUH1nlj9wQodxPJxJUNp+urJTHFfLxGnaZPrbD7Z5+YlD5xfKQPmR8ZBBMSCXpy\n\txaci73OYYFThwgZ8KKZeaff3GnxFi6e3LNCJgs+EakNmXu51LnPlf57xtFX8NCdy//BYQG\n\tF97AD9IXUyEno2u6+b1HVCDuSDo4zrXAu6jPgp4MLuD1J23arho2tLpXhruzdqVv/iu+yg\n\tAp7ZpAp90fNFbW0y5jmou+6haz9yrt/Yyq7DxIDMHnSny97Nk8teSO2EpwuqLNB7bAG7wL\n\tpFPh7xfaxalpFE0I3G53J7WK/EzAOO3/N7TM5TOLTyaCcTngwIurF7ed+EX1mA=="
        ],
        "From": "Miquel Raynal <miquel.raynal@bootlin.com>",
        "Date": "Thu, 07 May 2026 18:46:56 +0200",
        "Subject": "[PATCH v5 15/28] mtd: spi-nor: swp: Simplify checking the\n locked/unlocked range",
        "MIME-Version": "1.0",
        "Message-Id": "\n <20260507-winbond-v6-18-rc1-spi-nor-swp-v5-15-93453e1a9597@bootlin.com>",
        "References": "\n <20260507-winbond-v6-18-rc1-spi-nor-swp-v5-0-93453e1a9597@bootlin.com>",
        "In-Reply-To": "\n <20260507-winbond-v6-18-rc1-spi-nor-swp-v5-0-93453e1a9597@bootlin.com>",
        "To": "Pratyush Yadav <pratyush@kernel.org>, Michael Walle <mwalle@kernel.org>,\n Takahiro Kuwano <takahiro.kuwano@infineon.com>,\n Richard Weinberger <richard@nod.at>, Vignesh Raghavendra <vigneshr@ti.com>,\n Jonathan Corbet <corbet@lwn.net>, Tudor Ambarus <tudor.ambarus@linaro.org>,\n Shuah Khan <skhan@linuxfoundation.org>",
        "Cc": "Sean Anderson <sean.anderson@linux.dev>,\n Thomas Petazzoni <thomas.petazzoni@bootlin.com>,\n Steam Lin <STLin2@winbond.com>, linux-mtd@lists.infradead.org,\n linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,\n Miquel Raynal <miquel.raynal@bootlin.com>",
        "X-Mailer": "b4 0.14.3",
        "X-Last-TLS-Session-Version": "TLSv1.3",
        "X-CRM114-Version": "20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 ",
        "X-CRM114-CacheID": "sfid-20260507_094723_243880_91D884D9 ",
        "X-CRM114-Status": "GOOD (  11.67  )",
        "X-Spam-Score": "-2.1 (--)",
        "X-Spam-Report": "Spam detection software,\n running on the system \"bombadil.infradead.org\",\n has NOT identified this incoming email as spam.  The original\n message has been attached to this so you can view it or label\n similar future email.  If you have any questions, see\n the administrator of that system for details.\n Content preview:  In both the locking/unlocking steps, at the end we verify\n   whether we do not lock/unlock more than requested (in which case an error\n   must be returned). While being possible to do that with very simple mask\n comparisons,\n    it does not scale when adding extra locking features such as the CMP\n possibility.\n    In order to make these checks slightly easier to re [...]\n Content analysis details:   (-2.1 points, 5.0 required)\n  pts rule name              description\n ---- ----------------------\n --------------------------------------------------\n -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record\n -0.0 SPF_PASS               SPF: sender matches SPF record\n -0.1 DKIM_VALID_EF          Message has a valid DKIM or DK signature from\n                             envelope-from domain\n -0.1 DKIM_VALID             Message has at least one valid DKIM or DK\n signature\n -0.1 DKIM_VALID_AU          Message has a valid DKIM or DK signature from\n author's\n                             domain\n  0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n not necessarily valid\n -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n                             [score: 0.0000]\n -0.0 DMARC_PASS             DMARC pass policy",
        "X-BeenThere": "linux-mtd@lists.infradead.org",
        "X-Mailman-Version": "2.1.34",
        "Precedence": "list",
        "List-Id": "Linux MTD discussion mailing list <linux-mtd.lists.infradead.org>",
        "List-Unsubscribe": "<http://lists.infradead.org/mailman/options/linux-mtd>,\n <mailto:linux-mtd-request@lists.infradead.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.infradead.org/pipermail/linux-mtd/>",
        "List-Post": "<mailto:linux-mtd@lists.infradead.org>",
        "List-Help": "<mailto:linux-mtd-request@lists.infradead.org?subject=help>",
        "List-Subscribe": "<http://lists.infradead.org/mailman/listinfo/linux-mtd>,\n <mailto:linux-mtd-request@lists.infradead.org?subject=subscribe>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Sender": "\"linux-mtd\" <linux-mtd-bounces@lists.infradead.org>",
        "Errors-To": "linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org"
    },
    "content": "In both the locking/unlocking steps, at the end we verify whether we do\nnot lock/unlock more than requested (in which case an error must be\nreturned).\n\nWhile being possible to do that with very simple mask comparisons, it\ndoes not scale when adding extra locking features such as the CMP\npossibility. In order to make these checks slightly easier to read and\nmore future proof, use existing helpers to read the (future) status\nregister, extract the covered range, and compare it with very usual\nalgebric comparisons.\n\nSigned-off-by: Miquel Raynal <miquel.raynal@bootlin.com>\n---\n drivers/mtd/spi-nor/swp.c | 25 +++++++++++++++++--------\n 1 file changed, 17 insertions(+), 8 deletions(-)",
    "diff": "diff --git a/drivers/mtd/spi-nor/swp.c b/drivers/mtd/spi-nor/swp.c\nindex 8aa0fe297188..a45627380363 100644\n--- a/drivers/mtd/spi-nor/swp.c\n+++ b/drivers/mtd/spi-nor/swp.c\n@@ -200,7 +200,8 @@ static int spi_nor_sr_lock(struct spi_nor *nor, loff_t ofs, u64 len)\n \tu64 min_prot_len;\n \tint ret;\n \tu8 status_old[1] = {}, status_new[1] = {};\n-\tu8 bp_mask = spi_nor_get_sr_bp_mask(nor);\n+\tloff_t ofs_old, ofs_new;\n+\tu64 len_old, len_new;\n \tloff_t lock_len;\n \tbool can_be_top = true, can_be_bottom = nor->flags & SNOR_F_HAS_SR_TB;\n \tbool use_top;\n@@ -248,10 +249,6 @@ static int spi_nor_sr_lock(struct spi_nor *nor, loff_t ofs, u64 len)\n \tif (ret)\n \t\treturn ret;\n \n-\t/* Don't \"lock\" with no region! */\n-\tif (!(status_new[0] & bp_mask))\n-\t\treturn -EINVAL;\n-\n \t/*\n \t * Disallow further writes if WP# pin is neither left floating nor\n \t * wrongly tied to GND (that includes internal pull-downs).\n@@ -264,8 +261,16 @@ static int spi_nor_sr_lock(struct spi_nor *nor, loff_t ofs, u64 len)\n \tif (status_new[0] == status_old[0])\n \t\treturn 0;\n \n+\tspi_nor_get_locked_range_sr(nor, status_old, &ofs_old, &len_old);\n+\tspi_nor_get_locked_range_sr(nor, status_new, &ofs_new, &len_new);\n+\n+\t/* Don't \"lock\" with no region! */\n+\tif (!len_new)\n+\t\treturn -EINVAL;\n+\n \t/* Only modify protection if it will not unlock other areas */\n-\tif ((status_new[0] & bp_mask) < (status_old[0] & bp_mask))\n+\tif (len_old &&\n+\t    (ofs_old < ofs_new || (ofs_new + len_new) < (ofs_old + len_old)))\n \t\treturn -EINVAL;\n \n \treturn spi_nor_write_sr_and_check(nor, status_new[0]);\n@@ -281,7 +286,8 @@ static int spi_nor_sr_unlock(struct spi_nor *nor, loff_t ofs, u64 len)\n \tu64 min_prot_len;\n \tint ret;\n \tu8 status_old[1], status_new[1];\n-\tu8 bp_mask = spi_nor_get_sr_bp_mask(nor);\n+\tloff_t ofs_old, ofs_new;\n+\tu64 len_old, len_new;\n \tloff_t lock_len;\n \tbool can_be_top = true, can_be_bottom = nor->flags & SNOR_F_HAS_SR_TB;\n \tbool use_top;\n@@ -346,7 +352,10 @@ static int spi_nor_sr_unlock(struct spi_nor *nor, loff_t ofs, u64 len)\n \t\treturn 0;\n \n \t/* Only modify protection if it will not lock other areas */\n-\tif ((status_new[0] & bp_mask) > (status_old[0] & bp_mask))\n+\tspi_nor_get_locked_range_sr(nor, status_old, &ofs_old, &len_old);\n+\tspi_nor_get_locked_range_sr(nor, status_new, &ofs_new, &len_new);\n+\tif (len_old && len_new &&\n+\t    (ofs_new < ofs_old || (ofs_old + len_old) < (ofs_new + len_new)))\n \t\treturn -EINVAL;\n \n \treturn spi_nor_write_sr_and_check(nor, status_new[0]);\n",
    "prefixes": [
        "v5",
        "15/28"
    ]
}