[openwrt/openwrt] kernel: mtd: ubi: avoid attaching "linux,ubi" mtd again

LEDE Commits lede-commits at lists.infradead.org
Fri Jun 28 12:56:16 PDT 2024


dangole pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/007437c225d4e5b165ec5fe7d90eb00ef20fb6da

commit 007437c225d4e5b165ec5fe7d90eb00ef20fb6da
Author: Shiji Yang <yangshiji66 at qq.com>
AuthorDate: Fri Jun 21 13:56:23 2024 +0000

    kernel: mtd: ubi: avoid attaching "linux,ubi" mtd again
    
    "linux,ubi" compatible MTD device can be automatically attached early
    since commit fc153aa8d94f. Therefore, there is no need to attach MTD
    devices named "ubi" or "data" again.
    
    Signed-off-by: Shiji Yang <yangshiji66 at qq.com>
---
 ...-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/target/linux/generic/pending-6.6/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch b/target/linux/generic/pending-6.6/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch
index 6405865c45..defde3f426 100644
--- a/target/linux/generic/pending-6.6/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch
+++ b/target/linux/generic/pending-6.6/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch
@@ -8,7 +8,7 @@ Signed-off-by: Daniel Golle <daniel at makrotopia.org>
 
 --- a/drivers/mtd/ubi/build.c
 +++ b/drivers/mtd/ubi/build.c
-@@ -1258,6 +1258,74 @@ static struct mtd_notifier ubi_mtd_notif
+@@ -1258,6 +1258,80 @@ static struct mtd_notifier ubi_mtd_notif
  	.remove = ubi_notify_remove,
  };
  
@@ -21,6 +21,7 @@ Signed-off-by: Daniel Golle <daniel at makrotopia.org>
 +{
 +	int err;
 +	struct mtd_info *mtd;
++	struct device_node *np;
 +	loff_t offset = 0;
 +	size_t len;
 +	char magic[4];
@@ -33,6 +34,11 @@ Signed-off-by: Daniel Golle <daniel at makrotopia.org>
 +	if (IS_ERR(mtd))
 +		return;
 +
++	/* skip "linux,ubi" mtd as it has already been attached */
++	np = mtd_get_of_node(mtd);
++	if (of_device_is_compatible(np, "linux,ubi"))
++		goto cleanup;
++
 +	/* get the first not bad block */
 +	if (mtd_can_have_bb(mtd))
 +		while (mtd_block_isbad(mtd, offset)) {
@@ -83,7 +89,7 @@ Signed-off-by: Daniel Golle <daniel at makrotopia.org>
  static int __init ubi_init_attach(void)
  {
  	int err, i, k;
-@@ -1308,6 +1376,12 @@ static int __init ubi_init_attach(void)
+@@ -1308,6 +1382,12 @@ static int __init ubi_init_attach(void)
  		}
  	}
  




More information about the lede-commits mailing list