linux/generic/pending-5.15: add missing patch headers
[openwrt/staging/jow.git] / target / linux / generic / pending-5.15 / 400-mtd-mtdsplit-support.patch
index 1acb8d718fafe0f635da01f846d260f814172bfd..63df1d070d0a9bfb2f3378778fa94162209c2490 100644 (file)
@@ -1,3 +1,18 @@
+From 39717277d5c87bdb183cf2f258957b44ba99b4df Mon Sep 17 00:00:00 2001
+From: OpenWrt community <openwrt-devel@lists.openwrt.org>
+Date: Wed, 13 Jul 2022 11:47:35 +0200
+Subject: [PATCH] mtd: mtdsplit support
+
+---
+ drivers/mtd/Kconfig            |  19 ++++
+ drivers/mtd/Makefile           |   2 +
+ drivers/mtd/mtdpart.c          | 169 ++++++++++++++++++++++++++++-----
+ include/linux/mtd/mtd.h        |  25 +++++
+ include/linux/mtd/partitions.h |   7 ++
+ 5 files changed, 197 insertions(+), 25 deletions(-)
+
+diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
+index 796a2eccbef0..f9ed93c4cf0f 100644
 --- a/drivers/mtd/Kconfig
 +++ b/drivers/mtd/Kconfig
 @@ -12,6 +12,25 @@ menuconfig MTD
  config MTD_TESTS
        tristate "MTD tests support (DANGEROUS)"
        depends on m
+diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
+index 593d0593a038..b14b7fe0f597 100644
+--- a/drivers/mtd/Makefile
++++ b/drivers/mtd/Makefile
+@@ -9,6 +9,8 @@ mtd-y                          := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o
+ obj-y                         += parsers/
++obj-$(CONFIG_MTD_SPLIT)               += mtdsplit/
++
+ # 'Users' - code which presents functionality to userspace.
+ obj-$(CONFIG_MTD_BLKDEVS)     += mtd_blkdevs.o
+ obj-$(CONFIG_MTD_BLOCK)               += mtdblock.o
+diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
+index d442fa94c872..f1ed12aae1fe 100644
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -15,10 +15,12 @@
+@@ -15,11 +15,13 @@
  #include <linux/kmod.h>
  #include <linux/mtd/mtd.h>
  #include <linux/mtd/partitions.h>
 +#include <linux/magic.h>
  #include <linux/err.h>
  #include <linux/of.h>
+ #include <linux/of_platform.h>
  
  #include "mtdcore.h"
 +#include "mtdsplit/mtdsplit.h"
  
  /*
   * MTD methods which simply translate the effective address and pass through
-@@ -235,6 +237,146 @@ static int mtd_add_partition_attrs(struc
+@@ -236,6 +238,146 @@ static int mtd_add_partition_attrs(struct mtd_info *new)
        return ret;
  }
  
  int mtd_add_partition(struct mtd_info *parent, const char *name,
                      long long offset, long long length)
  {
-@@ -273,6 +415,7 @@ int mtd_add_partition(struct mtd_info *p
+@@ -274,6 +416,7 @@ int mtd_add_partition(struct mtd_info *parent, const char *name,
        if (ret)
                goto err_remove_part;
  
        mtd_add_partition_attrs(child);
  
        return 0;
-@@ -421,6 +564,7 @@ int add_mtd_partitions(struct mtd_info *
+@@ -422,6 +565,7 @@ int add_mtd_partitions(struct mtd_info *parent,
                        goto err_del_partitions;
                }
  
                mtd_add_partition_attrs(child);
  
                /* Look for subpartitions */
-@@ -437,31 +581,6 @@ err_del_partitions:
+@@ -438,31 +582,6 @@ int add_mtd_partitions(struct mtd_info *parent,
        return ret;
  }
  
  /*
   * Many partition parsers just expected the core to kfree() all their data in
   * one chunk. Do that by default.
---- a/include/linux/mtd/partitions.h
-+++ b/include/linux/mtd/partitions.h
-@@ -75,6 +75,12 @@ struct mtd_part_parser_data {
-  * Functions dealing with the various ways of partitioning the space
-  */
-+enum mtd_parser_type {
-+      MTD_PARSER_TYPE_DEVICE = 0,
-+      MTD_PARSER_TYPE_ROOTFS,
-+      MTD_PARSER_TYPE_FIRMWARE,
-+};
-+
- struct mtd_part_parser {
-       struct list_head list;
-       struct module *owner;
-@@ -83,6 +89,7 @@ struct mtd_part_parser {
-       int (*parse_fn)(struct mtd_info *, const struct mtd_partition **,
-                       struct mtd_part_parser_data *);
-       void (*cleanup)(const struct mtd_partition *pparts, int nr_parts);
-+      enum mtd_parser_type type;
- };
- /* Container for passing around a set of parsed partitions */
---- a/drivers/mtd/Makefile
-+++ b/drivers/mtd/Makefile
-@@ -9,6 +9,8 @@ mtd-y                          := mtdcore.o mtdsuper.o mtdconc
- obj-y                         += parsers/
-+obj-$(CONFIG_MTD_SPLIT)               += mtdsplit/
-+
- # 'Users' - code which presents functionality to userspace.
- obj-$(CONFIG_MTD_BLKDEVS)     += mtd_blkdevs.o
- obj-$(CONFIG_MTD_BLOCK)               += mtdblock.o
+diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
+index 8a2c60235ebb..b092bf6ff97d 100644
 --- a/include/linux/mtd/mtd.h
 +++ b/include/linux/mtd/mtd.h
-@@ -613,6 +613,24 @@ static inline void mtd_align_erase_req(s
+@@ -613,6 +613,24 @@ static inline void mtd_align_erase_req(struct mtd_info *mtd,
                req->len += mtd->erasesize - mod;
  }
  
  static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd)
  {
        if (mtd->writesize_shift)
-@@ -685,6 +703,13 @@ extern void __put_mtd_device(struct mtd_
+@@ -685,6 +703,13 @@ extern void __put_mtd_device(struct mtd_info *mtd);
  extern struct mtd_info *get_mtd_device_nm(const char *name);
  extern void put_mtd_device(struct mtd_info *mtd);
  
  
  struct mtd_notifier {
        void (*add)(struct mtd_info *mtd);
+diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
+index b74a539ec581..65ba0dbf961d 100644
+--- a/include/linux/mtd/partitions.h
++++ b/include/linux/mtd/partitions.h
+@@ -75,6 +75,12 @@ struct mtd_part_parser_data {
+  * Functions dealing with the various ways of partitioning the space
+  */
++enum mtd_parser_type {
++      MTD_PARSER_TYPE_DEVICE = 0,
++      MTD_PARSER_TYPE_ROOTFS,
++      MTD_PARSER_TYPE_FIRMWARE,
++};
++
+ struct mtd_part_parser {
+       struct list_head list;
+       struct module *owner;
+@@ -83,6 +89,7 @@ struct mtd_part_parser {
+       int (*parse_fn)(struct mtd_info *, const struct mtd_partition **,
+                       struct mtd_part_parser_data *);
+       void (*cleanup)(const struct mtd_partition *pparts, int nr_parts);
++      enum mtd_parser_type type;
+ };
+ /* Container for passing around a set of parsed partitions */
+-- 
+