From: Sam Edwards <cfsworks@gmail.com>
To: Heiko Schocher <hs@denx.de>, Kyungmin Park <kmpark@infradead.org>
Cc: u-boot@lists.denx.de, Sam Edwards <CFSworks@gmail.com>
Subject: [RFC PATCH 4/4] HACK: enable access to `ubi 0:volname` block devices
Date: Fri, 11 Aug 2023 18:06:06 -0600 [thread overview]
Message-ID: <20230812000606.72319-5-CFSworks@gmail.com> (raw)
In-Reply-To: <20230812000606.72319-1-CFSworks@gmail.com>
---
disk/part.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/disk/part.c b/disk/part.c
index 1ad8277b65..85eb51429a 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -14,6 +14,9 @@
#include <malloc.h>
#include <part.h>
#include <ubifs_uboot.h>
+#include <dm.h>
+#include <dm/device-internal.h>
+#include <dm/uclass-internal.h>
#undef PART_DEBUG
@@ -505,6 +508,59 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
}
#endif
+#if IS_ENABLED(CONFIG_CMD_UBI) && !IS_ENABLED(CONFIG_SPL_BUILD)
+ /*
+ * Also special-case UBI, which may use names to find the specific
+ * volumes, so this deviates a bit from the typical devnum:partnum
+ * syntax.
+ */
+ if (!strcmp(ifname, "ubi")) {
+ dev = hextoul(dev_part_str, &ep);
+ if (*ep == ':') {
+ struct udevice *ubi_dev = NULL;
+ struct udevice *vol_dev = NULL;
+ part_str = &ep[1];
+
+ ret = uclass_find_device(UCLASS_UBI, dev, &ubi_dev);
+ if (!ubi_dev || ret) {
+ printf("** Cannot find UBI %x\n", dev);
+ return -EINVAL;
+ }
+
+ part = hextoul(part_str, &ep);
+ if (!*ep) {
+ struct udevice *tmp_dev;
+ device_foreach_child(tmp_dev, ubi_dev) {
+ struct blk_desc *desc = dev_get_uclass_plat(tmp_dev);
+ if (desc->devnum == part) {
+ vol_dev = tmp_dev;
+ break;
+ }
+ }
+ }
+
+ if (!vol_dev)
+ ret = device_find_child_by_name(ubi_dev, part_str, &vol_dev);
+
+ if (!vol_dev || ret) {
+ printf("** UBI volume %s not found\n", part_str);
+ return -EINVAL;
+ }
+
+ ret = device_probe(vol_dev);
+ if (ret)
+ return ret;
+
+ *dev_desc = dev_get_uclass_plat(vol_dev);
+ part_get_info_whole_disk(*dev_desc, info);
+ return 0;
+ }
+
+ printf("UBIFS not mounted, use ubifsmount to mount volume first!\n");
+ return -EINVAL;
+ }
+#endif
+
/* If no dev_part_str, use bootdevice environment variable */
if (!dev_part_str || !strlen(dev_part_str) ||
!strcmp(dev_part_str, "-"))
--
2.41.0
next prev parent reply other threads:[~2023-08-12 0:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-12 0:06 [RFC PATCH 0/4] mtd: ubi: Enable accessing RO filesystems in UBI vols Sam Edwards
2023-08-12 0:06 ` [RFC PATCH 1/4] mtd: ubi: register UBI attachments as DM devices Sam Edwards
2023-08-12 0:06 ` [RFC PATCH 2/4] mtd: ubi: bind block device driver for static volumes Sam Edwards
2023-08-12 0:06 ` [RFC PATCH 3/4] disk: part: fall-through if "ubi" requested but ubifs not mounted Sam Edwards
2023-08-12 0:06 ` Sam Edwards [this message]
2023-08-14 6:45 ` [RFC PATCH 0/4] mtd: ubi: Enable accessing RO filesystems in UBI vols Heiko Schocher
2023-09-07 21:46 ` Sam Edwards
2023-09-21 6:44 ` Heiko Schocher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230812000606.72319-5-CFSworks@gmail.com \
--to=cfsworks@gmail.com \
--cc=hs@denx.de \
--cc=kmpark@infradead.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.