kernel: Fix compile warning
[openwrt/staging/mkresin.git] / target / linux / generic / pending-5.10 / 492-try-auto-mounting-ubi0-rootfs-in-init-do_mounts.c.patch
1 From: Daniel Golle <daniel@makrotopia.org>
2 Subject: try auto-mounting ubi0:rootfs in init/do_mounts.c
3
4 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
5 ---
6 init/do_mounts.c | 26 +++++++++++++++++++++++++-
7 1 file changed, 25 insertions(+), 1 deletion(-)
8
9 --- a/init/do_mounts.c
10 +++ b/init/do_mounts.c
11 @@ -474,7 +474,30 @@ retry:
12 out:
13 put_page(page);
14 }
15 -
16 +
17 +#ifdef CONFIG_MTD_ROOTFS_ROOT_DEV
18 +static int __init mount_ubi_rootfs(void)
19 +{
20 + int flags = MS_SILENT;
21 + int err, tried = 0;
22 +
23 + while (tried < 2) {
24 + err = do_mount_root("ubi0:rootfs", "ubifs", flags, \
25 + root_mount_data);
26 + switch (err) {
27 + case -EACCES:
28 + flags |= MS_RDONLY;
29 + tried++;
30 + break;
31 + default:
32 + return err;
33 + }
34 + }
35 +
36 + return -EINVAL;
37 +}
38 +#endif
39 +
40 #ifdef CONFIG_ROOT_NFS
41
42 #define NFSROOT_TIMEOUT_MIN 5
43 @@ -567,6 +590,10 @@ void __init mount_root(void)
44 return;
45 }
46 #endif
47 +#ifdef CONFIG_MTD_ROOTFS_ROOT_DEV
48 + if (!mount_ubi_rootfs())
49 + return;
50 +#endif
51 #ifdef CONFIG_BLOCK
52 {
53 int err = create_dev("/dev/root", ROOT_DEV);