OpenWrt – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | From: Felix Fietkau <nbd@nbd.name> |
2 | Subject: make rootfs split/detection more generic - patch can be moved to generic-2.6 after testing on other platforms |
||
3 | |||
4 | lede-commit: 328e660b31f0937d52c5ae3d6e7029409918a9df |
||
5 | Signed-off-by: Felix Fietkau <nbd@nbd.name> |
||
6 | --- |
||
7 | drivers/mtd/Kconfig | 17 +++++++++++++++++ |
||
8 | drivers/mtd/mtdpart.c | 35 +++++++++++++++++++++++++++++++++++ |
||
9 | include/linux/mtd/partitions.h | 2 ++ |
||
10 | 3 files changed, 54 insertions(+) |
||
11 | |||
12 | --- a/drivers/mtd/Kconfig |
||
13 | +++ b/drivers/mtd/Kconfig |
||
14 | @@ -11,6 +11,23 @@ menuconfig MTD |
||
15 | |||
16 | if MTD |
||
17 | |||
18 | +menu "OpenWrt specific MTD options" |
||
19 | + |
||
20 | +config MTD_ROOTFS_ROOT_DEV |
||
21 | + bool "Automatically set 'rootfs' partition to be root filesystem" |
||
22 | + default y |
||
23 | + |
||
24 | +config MTD_SPLIT_FIRMWARE |
||
25 | + bool "Automatically split firmware partition for kernel+rootfs" |
||
26 | + default y |
||
27 | + |
||
28 | +config MTD_SPLIT_FIRMWARE_NAME |
||
29 | + string "Firmware partition name" |
||
30 | + depends on MTD_SPLIT_FIRMWARE |
||
31 | + default "firmware" |
||
32 | + |
||
33 | +endmenu |
||
34 | + |
||
35 | config MTD_TESTS |
||
36 | tristate "MTD tests support (DANGEROUS)" |
||
37 | depends on m |
||
38 | --- a/drivers/mtd/mtdpart.c |
||
39 | +++ b/drivers/mtd/mtdpart.c |
||
40 | @@ -29,10 +29,12 @@ |
||
41 | #include <linux/kmod.h> |
||
42 | #include <linux/mtd/mtd.h> |
||
43 | #include <linux/mtd/partitions.h> |
||
44 | +#include <linux/magic.h> |
||
45 | #include <linux/err.h> |
||
46 | #include <linux/of.h> |
||
47 | |||
48 | #include "mtdcore.h" |
||
49 | +#include "mtdsplit/mtdsplit.h" |
||
50 | |||
51 | /* Our partition linked list */ |
||
52 | static LIST_HEAD(mtd_partitions); |
||
53 | @@ -52,6 +54,8 @@ struct mtd_part { |
||
54 | struct list_head list; |
||
55 | }; |
||
56 | |||
57 | +static void mtd_partition_split(struct mtd_info *master, struct mtd_part *part); |
||
58 | + |
||
59 | /* |
||
60 | * Given a pointer to the MTD object in the mtd_part structure, we can retrieve |
||
61 | * the pointer to that structure. |
||
62 | @@ -623,6 +627,7 @@ int mtd_add_partition(struct mtd_info *p |
||
63 | mutex_unlock(&mtd_partitions_mutex); |
||
64 | |||
65 | add_mtd_device(&new->mtd); |
||
66 | + mtd_partition_split(parent, new); |
||
67 | |||
68 | mtd_add_partition_attrs(new); |
||
69 | |||
70 | @@ -701,6 +706,29 @@ int mtd_del_partition(struct mtd_info *m |
||
71 | } |
||
72 | EXPORT_SYMBOL_GPL(mtd_del_partition); |
||
73 | |||
74 | +#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME |
||
75 | +#define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME |
||
76 | +#else |
||
77 | +#define SPLIT_FIRMWARE_NAME "unused" |
||
78 | +#endif |
||
79 | + |
||
80 | +static void split_firmware(struct mtd_info *master, struct mtd_part *part) |
||
81 | +{ |
||
82 | +} |
||
83 | + |
||
84 | +static void mtd_partition_split(struct mtd_info *master, struct mtd_part *part) |
||
85 | +{ |
||
86 | + static int rootfs_found = 0; |
||
87 | + |
||
88 | + if (rootfs_found) |
||
89 | + return; |
||
90 | + |
||
91 | + if (IS_ENABLED(CONFIG_MTD_SPLIT_FIRMWARE) && |
||
92 | + !strcmp(part->mtd.name, SPLIT_FIRMWARE_NAME) && |
||
93 | + !of_find_property(mtd_get_of_node(&part->mtd), "compatible", NULL)) |
||
94 | + split_firmware(master, part); |
||
95 | +} |
||
96 | + |
||
97 | /* |
||
98 | * This function, given a master MTD object and a partition table, creates |
||
99 | * and registers slave MTD objects which are bound to the master according to |
||
100 | @@ -732,6 +760,7 @@ int add_mtd_partitions(struct mtd_info * |
||
101 | mutex_unlock(&mtd_partitions_mutex); |
||
102 | |||
103 | add_mtd_device(&slave->mtd); |
||
104 | + mtd_partition_split(master, slave); |
||
105 | mtd_add_partition_attrs(slave); |
||
106 | /* Look for subpartitions */ |
||
107 | parse_mtd_partitions(&slave->mtd, parts[i].types, NULL); |