kernel: backport patch to relax mtdblock NAND warning
[openwrt/staging/mkresin.git] / target / linux / generic / backport-5.15 / 400-mtdblock-warn-if-opened-on-NAND.patch
1 From 96a3295c351da82d7af99b2fc004a3cf9f4716a9 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= <bjorn@mork.no>
3 Date: Mon, 28 Mar 2022 18:11:08 +0200
4 Subject: [PATCH] mtdblock: warn if opened on NAND
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Warning on every translated mtd partition results in excessive log noise
10 if this driver is loaded:
11
12 nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1
13 nand: Macronix MX30LF1G18AC
14 nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
15 mt7621-nand 1e003000.nand: ECC strength adjusted to 4 bits
16 read_bbt: found bbt at block 1023
17 10 fixed-partitions partitions found on MTD device mt7621-nand
18 Creating 10 MTD partitions on "mt7621-nand":
19 0x000000000000-0x000000080000 : "Bootloader"
20 mtdblock: MTD device 'Bootloader' is NAND, please consider using UBI block devices instead.
21 0x000000080000-0x000000100000 : "Config"
22 mtdblock: MTD device 'Config' is NAND, please consider using UBI block devices instead.
23 0x000000100000-0x000000140000 : "Factory"
24 mtdblock: MTD device 'Factory' is NAND, please consider using UBI block devices instead.
25 0x000000140000-0x000002000000 : "Kernel"
26 mtdblock: MTD device 'Kernel' is NAND, please consider using UBI block devices instead.
27 0x000000540000-0x000002000000 : "ubi"
28 mtdblock: MTD device 'ubi' is NAND, please consider using UBI block devices instead.
29 0x000002140000-0x000004000000 : "Kernel2"
30 mtdblock: MTD device 'Kernel2' is NAND, please consider using UBI block devices instead.
31 0x000004000000-0x000004100000 : "wwan"
32 mtdblock: MTD device 'wwan' is NAND, please consider using UBI block devices instead.
33 0x000004100000-0x000005100000 : "data"
34 mtdblock: MTD device 'data' is NAND, please consider using UBI block devices instead.
35 0x000005100000-0x000005200000 : "rom-d"
36 mtdblock: MTD device 'rom-d' is NAND, please consider using UBI block devices instead.
37 0x000005200000-0x000005280000 : "reserve"
38 mtdblock: MTD device 'reserve' is NAND, please consider using UBI block devices instead.
39 mtk_soc_eth 1e100000.ethernet eth0: mediatek frame engine at 0xbe100000, irq 21
40
41 This is more likely to annoy than to help users of embedded distros where
42 this driver is enabled by default. Making the blockdevs available does
43 not imply that they are in use, and warning about bootloader partitions
44 or other devices which obviously never will be mounted is more confusing
45 than helpful.
46
47 Move the warning to open(), where it will be of more use - actually warning
48 anyone who mounts a file system on NAND using mtdblock.
49
50 Fixes: e07403a8c6be ("mtdblock: Warn if added for a NAND device")
51 Signed-off-by: Bjørn Mork <bjorn@mork.no>
52 Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
53 Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
54 Link: https://lore.kernel.org/linux-mtd/20220328161108.87757-1-bjorn@mork.no
55 ---
56 drivers/mtd/mtdblock.c | 8 ++++----
57 1 file changed, 4 insertions(+), 4 deletions(-)
58
59 --- a/drivers/mtd/mtdblock.c
60 +++ b/drivers/mtd/mtdblock.c
61 @@ -257,6 +257,10 @@ static int mtdblock_open(struct mtd_blkt
62 return 0;
63 }
64
65 + if (mtd_type_is_nand(mbd->mtd))
66 + pr_warn("%s: MTD device '%s' is NAND, please consider using UBI block devices instead.\n",
67 + mbd->tr->name, mbd->mtd->name);
68 +
69 /* OK, it's not open. Create cache info for it */
70 mtdblk->count = 1;
71 mutex_init(&mtdblk->cache_mutex);
72 @@ -322,10 +326,6 @@ static void mtdblock_add_mtd(struct mtd_
73 if (!(mtd->flags & MTD_WRITEABLE))
74 dev->mbd.readonly = 1;
75
76 - if (mtd_type_is_nand(mtd))
77 - pr_warn("%s: MTD device '%s' is NAND, please consider using UBI block devices instead.\n",
78 - tr->name, mtd->name);
79 -
80 if (add_mtd_blktrans_dev(&dev->mbd))
81 kfree(dev);
82 }