Skip to content

Commit f3cd013

Browse files
DragonBluepcoolsnowwolf
authored andcommitted
kernel: mtd: ubi: avoid attaching "linux,ubi" mtd again
"linux,ubi" compatible MTD device can be automatically attached early since commit fc153aa. Therefore, there is no need to attach MTD devices named "ubi" or "data" again. Signed-off-by: Shiji Yang <yangshiji66@qq.com>
1 parent 9f2db43 commit f3cd013

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

target/linux/generic/pending-6.6/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
88

99
--- a/drivers/mtd/ubi/build.c
1010
+++ b/drivers/mtd/ubi/build.c
11-
@@ -1258,6 +1258,74 @@ static struct mtd_notifier ubi_mtd_notif
11+
@@ -1258,6 +1258,80 @@ static struct mtd_notifier ubi_mtd_notif
1212
.remove = ubi_notify_remove,
1313
};
1414

@@ -21,6 +21,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2121
+{
2222
+ int err;
2323
+ struct mtd_info *mtd;
24+
+ struct device_node *np;
2425
+ loff_t offset = 0;
2526
+ size_t len;
2627
+ char magic[4];
@@ -33,6 +34,11 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
3334
+ if (IS_ERR(mtd))
3435
+ return;
3536
+
37+
+ /* skip "linux,ubi" mtd as it has already been attached */
38+
+ np = mtd_get_of_node(mtd);
39+
+ if (of_device_is_compatible(np, "linux,ubi"))
40+
+ goto cleanup;
41+
+
3642
+ /* get the first not bad block */
3743
+ if (mtd_can_have_bb(mtd))
3844
+ while (mtd_block_isbad(mtd, offset)) {
@@ -83,7 +89,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
8389
static int __init ubi_init_attach(void)
8490
{
8591
int err, i, k;
86-
@@ -1308,6 +1376,12 @@ static int __init ubi_init_attach(void)
92+
@@ -1308,6 +1382,12 @@ static int __init ubi_init_attach(void)
8793
}
8894
}
8995

0 commit comments

Comments
 (0)