dbbe68ff4a3259804332afef07799b43746f8916
[openwrt/openwrt.git] / target / linux / generic / hack-4.14 / 401-inherit-parent-partition-access-mode.patch
1 --- a/drivers/mtd/mtdchar.c
2 +++ b/drivers/mtd/mtdchar.c
3 @@ -595,7 +595,10 @@
4 /* Sanitize user input */
5 p.devname[BLKPG_DEVNAMELTH - 1] = '\0';
6
7 - return mtd_add_partition(mtd, p.devname, p.start, p.length);
8 + /* No mtd flags masking required */
9 + uint32_t mask_flags = 0;
10 +
11 + return mtd_add_partition(mtd, p.devname, p.start, p.length, mask_flags);
12
13 case BLKPG_DEL_PARTITION:
14
15 --- a/drivers/mtd/mtdpart.c
16 +++ b/drivers/mtd/mtdpart.c
17 @@ -726,7 +726,7 @@
18 }
19
20 int mtd_add_partition(struct mtd_info *parent, const char *name,
21 - long long offset, long long length)
22 + long long offset, long long length, uint32_t mask_flags)
23 {
24 struct mtd_partition part;
25 struct mtd_part *new;
26 @@ -747,6 +747,7 @@
27 part.name = name;
28 part.size = length;
29 part.offset = offset;
30 + part.mask_flags = mask_flags;
31
32 new = allocate_partition(parent, &part, -1, offset);
33 if (IS_ERR(new))
34 @@ -855,10 +856,14 @@
35 /* adjust partition offsets */
36 parts[i].offset += slave->offset;
37
38 + /* adjust partition mask */
39 + parts[i].mask_flags = !(slave->mtd.flags & MTD_WRITEABLE) ? MTD_WRITEABLE : 0;
40 +
41 mtd_add_partition(slave->parent,
42 parts[i].name,
43 parts[i].offset,
44 - parts[i].size);
45 + parts[i].size,
46 + parts[i].mask_flags);
47 }
48
49 kfree(parts);
50 --- a/include/linux/mtd/partitions.h
51 +++ b/include/linux/mtd/partitions.h
52 @@ -114,7 +114,7 @@
53
54 int mtd_is_partition(const struct mtd_info *mtd);
55 int mtd_add_partition(struct mtd_info *master, const char *name,
56 - long long offset, long long length);
57 + long long offset, long long length, uint32_t mask_flags);
58 int mtd_del_partition(struct mtd_info *master, int partno);
59 struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd);
60 uint64_t mtdpart_get_offset(const struct mtd_info *mtd);