kernel: bump 5.10 to 5.10.178
[openwrt/staging/dedeckeh.git] / target / linux / generic / hack-5.10 / 410-block-fit-partition-parser.patch
index c417c78eb6c2a8c23cfc032616ba6be2de4e97fa..52d8e24d0f37a1480c6ee8af47c7e4ba071f432b 100644 (file)
@@ -1,10 +1,38 @@
+From: Daniel Golle <daniel@makrotopia.org>
+Subject: [PATCH] kernel: fix FIT partition parser compatibility issues
+
+The uImage.FIT partition parser used to squeeze in FIT partitions in
+the range where partition editor tools (fdisk and such) expect the
+regular partition. This is confusing people and tools when adding
+additional partitions on top of the partition used for OpenWrt's
+uImage.FIT.
+Instead of squeezing in the additional partitions, rather start with
+all uImage.FIT partitions at offset 64.
+
+Submitted-by: Daniel Golle <daniel@makrotopia.org>
+---
+ block/blk.h                                            |  2 ++
+ block/partitions/Kconfig                               |  7 +++
+ block/partitions/Makefile                              |  1 +
+ block/partitions/check.h                               |  3 ++
+ block/partitions/core.c                                | 15 +++++++
+ drivers/mtd/ubi/block.c                                |  7 +++
+ block/partitions/efi.c                                 |  8 +++++++
+ block/partitions/efi.h                                 |  3 ++
+ drivers/mtd/mtdblock.c                                 |  4 +++
+ drivers/mtd/mtd_blkdevs.c                              | 14 +------
+ block/partitions/msdos.c                               | 10 ++++++
+ include/linux/msdos_partition.h                        |  1 +
+ 12 files changed, 52 insertions(+), 13 deletions(-)
+
 --- a/block/blk.h
 +++ b/block/blk.h
-@@ -355,6 +355,7 @@ char *disk_name(struct gendisk *hd, int
+@@ -361,6 +361,8 @@ char *disk_name(struct gendisk *hd, int
  #define ADDPART_FLAG_NONE     0
  #define ADDPART_FLAG_RAID     1
  #define ADDPART_FLAG_WHOLEDISK        2
-+#define ADDPART_FLAG_ROOTDEV  4
++#define ADDPART_FLAG_READONLY 4
++#define ADDPART_FLAG_ROOTDEV  8
  void delete_partition(struct hd_struct *part);
  int bdev_add_partition(struct block_device *bdev, int partno,
                sector_t start, sector_t length);
  #ifdef CONFIG_SGI_PARTITION
        sgi_partition,
  #endif
-@@ -215,6 +222,18 @@ static ssize_t part_discard_alignment_sh
-                               p->start_sect));
- }
-+static ssize_t part_name_show(struct device *dev,
-+                            struct device_attribute *attr, char *buf)
-+{
-+      struct hd_struct *p = dev_to_part(dev);
-+
-+      if (p->info && p->info->volname)
-+              return sprintf(buf, "%s\n", p->info->volname);
-+
-+      buf[0] = '\0';
-+      return 0;
-+}
-+
- static DEVICE_ATTR(partition, 0444, part_partition_show, NULL);
- static DEVICE_ATTR(start, 0444, part_start_show, NULL);
- static DEVICE_ATTR(size, 0444, part_size_show, NULL);
-@@ -223,6 +242,7 @@ static DEVICE_ATTR(alignment_offset, 044
- static DEVICE_ATTR(discard_alignment, 0444, part_discard_alignment_show, NULL);
- static DEVICE_ATTR(stat, 0444, part_stat_show, NULL);
- static DEVICE_ATTR(inflight, 0444, part_inflight_show, NULL);
-+static DEVICE_ATTR(name, 0444, part_name_show, NULL);
- #ifdef CONFIG_FAIL_MAKE_REQUEST
- static struct device_attribute dev_attr_fail =
-       __ATTR(make-it-fail, 0644, part_fail_show, part_fail_store);
-@@ -237,6 +257,7 @@ static struct attribute *part_attrs[] =
-       &dev_attr_discard_alignment.attr,
-       &dev_attr_stat.attr,
-       &dev_attr_inflight.attr,
-+      &dev_attr_name.attr,
- #ifdef CONFIG_FAIL_MAKE_REQUEST
-       &dev_attr_fail.attr,
- #endif
-@@ -694,6 +715,11 @@ static bool blk_add_partition(struct gen
+@@ -701,6 +708,14 @@ static bool blk_add_partition(struct gen
            (state->parts[p].flags & ADDPART_FLAG_RAID))
                md_autodetect_dev(part_to_dev(part)->devt);
  
 +#ifdef CONFIG_FIT_PARTITION
 +      if ((state->parts[p].flags & ADDPART_FLAG_ROOTDEV) && ROOT_DEV == 0)
 +              ROOT_DEV = part_to_dev(part)->devt;
++
++      if (state->parts[p].flags & ADDPART_FLAG_READONLY)
++              part->policy = true;
 +#endif
 +
        return true;
        __le64 signature;
 --- a/drivers/mtd/mtdblock.c
 +++ b/drivers/mtd/mtdblock.c
-@@ -334,7 +334,11 @@ static void mtdblock_remove_dev(struct m
+@@ -338,7 +338,11 @@ static void mtdblock_remove_dev(struct m
  static struct mtd_blktrans_ops mtdblock_tr = {
        .name           = "mtdblock",
        .major          = MTD_BLOCK_MAJOR,
 +#ifdef CONFIG_FIT_PARTITION
-+      .part_bits      = 1,
++      .part_bits      = 2,
 +#else
        .part_bits      = 0,
 +#endif