get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1877711,
    "url": "http://patchwork.ozlabs.org/api/patches/1877711/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linux-mtd/patch/af5981d9bc41b6425e88c7389b4669bc07c27429.1702952891.git.daniel@makrotopia.org/",
    "project": {
        "id": 3,
        "url": "http://patchwork.ozlabs.org/api/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": "<af5981d9bc41b6425e88c7389b4669bc07c27429.1702952891.git.daniel@makrotopia.org>",
    "list_archive_url": null,
    "date": "2023-12-19T02:32:35",
    "name": "[v7,3/7] mtd: ubi: block: use notifier to create ubiblock from parameter",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "a600f4e4b869ffc78998e429da5fd9150d6e689a",
    "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/linux-mtd/patch/af5981d9bc41b6425e88c7389b4669bc07c27429.1702952891.git.daniel@makrotopia.org/mbox/",
    "series": [
        {
            "id": 387243,
            "url": "http://patchwork.ozlabs.org/api/series/387243/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/linux-mtd/list/?series=387243",
            "date": "2023-12-19T02:32:00",
            "name": "mtd: ubi: allow UBI volumes to provide NVMEM",
            "version": 7,
            "mbox": "http://patchwork.ozlabs.org/series/387243/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1877711/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1877711/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=bq5bpovu;\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 4SvLNH1p9bz20H4\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 19 Dec 2023 13:33:35 +1100 (AEDT)",
            "from localhost ([::1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux))\n\tid 1rFPuY-00Cams-11;\n\tTue, 19 Dec 2023 02:32:46 +0000",
            "from pidgin.makrotopia.org ([185.142.180.65])\n\tby bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux))\n\tid 1rFPuV-00Cal7-1N\n\tfor linux-mtd@lists.infradead.org;\n\tTue, 19 Dec 2023 02:32:45 +0000",
            "from local\n\tby pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256)\n\t (Exim 4.96.2)\n\t(envelope-from <daniel@makrotopia.org>)\n\tid 1rFPuP-0008I2-0u;\n\tTue, 19 Dec 2023 02:32:38 +0000"
        ],
        "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:In-Reply-To:MIME-Version:References:\n\tMessage-ID:Subject:To:From:Date:Reply-To:Cc:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=EhRtQU85Q3ZcEQd+kK9XM7qKTqMtsaQ6nFWZczlYrF0=; b=bq5bpovuU/x+24\n\tUaWKOBX3jc9KjoKMWU0bfQpJiDzC5p6bUtd00Q5EgyOrCiJWbhZb8ZUGGtywjl/K2RJFDZHCAPdtL\n\tSwS7AVjbCaEd73OsZ/Hsnqn4jUir8e4CpI+HoC3H+fg+kjlHY9TwAu4c5yHzyoqJuUQYU2AsMlnvP\n\tBZpoKtYzEQzBJC3RoD6MbYBb/LKYC8PWav0egkls4/SpFzwtOkg2N/cHAJnHxy4w3FeaD+4tNqqzR\n\tARuOAD3VBW4kAHaQRlet8WeFgBVtCwNwYfALrQUDJv2J2awZ5gTMHfpKP7aw+z04XYzgzEFOCZEct\n\t1C3p1StxpJFgqVBxGR+g==;",
        "Date": "Tue, 19 Dec 2023 02:32:35 +0000",
        "From": "Daniel Golle <daniel@makrotopia.org>",
        "To": "Miquel Raynal <miquel.raynal@bootlin.com>,\n\tRichard Weinberger <richard@nod.at>,\n\tVignesh Raghavendra <vigneshr@ti.com>,\n\tRob Herring <robh+dt@kernel.org>,\n\tKrzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,\n\tConor Dooley <conor+dt@kernel.org>,\n\tDaniel Golle <daniel@makrotopia.org>, linux-mtd@lists.infradead.org,\n\tdevicetree@vger.kernel.org, linux-kernel@vger.kernel.org",
        "Subject": "[PATCH v7 3/7] mtd: ubi: block: use notifier to create ubiblock from\n parameter",
        "Message-ID": "\n <af5981d9bc41b6425e88c7389b4669bc07c27429.1702952891.git.daniel@makrotopia.org>",
        "References": "<cover.1702952891.git.daniel@makrotopia.org>",
        "MIME-Version": "1.0",
        "Content-Disposition": "inline",
        "In-Reply-To": "<cover.1702952891.git.daniel@makrotopia.org>",
        "X-CRM114-Version": "20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ",
        "X-CRM114-CacheID": "sfid-20231218_183243_626203_44C66596 ",
        "X-CRM114-Status": "GOOD (  30.59  )",
        "X-Spam-Score": "0.0 (/)",
        "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:  Use UBI_VOLUME_ADDED notification to create ubiblock device\n    specified on kernel cmdline or module parameter. This makes thing more\n simple\n    and has the advantage that ubiblock devices on volumes which a [...]\n Content analysis details:   (0.0 points, 5.0 required)\n  pts rule name              description\n ---- ----------------------\n --------------------------------------------------\n -0.0 SPF_PASS               SPF: sender matches SPF record\n  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record",
        "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": "Use UBI_VOLUME_ADDED notification to create ubiblock device specified\non kernel cmdline or module parameter.\nThis makes thing more simple and has the advantage that ubiblock devices\non volumes which are not present at the time the ubi module is probed\nwill still be created.\n\nSuggested-by: Zhihao Cheng <chengzhihao1@huawei.com>\nSigned-off-by: Daniel Golle <daniel@makrotopia.org>\n---\n drivers/mtd/ubi/block.c | 136 ++++++++++++++++++++--------------------\n drivers/mtd/ubi/kapi.c  |  54 +++++++++++-----\n drivers/mtd/ubi/ubi.h   |   1 +\n 3 files changed, 106 insertions(+), 85 deletions(-)",
    "diff": "diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c\nindex 309a42aeaa4cd..a467df5aa130a 100644\n--- a/drivers/mtd/ubi/block.c\n+++ b/drivers/mtd/ubi/block.c\n@@ -65,10 +65,10 @@ struct ubiblock_pdu {\n };\n \n /* Numbers of elements set in the @ubiblock_param array */\n-static int ubiblock_devs __initdata;\n+static int ubiblock_devs;\n \n /* MTD devices specification parameters */\n-static struct ubiblock_param ubiblock_param[UBIBLOCK_MAX_DEVICES] __initdata;\n+static struct ubiblock_param ubiblock_param[UBIBLOCK_MAX_DEVICES];\n \n struct ubiblock {\n \tstruct ubi_volume_desc *desc;\n@@ -534,6 +534,70 @@ static int ubiblock_resize(struct ubi_volume_info *vi)\n \treturn 0;\n }\n \n+static bool\n+match_volume_desc(struct ubi_volume_info *vi, const char *name, int ubi_num, int vol_id)\n+{\n+\tint err, len, cur_ubi_num, cur_vol_id;\n+\n+\tif (ubi_num == -1) {\n+\t\t/* No ubi num, name must be a vol device path */\n+\t\terr = ubi_get_num_by_path(name, &cur_ubi_num, &cur_vol_id);\n+\t\tif (err || vi->ubi_num != cur_ubi_num || vi->vol_id != cur_vol_id)\n+\t\t\treturn false;\n+\n+\t\treturn true;\n+\t}\n+\n+\tif (vol_id == -1) {\n+\t\t/* Got ubi_num, but no vol_id, name must be volume name */\n+\t\tif (vi->ubi_num != ubi_num)\n+\t\t\treturn false;\n+\n+\t\tlen = strnlen(name, UBI_VOL_NAME_MAX + 1);\n+\t\tif (len < 1 || vi->name_len != len)\n+\t\t\treturn false;\n+\n+\t\tif (strcmp(name, vi->name))\n+\t\t\treturn false;\n+\n+\t\treturn true;\n+\t}\n+\n+\tif (vi->ubi_num != ubi_num)\n+\t\treturn false;\n+\n+\tif (vi->vol_id != vol_id)\n+\t\treturn false;\n+\n+\treturn true;\n+}\n+\n+static void\n+ubiblock_create_from_param(struct ubi_volume_info *vi)\n+{\n+\tint i, ret = 0;\n+\tstruct ubiblock_param *p;\n+\n+\t/*\n+\t * Iterate over ubiblock cmdline parameters. If a parameter matches the\n+\t * newly added volume create the ubiblock device for it.\n+\t */\n+\tfor (i = 0; i < ubiblock_devs; i++) {\n+\t\tp = &ubiblock_param[i];\n+\n+\t\tif (!match_volume_desc(vi, p->name, p->ubi_num, p->vol_id))\n+\t\t\tcontinue;\n+\n+\t\tret = ubiblock_create(vi);\n+\t\tif (ret) {\n+\t\t\tpr_err(\n+\t\t\t       \"UBI: block: can't add '%s' volume on ubi%d_%d, err=%d\\n\",\n+\t\t\t       vi->name, p->ubi_num, p->vol_id, ret);\n+\t\t}\n+\t\tbreak;\n+\t}\n+}\n+\n static int ubiblock_notify(struct notifier_block *nb,\n \t\t\t unsigned long notification_type, void *ns_ptr)\n {\n@@ -541,10 +605,7 @@ static int ubiblock_notify(struct notifier_block *nb,\n \n \tswitch (notification_type) {\n \tcase UBI_VOLUME_ADDED:\n-\t\t/*\n-\t\t * We want to enforce explicit block device creation for\n-\t\t * volumes, so when a volume is added we do nothing.\n-\t\t */\n+\t\tubiblock_create_from_param(&nt->vi);\n \t\tbreak;\n \tcase UBI_VOLUME_REMOVED:\n \t\tubiblock_remove(&nt->vi);\n@@ -570,56 +631,6 @@ static struct notifier_block ubiblock_notifier = {\n \t.notifier_call = ubiblock_notify,\n };\n \n-static struct ubi_volume_desc * __init\n-open_volume_desc(const char *name, int ubi_num, int vol_id)\n-{\n-\tif (ubi_num == -1)\n-\t\t/* No ubi num, name must be a vol device path */\n-\t\treturn ubi_open_volume_path(name, UBI_READONLY);\n-\telse if (vol_id == -1)\n-\t\t/* No vol_id, must be vol_name */\n-\t\treturn ubi_open_volume_nm(ubi_num, name, UBI_READONLY);\n-\telse\n-\t\treturn ubi_open_volume(ubi_num, vol_id, UBI_READONLY);\n-}\n-\n-static void __init ubiblock_create_from_param(void)\n-{\n-\tint i, ret = 0;\n-\tstruct ubiblock_param *p;\n-\tstruct ubi_volume_desc *desc;\n-\tstruct ubi_volume_info vi;\n-\n-\t/*\n-\t * If there is an error creating one of the ubiblocks, continue on to\n-\t * create the following ubiblocks. This helps in a circumstance where\n-\t * the kernel command-line specifies multiple block devices and some\n-\t * may be broken, but we still want the working ones to come up.\n-\t */\n-\tfor (i = 0; i < ubiblock_devs; i++) {\n-\t\tp = &ubiblock_param[i];\n-\n-\t\tdesc = open_volume_desc(p->name, p->ubi_num, p->vol_id);\n-\t\tif (IS_ERR(desc)) {\n-\t\t\tpr_err(\n-\t\t\t       \"UBI: block: can't open volume on ubi%d_%d, err=%ld\\n\",\n-\t\t\t       p->ubi_num, p->vol_id, PTR_ERR(desc));\n-\t\t\tcontinue;\n-\t\t}\n-\n-\t\tubi_get_volume_info(desc, &vi);\n-\t\tubi_close_volume(desc);\n-\n-\t\tret = ubiblock_create(&vi);\n-\t\tif (ret) {\n-\t\t\tpr_err(\n-\t\t\t       \"UBI: block: can't add '%s' volume on ubi%d_%d, err=%d\\n\",\n-\t\t\t       vi.name, p->ubi_num, p->vol_id, ret);\n-\t\t\tcontinue;\n-\t\t}\n-\t}\n-}\n-\n static void ubiblock_remove_all(void)\n {\n \tstruct ubiblock *next;\n@@ -645,18 +656,7 @@ int __init ubiblock_init(void)\n \tif (ubiblock_major < 0)\n \t\treturn ubiblock_major;\n \n-\t/*\n-\t * Attach block devices from 'block=' module param.\n-\t * Even if one block device in the param list fails to come up,\n-\t * still allow the module to load and leave any others up.\n-\t */\n-\tubiblock_create_from_param();\n-\n-\t/*\n-\t * Block devices are only created upon user requests, so we ignore\n-\t * existing volumes.\n-\t */\n-\tret = ubi_register_volume_notifier(&ubiblock_notifier, 1);\n+\tret = ubi_register_volume_notifier(&ubiblock_notifier, 0);\n \tif (ret)\n \t\tgoto err_unreg;\n \treturn 0;\ndiff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c\nindex 5db653eacbd45..fbf3a7fe2af79 100644\n--- a/drivers/mtd/ubi/kapi.c\n+++ b/drivers/mtd/ubi/kapi.c\n@@ -279,6 +279,41 @@ struct ubi_volume_desc *ubi_open_volume_nm(int ubi_num, const char *name,\n }\n EXPORT_SYMBOL_GPL(ubi_open_volume_nm);\n \n+/**\n+ * ubi_get_num_by_path - get UBI device and volume number from device path\n+ * @pathname: volume character device node path\n+ * @ubi_num: pointer to UBI device number to be set\n+ * @vol_id: pointer to UBI volume ID to be set\n+ *\n+ * Returns 0 on success and sets ubi_num and vol_id, returns error otherwise.\n+ */\n+int ubi_get_num_by_path(const char *pathname, int *ubi_num, int *vol_id)\n+{\n+\tint error;\n+\tstruct path path;\n+\tstruct kstat stat;\n+\n+\terror = kern_path(pathname, LOOKUP_FOLLOW, &path);\n+\tif (error)\n+\t\treturn error;\n+\n+\terror = vfs_getattr(&path, &stat, STATX_TYPE, AT_STATX_SYNC_AS_STAT);\n+\tpath_put(&path);\n+\tif (error)\n+\t\treturn error;\n+\n+\tif (!S_ISCHR(stat.mode))\n+\t\treturn -EINVAL;\n+\n+\t*ubi_num = ubi_major2num(MAJOR(stat.rdev));\n+\t*vol_id = MINOR(stat.rdev) - 1;\n+\n+\tif (*vol_id < 0 || *ubi_num < 0)\n+\t\treturn -ENODEV;\n+\n+\treturn 0;\n+}\n+\n /**\n  * ubi_open_volume_path - open UBI volume by its character device node path.\n  * @pathname: volume character device node path\n@@ -290,32 +325,17 @@ EXPORT_SYMBOL_GPL(ubi_open_volume_nm);\n struct ubi_volume_desc *ubi_open_volume_path(const char *pathname, int mode)\n {\n \tint error, ubi_num, vol_id;\n-\tstruct path path;\n-\tstruct kstat stat;\n \n \tdbg_gen(\"open volume %s, mode %d\", pathname, mode);\n \n \tif (!pathname || !*pathname)\n \t\treturn ERR_PTR(-EINVAL);\n \n-\terror = kern_path(pathname, LOOKUP_FOLLOW, &path);\n-\tif (error)\n-\t\treturn ERR_PTR(error);\n-\n-\terror = vfs_getattr(&path, &stat, STATX_TYPE, AT_STATX_SYNC_AS_STAT);\n-\tpath_put(&path);\n+\terror = ubi_get_num_by_path(pathname, &ubi_num, &vol_id);\n \tif (error)\n \t\treturn ERR_PTR(error);\n \n-\tif (!S_ISCHR(stat.mode))\n-\t\treturn ERR_PTR(-EINVAL);\n-\n-\tubi_num = ubi_major2num(MAJOR(stat.rdev));\n-\tvol_id = MINOR(stat.rdev) - 1;\n-\n-\tif (vol_id >= 0 && ubi_num >= 0)\n-\t\treturn ubi_open_volume(ubi_num, vol_id, mode);\n-\treturn ERR_PTR(-ENODEV);\n+\treturn ubi_open_volume(ubi_num, vol_id, mode);\n }\n EXPORT_SYMBOL_GPL(ubi_open_volume_path);\n \ndiff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h\nindex a5ec566df0d74..17b463804c979 100644\n--- a/drivers/mtd/ubi/ubi.h\n+++ b/drivers/mtd/ubi/ubi.h\n@@ -962,6 +962,7 @@ void ubi_free_internal_volumes(struct ubi_device *ubi);\n void ubi_do_get_device_info(struct ubi_device *ubi, struct ubi_device_info *di);\n void ubi_do_get_volume_info(struct ubi_device *ubi, struct ubi_volume *vol,\n \t\t\t    struct ubi_volume_info *vi);\n+int ubi_get_num_by_path(const char *pathname, int *ubi_num, int *vol_id);\n /* scan.c */\n int ubi_compare_lebs(struct ubi_device *ubi, const struct ubi_ainf_peb *aeb,\n \t\t      int pnum, const struct ubi_vid_hdr *vid_hdr);\n",
    "prefixes": [
        "v7",
        "3/7"
    ]
}