aboutsummaryrefslogtreecommitdiff
path: root/target/linux/generic/pending-6.1/450-06-mtd-ubi-populate-ubi-volume-fwnode.patch
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2023-12-04 23:48:40 +0000
committerDaniel Golle <daniel@makrotopia.org>2024-02-15 19:06:36 +0000
commitfc153aa8d94ffe09d5ff50e2a73a6dfc209d8545 (patch)
treea82909610b478b35864c2a1f28048e7c8d172b38 /target/linux/generic/pending-6.1/450-06-mtd-ubi-populate-ubi-volume-fwnode.patch
parentcff4335245e0d23e27917c6cb8f3e1eefda5bb1e (diff)
kernel: import pending patches adding support for NVMEM on UBI and MMC
Similar to supporting nvmem-layouts on MTD devices, also allow referencing UBI and MMC devices in DT. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'target/linux/generic/pending-6.1/450-06-mtd-ubi-populate-ubi-volume-fwnode.patch')
-rw-r--r--target/linux/generic/pending-6.1/450-06-mtd-ubi-populate-ubi-volume-fwnode.patch65
1 files changed, 65 insertions, 0 deletions
diff --git a/target/linux/generic/pending-6.1/450-06-mtd-ubi-populate-ubi-volume-fwnode.patch b/target/linux/generic/pending-6.1/450-06-mtd-ubi-populate-ubi-volume-fwnode.patch
new file mode 100644
index 0000000000..1322766965
--- /dev/null
+++ b/target/linux/generic/pending-6.1/450-06-mtd-ubi-populate-ubi-volume-fwnode.patch
@@ -0,0 +1,65 @@
+From 3a041ee543cdf2e707a1dd72946cd6a583509b28 Mon Sep 17 00:00:00 2001
+From: Daniel Golle <daniel@makrotopia.org>
+Date: Fri, 21 Jul 2023 19:26:37 +0100
+Subject: [PATCH 06/15] mtd: ubi: populate ubi volume fwnode
+
+Look for the 'volumes' subnode of an MTD partition attached to a UBI
+device and attach matching child nodes to UBI volumes.
+This allows UBI volumes to be referenced in device tree, e.g. for use
+as NVMEM providers.
+
+Signed-off-by: Daniel Golle <daniel@makrotopia.org>
+---
+ drivers/mtd/ubi/vmt.c | 27 +++++++++++++++++++++++++++
+ 1 file changed, 27 insertions(+)
+
+--- a/drivers/mtd/ubi/vmt.c
++++ b/drivers/mtd/ubi/vmt.c
+@@ -124,6 +124,31 @@ static void vol_release(struct device *d
+ kfree(vol);
+ }
+
++static struct fwnode_handle *find_volume_fwnode(struct ubi_volume *vol)
++{
++ struct fwnode_handle *fw_vols, *fw_vol;
++ const char *volname;
++ u32 volid;
++
++ fw_vols = device_get_named_child_node(vol->dev.parent->parent, "volumes");
++ if (!fw_vols)
++ return NULL;
++
++ fwnode_for_each_child_node(fw_vols, fw_vol) {
++ if (!fwnode_property_read_string(fw_vol, "volname", &volname) &&
++ strncmp(volname, vol->name, vol->name_len))
++ continue;
++
++ if (!fwnode_property_read_u32(fw_vol, "volid", &volid) &&
++ vol->vol_id != volid)
++ continue;
++
++ return fw_vol;
++ }
++
++ return NULL;
++}
++
+ /**
+ * ubi_create_volume - create volume.
+ * @ubi: UBI device description object
+@@ -223,6 +248,7 @@ int ubi_create_volume(struct ubi_device
+ vol->name_len = req->name_len;
+ memcpy(vol->name, req->name, vol->name_len);
+ vol->ubi = ubi;
++ device_set_node(&vol->dev, find_volume_fwnode(vol));
+
+ /*
+ * Finish all pending erases because there may be some LEBs belonging
+@@ -605,6 +631,7 @@ int ubi_add_volume(struct ubi_device *ub
+ vol->dev.class = &ubi_class;
+ vol->dev.groups = volume_dev_groups;
+ dev_set_name(&vol->dev, "%s_%d", ubi->ubi_name, vol->vol_id);
++ device_set_node(&vol->dev, find_volume_fwnode(vol));
+ err = device_register(&vol->dev);
+ if (err) {
+ cdev_del(&vol->cdev);