kernel: mtd: ubi: avoid attaching "linux,ubi" mtd again
"linux,ubi" compatible MTD device can be automatically attached early
since commit fc153aa8d9
. Therefore, there is no need to attach MTD
devices named "ubi" or "data" again.
Signed-off-by: Shiji Yang <yangshiji66@qq.com>
This commit is contained in:
parent
7c32295b00
commit
007437c225
1 changed files with 8 additions and 2 deletions
|
@ -8,7 +8,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||||
|
|
||||||
--- a/drivers/mtd/ubi/build.c
|
--- a/drivers/mtd/ubi/build.c
|
||||||
+++ b/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,
|
.remove = ubi_notify_remove,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||||
+{
|
+{
|
||||||
+ int err;
|
+ int err;
|
||||||
+ struct mtd_info *mtd;
|
+ struct mtd_info *mtd;
|
||||||
|
+ struct device_node *np;
|
||||||
+ loff_t offset = 0;
|
+ loff_t offset = 0;
|
||||||
+ size_t len;
|
+ size_t len;
|
||||||
+ char magic[4];
|
+ char magic[4];
|
||||||
|
@ -33,6 +34,11 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||||
+ if (IS_ERR(mtd))
|
+ if (IS_ERR(mtd))
|
||||||
+ return;
|
+ 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 */
|
+ /* get the first not bad block */
|
||||||
+ if (mtd_can_have_bb(mtd))
|
+ if (mtd_can_have_bb(mtd))
|
||||||
+ while (mtd_block_isbad(mtd, offset)) {
|
+ while (mtd_block_isbad(mtd, offset)) {
|
||||||
|
@ -83,7 +89,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||||
static int __init ubi_init_attach(void)
|
static int __init ubi_init_attach(void)
|
||||||
{
|
{
|
||||||
int err, i, k;
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue