image: add support for building FIT image with filesystem
[openwrt/openwrt.git] / target / linux / generic / hack-5.10 / 400-block-fit-partition-parser.patch
1 --- a/block/blk.h
2 +++ b/block/blk.h
3 @@ -357,6 +357,7 @@ char *disk_name(struct gendisk *hd, int
4 #define ADDPART_FLAG_NONE 0
5 #define ADDPART_FLAG_RAID 1
6 #define ADDPART_FLAG_WHOLEDISK 2
7 +#define ADDPART_FLAG_ROOTDEV 4
8 void delete_partition(struct hd_struct *part);
9 int bdev_add_partition(struct block_device *bdev, int partno,
10 sector_t start, sector_t length);
11 --- a/block/partitions/Kconfig
12 +++ b/block/partitions/Kconfig
13 @@ -101,6 +101,13 @@ config ATARI_PARTITION
14 Say Y here if you would like to use hard disks under Linux which
15 were partitioned under the Atari OS.
16
17 +config FIT_PARTITION
18 + bool "Flattened-Image-Tree (FIT) partition support" if PARTITION_ADVANCED
19 + default n
20 + help
21 + Say Y here if your system needs to mount the filesystem part of
22 + a Flattened-Image-Tree (FIT) image commonly used with Das U-Boot.
23 +
24 config IBM_PARTITION
25 bool "IBM disk label and partition support"
26 depends on PARTITION_ADVANCED && S390
27 --- a/block/partitions/Makefile
28 +++ b/block/partitions/Makefile
29 @@ -8,6 +8,7 @@ obj-$(CONFIG_ACORN_PARTITION) += acorn.o
30 obj-$(CONFIG_AMIGA_PARTITION) += amiga.o
31 obj-$(CONFIG_ATARI_PARTITION) += atari.o
32 obj-$(CONFIG_AIX_PARTITION) += aix.o
33 +obj-$(CONFIG_FIT_PARTITION) += fit.o
34 obj-$(CONFIG_CMDLINE_PARTITION) += cmdline.o
35 obj-$(CONFIG_MAC_PARTITION) += mac.o
36 obj-$(CONFIG_LDM_PARTITION) += ldm.o
37 --- a/block/partitions/check.h
38 +++ b/block/partitions/check.h
39 @@ -58,6 +58,7 @@ int amiga_partition(struct parsed_partit
40 int atari_partition(struct parsed_partitions *state);
41 int cmdline_partition(struct parsed_partitions *state);
42 int efi_partition(struct parsed_partitions *state);
43 +int fit_partition(struct parsed_partitions *state);
44 int ibm_partition(struct parsed_partitions *);
45 int karma_partition(struct parsed_partitions *state);
46 int ldm_partition(struct parsed_partitions *state);
47 --- a/block/partitions/core.c
48 +++ b/block/partitions/core.c
49 @@ -10,6 +10,8 @@
50 #include <linux/vmalloc.h>
51 #include <linux/blktrace_api.h>
52 #include <linux/raid/detect.h>
53 +#include <linux/root_dev.h>
54 +
55 #include "check.h"
56
57 static int (*check_part[])(struct parsed_partitions *) = {
58 @@ -46,6 +48,9 @@ static int (*check_part[])(struct parsed
59 #ifdef CONFIG_EFI_PARTITION
60 efi_partition, /* this must come before msdos */
61 #endif
62 +#ifdef CONFIG_FIT_PARTITION
63 + fit_partition,
64 +#endif
65 #ifdef CONFIG_SGI_PARTITION
66 sgi_partition,
67 #endif
68 @@ -694,6 +699,9 @@ static bool blk_add_partition(struct gen
69 (state->parts[p].flags & ADDPART_FLAG_RAID))
70 md_autodetect_dev(part_to_dev(part)->devt);
71
72 + if ((state->parts[p].flags & ADDPART_FLAG_ROOTDEV) && ROOT_DEV == 0)
73 + ROOT_DEV = part_to_dev(part)->devt;
74 +
75 return true;
76 }
77
78 --- a/drivers/mtd/ubi/block.c
79 +++ b/drivers/mtd/ubi/block.c
80 @@ -396,7 +396,7 @@ int ubiblock_create(struct ubi_volume_in
81 dev->leb_size = vi->usable_leb_size;
82
83 /* Initialize the gendisk of this ubiblock device */
84 - gd = alloc_disk(1);
85 + gd = alloc_disk(0);
86 if (!gd) {
87 pr_err("UBI: block: alloc_disk failed\n");
88 ret = -ENODEV;
89 @@ -413,6 +413,7 @@ int ubiblock_create(struct ubi_volume_in
90 goto out_put_disk;
91 }
92 gd->private_data = dev;
93 + gd->flags |= GENHD_FL_EXT_DEVT;
94 sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id);
95 set_capacity(gd, disk_capacity);
96 dev->gd = gd;