aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/backport-5.15/406-v6.2-0001-mtd-core-simplify-a-bit-code-find-partition-matching.patch
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2022-10-18 22:12:27 +0200
committerRafał Miłecki <rafal@milecki.pl>2022-10-19 07:07:14 +0200
commit4eda414b09c790344e47c1cebe78e5433b4dc10d (patch)
treee60c3a824efa6b920dbe0021a31bd696c24b0d54 /target/linux/generic/backport-5.15/406-v6.2-0001-mtd-core-simplify-a-bit-code-find-partition-matching.patch
parent76a470d5df971bd4c7309480a585d7fbaef63621 (diff)
downloadupstream-4eda414b09c790344e47c1cebe78e5433b4dc10d.tar.gz
upstream-4eda414b09c790344e47c1cebe78e5433b4dc10d.tar.bz2
upstream-4eda414b09c790344e47c1cebe78e5433b4dc10d.zip
kernel: mtd: backport extended dynamic partitions support
This gets rid of "nvmem-cells" limitation. Dynamic partitions can be defined for any (sub)partitions layout. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Diffstat (limited to 'target/linux/generic/backport-5.15/406-v6.2-0001-mtd-core-simplify-a-bit-code-find-partition-matching.patch')
-rw-r--r--target/linux/generic/backport-5.15/406-v6.2-0001-mtd-core-simplify-a-bit-code-find-partition-matching.patch65
1 files changed, 65 insertions, 0 deletions
diff --git a/target/linux/generic/backport-5.15/406-v6.2-0001-mtd-core-simplify-a-bit-code-find-partition-matching.patch b/target/linux/generic/backport-5.15/406-v6.2-0001-mtd-core-simplify-a-bit-code-find-partition-matching.patch
new file mode 100644
index 0000000000..7e9645ea98
--- /dev/null
+++ b/target/linux/generic/backport-5.15/406-v6.2-0001-mtd-core-simplify-a-bit-code-find-partition-matching.patch
@@ -0,0 +1,65 @@
+From 63db0cb35e1cb3b3c134906d1062f65513fdda2d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Tue, 4 Oct 2022 10:37:09 +0200
+Subject: [PATCH] mtd: core: simplify (a bit) code find partition-matching
+ dynamic OF node
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+1. Don't hardcode "partition-" string twice
+2. Use simpler logic & use ->name to avoid of_property_read_string()
+3. Use mtd_get_of_node() helper
+
+Cc: Christian Marangi <ansuelsmth@gmail.com>
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
+Link: https://lore.kernel.org/linux-mtd/20221004083710.27704-1-zajec5@gmail.com
+---
+ drivers/mtd/mtdcore.c | 16 +++++++---------
+ 1 file changed, 7 insertions(+), 9 deletions(-)
+
+--- a/drivers/mtd/mtdcore.c
++++ b/drivers/mtd/mtdcore.c
+@@ -569,18 +569,16 @@ static void mtd_check_of_node(struct mtd
+ struct device_node *partitions, *parent_dn, *mtd_dn = NULL;
+ const char *pname, *prefix = "partition-";
+ int plen, mtd_name_len, offset, prefix_len;
+- struct mtd_info *parent;
+ bool found = false;
+
+ /* Check if MTD already has a device node */
+- if (dev_of_node(&mtd->dev))
++ if (mtd_get_of_node(mtd))
+ return;
+
+ /* Check if a partitions node exist */
+ if (!mtd_is_partition(mtd))
+ return;
+- parent = mtd->parent;
+- parent_dn = of_node_get(dev_of_node(&parent->dev));
++ parent_dn = of_node_get(mtd_get_of_node(mtd->parent));
+ if (!parent_dn)
+ return;
+
+@@ -593,15 +591,15 @@ static void mtd_check_of_node(struct mtd
+
+ /* Search if a partition is defined with the same name */
+ for_each_child_of_node(partitions, mtd_dn) {
+- offset = 0;
+-
+ /* Skip partition with no/wrong prefix */
+- if (!of_node_name_prefix(mtd_dn, "partition-"))
++ if (!of_node_name_prefix(mtd_dn, prefix))
+ continue;
+
+ /* Label have priority. Check that first */
+- if (of_property_read_string(mtd_dn, "label", &pname)) {
+- of_property_read_string(mtd_dn, "name", &pname);
++ if (!of_property_read_string(mtd_dn, "label", &pname)) {
++ offset = 0;
++ } else {
++ pname = mtd_dn->name;
+ offset = prefix_len;
+ }
+