OpenWrt – Blame information for rev 3
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | From: Gabor Juhos <juhosg@openwrt.org> |
2 | Subject: kernel/3.10: add separate rootfs partition parser |
||
3 | |||
4 | lede-commit: daec7ad7688415156e2730e401503d09bd3acf91 |
||
5 | Signed-off-by: Gabor Juhos <juhosg@openwrt.org> |
||
6 | --- |
||
7 | drivers/mtd/mtdpart.c | 29 +++++++++++++++++++++++++++++ |
||
8 | include/linux/mtd/mtd.h | 18 ++++++++++++++++++ |
||
9 | include/linux/mtd/partitions.h | 2 ++ |
||
10 | 3 files changed, 49 insertions(+) |
||
11 | |||
12 | --- a/drivers/mtd/mtdpart.c |
||
13 | +++ b/drivers/mtd/mtdpart.c |
||
3 | office | 14 | @@ -763,6 +763,17 @@ run_parsers_by_type(struct mtd_part *sla |
15 | return nr_parts; |
||
1 | office | 16 | } |
3 | office | 17 | |
18 | +static inline unsigned long |
||
19 | +mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len) |
||
20 | +{ |
||
21 | + unsigned long mask = mtd->erasesize - 1; |
||
22 | + |
||
23 | + len += offset & mask; |
||
24 | + len = (len + mask) & ~mask; |
||
25 | + len -= offset & mask; |
||
26 | + return len; |
||
27 | +} |
||
28 | + |
||
29 | #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME |
||
30 | #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME |
||
31 | #else |
||
32 | @@ -1225,6 +1236,24 @@ int mtd_is_partition(const struct mtd_in |
||
33 | } |
||
1 | office | 34 | EXPORT_SYMBOL_GPL(mtd_is_partition); |
35 | |||
36 | +struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd) |
||
37 | +{ |
||
38 | + if (!mtd_is_partition(mtd)) |
||
39 | + return (struct mtd_info *)mtd; |
||
40 | + |
||
41 | + return mtd_to_part(mtd)->parent; |
||
42 | +} |
||
43 | +EXPORT_SYMBOL_GPL(mtdpart_get_master); |
||
44 | + |
||
45 | +uint64_t mtdpart_get_offset(const struct mtd_info *mtd) |
||
46 | +{ |
||
47 | + if (!mtd_is_partition(mtd)) |
||
48 | + return 0; |
||
49 | + |
||
50 | + return mtd_to_part(mtd)->offset; |
||
51 | +} |
||
52 | +EXPORT_SYMBOL_GPL(mtdpart_get_offset); |
||
53 | + |
||
54 | /* Returns the size of the entire flash chip */ |
||
55 | uint64_t mtd_get_device_size(const struct mtd_info *mtd) |
||
56 | { |
||
57 | --- a/include/linux/mtd/mtd.h |
||
58 | +++ b/include/linux/mtd/mtd.h |
||
59 | @@ -485,6 +485,24 @@ static inline uint32_t mtd_mod_by_eb(uin |
||
60 | return do_div(sz, mtd->erasesize); |
||
61 | } |
||
62 | |||
63 | +static inline uint64_t mtd_roundup_to_eb(uint64_t sz, struct mtd_info *mtd) |
||
64 | +{ |
||
65 | + if (mtd_mod_by_eb(sz, mtd) == 0) |
||
66 | + return sz; |
||
67 | + |
||
68 | + /* Round up to next erase block */ |
||
69 | + return (mtd_div_by_eb(sz, mtd) + 1) * mtd->erasesize; |
||
70 | +} |
||
71 | + |
||
72 | +static inline uint64_t mtd_rounddown_to_eb(uint64_t sz, struct mtd_info *mtd) |
||
73 | +{ |
||
74 | + if (mtd_mod_by_eb(sz, mtd) == 0) |
||
75 | + return sz; |
||
76 | + |
||
77 | + /* Round down to the start of the current erase block */ |
||
78 | + return (mtd_div_by_eb(sz, mtd)) * mtd->erasesize; |
||
79 | +} |
||
80 | + |
||
81 | static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd) |
||
82 | { |
||
83 | if (mtd->writesize_shift) |
||
84 | --- a/include/linux/mtd/partitions.h |
||
85 | +++ b/include/linux/mtd/partitions.h |
||
3 | office | 86 | @@ -115,6 +115,8 @@ int mtd_is_partition(const struct mtd_in |
1 | office | 87 | int mtd_add_partition(struct mtd_info *master, const char *name, |
88 | long long offset, long long length); |
||
89 | int mtd_del_partition(struct mtd_info *master, int partno); |
||
90 | +struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd); |
||
91 | +uint64_t mtdpart_get_offset(const struct mtd_info *mtd); |
||
92 | uint64_t mtd_get_device_size(const struct mtd_info *mtd); |
||
3 | office | 93 | extern void __weak arch_split_mtd_part(struct mtd_info *master, |
94 | const char *name, int offset, int size); |