get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2197010,
    "url": "http://patchwork.ozlabs.org/api/patches/2197010/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/01cc9fe77706bfec2c7806f95d93c84678d06a91.1771275704.git.daniel@makrotopia.org/",
    "project": {
        "id": 18,
        "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api",
        "name": "U-Boot",
        "link_name": "uboot",
        "list_id": "u-boot.lists.denx.de",
        "list_email": "u-boot@lists.denx.de",
        "web_url": null,
        "scm_url": null,
        "webscm_url": null,
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<01cc9fe77706bfec2c7806f95d93c84678d06a91.1771275704.git.daniel@makrotopia.org>",
    "list_archive_url": null,
    "date": "2026-02-16T21:23:50",
    "name": "[RFC,16/20] boot: bootdev: add MTD boot device",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "fbfea7081501e6bb4cb963a2ff5046989f8db9a6",
    "submitter": {
        "id": 64091,
        "url": "http://patchwork.ozlabs.org/api/people/64091/?format=api",
        "name": "Daniel Golle",
        "email": "daniel@makrotopia.org"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/01cc9fe77706bfec2c7806f95d93c84678d06a91.1771275704.git.daniel@makrotopia.org/mbox/",
    "series": [
        {
            "id": 492351,
            "url": "http://patchwork.ozlabs.org/api/series/492351/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=492351",
            "date": "2026-02-16T21:21:14",
            "name": "boot: add OpenWrt boot method and on-demand FIT loading",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/492351/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2197010/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2197010/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<u-boot-bounces@lists.denx.de>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)",
            "phobos.denx.de;\n dmarc=none (p=none dis=none) header.from=makrotopia.org",
            "phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de",
            "phobos.denx.de; dmarc=none (p=none dis=none)\n header.from=makrotopia.org",
            "phobos.denx.de;\n spf=pass smtp.mailfrom=daniel@makrotopia.org"
        ],
        "Received": [
            "from phobos.denx.de (phobos.denx.de\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fFG681JrNz1xpl\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 17 Feb 2026 08:25:52 +1100 (AEDT)",
            "from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 20A7683EEF;\n\tMon, 16 Feb 2026 22:24:19 +0100 (CET)",
            "by phobos.denx.de (Postfix, from userid 109)\n id C584783E61; Mon, 16 Feb 2026 22:24:10 +0100 (CET)",
            "from pidgin.makrotopia.org (pidgin.makrotopia.org\n [IPv6:2a07:2ec0:3002::65])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 6B2C783B8A\n for <u-boot@lists.denx.de>; Mon, 16 Feb 2026 22:24:06 +0100 (CET)",
            "from local\n by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256)\n (Exim 4.99) (envelope-from <daniel@makrotopia.org>)\n id 1vs64P-000000002oy-2mGR; Mon, 16 Feb 2026 21:23:53 +0000"
        ],
        "X-Spam-Checker-Version": "SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de",
        "X-Spam-Level": "",
        "X-Spam-Status": "No, score=-1.9 required=5.0 tests=BAYES_00,\n RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham\n autolearn_force=no version=3.4.2",
        "Date": "Mon, 16 Feb 2026 21:23:50 +0000",
        "From": "Daniel Golle <daniel@makrotopia.org>",
        "To": "Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>,\n Quentin Schulz <quentin.schulz@cherry.de>,\n Daniel Golle <daniel@makrotopia.org>,\n Kory Maincent <kory.maincent@bootlin.com>,\n Mattijs Korpershoek <mkorpershoek@kernel.org>,\n Martin Schwan <m.schwan@phytec.de>, Anshul Dalal <anshuld@ti.com>,\n Ilias Apalodimas <ilias.apalodimas@linaro.org>,\n Sughosh Ganu <sughosh.ganu@arm.com>, Aristo Chen <jj251510319013@gmail.com>,\n\t=?utf-8?b?54mbIOW/l+Wujw==?= <Zone.Niuzh@hotmail.com>,\n Marek Vasut <marek.vasut+renesas@mailbox.org>,\n Heinrich Schuchardt <xypron.glpk@gmx.de>,\n Wolfgang Wallner <wolfgang.wallner@at.abb.com>,\n Frank Wunderlich <frank-w@public-files.de>,\n David Lechner <dlechner@baylibre.com>,\n Osama Abdelkader <osama.abdelkader@gmail.com>,\n Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>,\n Michael Trimarchi <michael@amarulasolutions.com>,\n Miquel Raynal <miquel.raynal@bootlin.com>,\n Andrew Goodbody <andrew.goodbody@linaro.org>,\n Yegor Yefremov <yegorslists@googlemail.com>,\n Mike Looijmans <mike.looijmans@topic.nl>,\n Weijie Gao <weijie.gao@mediatek.com>,\n Alexander Stein <alexander.stein@ew.tq-group.com>,\n Neil Armstrong <neil.armstrong@linaro.org>,\n Mayuresh Chitale <mchitale@ventanamicro.com>,\n Paul HENRYS <paul.henrys_ext@softathome.com>, u-boot@lists.denx.de",
        "Cc": "John Crispin <john@phrozen.org>, Paul Spooren <mail@aparcar.org>",
        "Subject": "[RFC PATCH 16/20] boot: bootdev: add MTD boot device",
        "Message-ID": "\n <01cc9fe77706bfec2c7806f95d93c84678d06a91.1771275704.git.daniel@makrotopia.org>",
        "References": "<cover.1771275704.git.daniel@makrotopia.org>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=utf-8",
        "Content-Disposition": "inline",
        "Content-Transfer-Encoding": "8bit",
        "In-Reply-To": "<cover.1771275704.git.daniel@makrotopia.org>",
        "X-Mailman-Approved-At": "Mon, 16 Feb 2026 22:24:18 +0100",
        "X-BeenThere": "u-boot@lists.denx.de",
        "X-Mailman-Version": "2.1.39",
        "Precedence": "list",
        "List-Id": "U-Boot discussion <u-boot.lists.denx.de>",
        "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>",
        "List-Archive": "<https://lists.denx.de/pipermail/u-boot/>",
        "List-Post": "<mailto:u-boot@lists.denx.de>",
        "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>",
        "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>",
        "Errors-To": "u-boot-bounces@lists.denx.de",
        "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>",
        "X-Virus-Scanned": "clamav-milter 0.103.8 at phobos.denx.de",
        "X-Virus-Status": "Clean"
    },
    "content": "Add a boot device driver for MTD (Memory Technology Devices) that\nenables bootstd to scan MTD partitions for FIT images.\n\nAdd a mtd_bootdev_hunt() callback that:\n- Calls mtd_probe_devices() once to probe all MTD devices (both\n  UCLASS_MTD and UCLASS_SPI_FLASH) and parse their partitions\n- Iterates the MTD subsystem device list and binds an mtd_bootdev for\n  any top-level MTD device that has partitions but is not in UCLASS_MTD\n  (those already get their bootdev from mtd_post_bind)\n- Uses bootdev_bind() directly since sf_bootdev may already occupy the\n  standard bootdev child slot\n\nThe MTD bootdev calls bootmeth_check() at the start of get_bootflow()\nso that only compatible bootmeths (those that accept MTD bootdevs)\nproduce bootflows. Until bootmeth_openwrt's check() is extended to\naccept MTD bootdevs, this driver is inert — each commit compiles and\nintroduces no regressions independently.\n\nSigned-off-by: Daniel Golle <daniel@makrotopia.org>\n---\n boot/Kconfig             |   9 +++\n boot/Makefile            |   1 +\n boot/mtd_bootdev.c       | 150 +++++++++++++++++++++++++++++++++++++++\n drivers/mtd/mtd-uclass.c |  15 ++++\n 4 files changed, 175 insertions(+)\n create mode 100644 boot/mtd_bootdev.c",
    "diff": "diff --git a/boot/Kconfig b/boot/Kconfig\nindex d8c7b8360ac..63e373cc62d 100644\n--- a/boot/Kconfig\n+++ b/boot/Kconfig\n@@ -585,6 +585,15 @@ config BOOTMETH_CROS\n \n \t  Note that only x86 devices are supported at present.\n \n+config BOOTDEV_MTD\n+\tbool \"MTD bootdev support\"\n+\tdepends on DM_MTD\n+\tdepends on BOOTSTD\n+\thelp\n+\t  Enable a boot device for MTD (Memory Technology Devices).\n+\t  This scans MTD partitions for uImage.FIT firmware images,\n+\t  enabling raw-flash boot via the OpenWrt boot method.\n+\n config BOOTMETH_OPENWRT\n \tbool \"Bootdev support for OpenWrt\"\n \tdepends on FIT\ndiff --git a/boot/Makefile b/boot/Makefile\nindex 7b42358eb0c..feeed4924dd 100644\n--- a/boot/Makefile\n+++ b/boot/Makefile\n@@ -72,6 +72,7 @@ obj-$(CONFIG_$(PHASE_)BOOTMETH_VBE_SIMPLE_FW) += vbe_simple_fw.o\n obj-$(CONFIG_$(PHASE_)BOOTMETH_VBE_SIMPLE_OS) += vbe_simple_os.o\n \n obj-$(CONFIG_$(PHASE_)BOOTMETH_ANDROID) += bootmeth_android.o\n+obj-$(CONFIG_$(PHASE_)BOOTDEV_MTD) += mtd_bootdev.o\n obj-$(CONFIG_$(PHASE_)BOOTMETH_OPENWRT) += bootmeth_openwrt.o\n \n obj-$(CONFIG_IMAGE_LOADER) += image-loader.o\ndiff --git a/boot/mtd_bootdev.c b/boot/mtd_bootdev.c\nnew file mode 100644\nindex 00000000000..8a3304be988\n--- /dev/null\n+++ b/boot/mtd_bootdev.c\n@@ -0,0 +1,150 @@\n+// SPDX-License-Identifier: GPL-2.0+\n+/*\n+ * MTD boot device\n+ *\n+ * Copyright (C) 2026 Daniel Golle <daniel@makrotopia.org>\n+ */\n+\n+#define LOG_CATEGORY UCLASS_BOOTSTD\n+\n+#include <bootdev.h>\n+#include <bootflow.h>\n+#include <bootmeth.h>\n+#include <dm.h>\n+#include <malloc.h>\n+#include <mtd.h>\n+#include <linux/libfdt.h>\n+\n+static int mtd_bootdev_get_bootflow(struct udevice *dev,\n+\t\t\t\t    struct bootflow_iter *iter,\n+\t\t\t\t    struct bootflow *bflow)\n+{\n+\tstruct udevice *parent = dev_get_parent(dev);\n+\tstruct mtd_info *mtd, *part;\n+\tu8 buf[40];\n+\tsize_t retlen;\n+\tchar dname[60];\n+\tint n = 0;\n+\tint ret;\n+\n+\tret = bootmeth_check(bflow->method, iter);\n+\tif (ret)\n+\t\treturn log_msg_ret(\"chk\", ret);\n+\n+\t/* Find the top-level MTD device matching our parent */\n+\tmtd_for_each_device(mtd) {\n+\t\tif (!mtd_is_partition(mtd) && mtd->dev == parent)\n+\t\t\tbreak;\n+\t}\n+\tif (!mtd || mtd->dev != parent)\n+\t\treturn log_msg_ret(\"mtd\", -ESHUTDOWN);\n+\n+\t/* Count partitions so the scanning framework knows the bound */\n+\tlist_for_each_entry(part, &mtd->partitions, node)\n+\t\tn++;\n+\tif (n)\n+\t\titer->max_part = n - 1;\n+\n+\tn = 0;\n+\n+\t/* Walk to the iter->part'th sub-partition */\n+\tlist_for_each_entry(part, &mtd->partitions, node) {\n+\t\tif (n == iter->part)\n+\t\t\tgoto found;\n+\t\tn++;\n+\t}\n+\treturn -ESHUTDOWN;\n+\n+found:\n+\tret = mtd_read(part, 0, sizeof(buf), &retlen, buf);\n+\tif (ret || retlen < sizeof(buf))\n+\t\treturn log_msg_ret(\"rd\", -EIO);\n+\n+\tif (fdt_check_header(buf))\n+\t\treturn log_msg_ret(\"fdt\", -ENOENT);\n+\n+\t/* Device-style name and partition index for bootflow list display */\n+\tsnprintf(dname, sizeof(dname), \"%s.part_%x\", dev->name, iter->part);\n+\tbflow->name = strdup(dname);\n+\tbflow->part = iter->part;\n+\tbflow->fname = strdup(part->name);\n+\tbflow->bootmeth_priv = strdup(part->name);\n+\tbflow->state = BOOTFLOWST_MEDIA;\n+\n+\treturn bootmeth_read_bootflow(bflow->method, bflow);\n+}\n+\n+static int mtd_bootdev_bind(struct udevice *dev)\n+{\n+\tstruct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);\n+\n+\tucp->prio = BOOTDEVP_4_SCAN_FAST;\n+\n+\treturn 0;\n+}\n+\n+struct bootdev_ops mtd_bootdev_ops = {\n+\t.get_bootflow\t= mtd_bootdev_get_bootflow,\n+};\n+\n+static const struct udevice_id mtd_bootdev_ids[] = {\n+\t{ .compatible = \"u-boot,bootdev-mtd\" },\n+\t{ }\n+};\n+\n+U_BOOT_DRIVER(mtd_bootdev) = {\n+\t.name\t\t= \"mtd_bootdev\",\n+\t.id\t\t= UCLASS_BOOTDEV,\n+\t.ops\t\t= &mtd_bootdev_ops,\n+\t.bind\t\t= mtd_bootdev_bind,\n+\t.of_match\t= mtd_bootdev_ids,\n+};\n+\n+/**\n+ * mtd_bootdev_hunt() - probe MTD devices and bind bootdevs\n+ *\n+ * Call mtd_probe_devices() to ensure all MTD devices (including SPI NOR\n+ * flash via CONFIG_SPI_FLASH_MTD) are probed and their partitions parsed.\n+ *\n+ * UCLASS_MTD devices already get an mtd_bootdev via mtd_post_bind().\n+ * This creates mtd_bootdev instances for other MTD devices (e.g. SPI NOR\n+ * in UCLASS_SPI_FLASH) that have partitions but would otherwise lack one.\n+ * bootdev_bind() is used directly because sf_bootdev may already occupy\n+ * the standard bootdev child slot.\n+ */\n+static int mtd_bootdev_hunt(struct bootdev_hunter *info, bool show)\n+{\n+\tstruct mtd_info *mtd;\n+\tstruct udevice *bdev;\n+\n+\tmtd_probe_devices();\n+\n+\tmtd_for_each_device(mtd) {\n+\t\t/* Only top-level MTD devices, not partitions */\n+\t\tif (mtd_is_partition(mtd))\n+\t\t\tcontinue;\n+\n+\t\t/* Must have a DM device */\n+\t\tif (!mtd->dev)\n+\t\t\tcontinue;\n+\n+\t\t/* UCLASS_MTD devices already have mtd_bootdev from post_bind */\n+\t\tif (device_get_uclass_id(mtd->dev) == UCLASS_MTD)\n+\t\t\tcontinue;\n+\n+\t\t/* Only interested in MTD devices that have partitions */\n+\t\tif (list_empty(&mtd->partitions))\n+\t\t\tcontinue;\n+\n+\t\tbootdev_bind(mtd->dev, \"mtd_bootdev\", \"mtdbootdev\", &bdev);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+BOOTDEV_HUNTER(mtd_bootdev_hunter) = {\n+\t.prio\t\t= BOOTDEVP_4_SCAN_FAST,\n+\t.uclass\t\t= UCLASS_MTD,\n+\t.drv\t\t= DM_DRIVER_REF(mtd_bootdev),\n+\t.hunt\t\t= mtd_bootdev_hunt,\n+};\ndiff --git a/drivers/mtd/mtd-uclass.c b/drivers/mtd/mtd-uclass.c\nindex 720bd824c4d..0c637d3f5ec 100644\n--- a/drivers/mtd/mtd-uclass.c\n+++ b/drivers/mtd/mtd-uclass.c\n@@ -5,11 +5,25 @@\n \n #define LOG_CATEGORY UCLASS_MTD\n \n+#include <bootdev.h>\n #include <dm.h>\n #include <dm/device-internal.h>\n #include <errno.h>\n #include <mtd.h>\n \n+static int mtd_post_bind(struct udevice *dev)\n+{\n+\tif (CONFIG_IS_ENABLED(BOOTDEV_MTD)) {\n+\t\tint ret;\n+\n+\t\tret = bootdev_setup_for_dev(dev, \"mtd_bootdev\");\n+\t\tif (ret)\n+\t\t\treturn log_msg_ret(\"bd\", ret);\n+\t}\n+\n+\treturn 0;\n+}\n+\n /*\n  * Implement a MTD uclass which should include most flash drivers.\n  * The uclass private is pointed to mtd_info.\n@@ -18,5 +32,6 @@\n UCLASS_DRIVER(mtd) = {\n \t.id\t\t= UCLASS_MTD,\n \t.name\t\t= \"mtd\",\n+\t.post_bind\t= mtd_post_bind,\n \t.per_device_auto\t= sizeof(struct mtd_info),\n };\n",
    "prefixes": [
        "RFC",
        "16/20"
    ]
}