From: Álvaro Fernández Rojas Date: Mon, 10 Aug 2020 15:17:52 +0000 (+0200) Subject: bcm63xx: switch to upstream CFE detection patch X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=a5a0b3f1d0bf14008e6fbad7024df3f5901303f1;p=openwrt%2Fstaging%2Fblocktrron.git bcm63xx: switch to upstream CFE detection patch This patch has been merged in linux 5.9. Signed-off-by: Álvaro Fernández Rojas --- diff --git a/target/linux/bcm63xx/patches-5.4/033-v5.9-mtd-parsers-bcm63xx-simplify-CFE-detection.patch b/target/linux/bcm63xx/patches-5.4/033-v5.9-mtd-parsers-bcm63xx-simplify-CFE-detection.patch new file mode 100644 index 0000000000..ff1f30cb9b --- /dev/null +++ b/target/linux/bcm63xx/patches-5.4/033-v5.9-mtd-parsers-bcm63xx-simplify-CFE-detection.patch @@ -0,0 +1,78 @@ +From 91e81150d38842b58133ce1a5d70c88e8f1cf7c1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Mon, 15 Jun 2020 11:17:40 +0200 +Subject: [PATCH] mtd: parsers: bcm63xx: simplify CFE detection +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Instead of trying to parse CFE version string, which is customized by some +vendors, let's just check that "CFE1" was passed on argument 3. + +Signed-off-by: Álvaro Fernández Rojas +Signed-off-by: Jonas Gorski +Reviewed-by: Florian Fainelli +Signed-off-by: Miquel Raynal +Link: https://lore.kernel.org/linux-mtd/20200615091740.2958303-1-noltari@gmail.com +--- + drivers/mtd/parsers/bcm63xxpart.c | 32 ++++++++++++------------------- + 1 file changed, 12 insertions(+), 20 deletions(-) + +--- a/drivers/mtd/parsers/bcm63xxpart.c ++++ b/drivers/mtd/parsers/bcm63xxpart.c +@@ -22,6 +22,11 @@ + #include + #include + ++#ifdef CONFIG_MIPS ++#include ++#include ++#endif /* CONFIG_MIPS */ ++ + #define BCM963XX_CFE_BLOCK_SIZE SZ_64K /* always at least 64KiB */ + + #define BCM963XX_CFE_MAGIC_OFFSET 0x4e0 +@@ -32,28 +37,15 @@ + #define STR_NULL_TERMINATE(x) \ + do { char *_str = (x); _str[sizeof(x) - 1] = 0; } while (0) + +-static int bcm63xx_detect_cfe(struct mtd_info *master) ++static inline int bcm63xx_detect_cfe(void) + { +- char buf[9]; +- int ret; +- size_t retlen; +- +- ret = mtd_read(master, BCM963XX_CFE_VERSION_OFFSET, 5, &retlen, +- (void *)buf); +- buf[retlen] = 0; +- +- if (ret) +- return ret; +- +- if (strncmp("cfe-v", buf, 5) == 0) +- return 0; ++ int ret = 0; + +- /* very old CFE's do not have the cfe-v string, so check for magic */ +- ret = mtd_read(master, BCM963XX_CFE_MAGIC_OFFSET, 8, &retlen, +- (void *)buf); +- buf[retlen] = 0; ++#ifdef CONFIG_MIPS ++ ret = (fw_arg3 == CFE_EPTSEAL); ++#endif /* CONFIG_MIPS */ + +- return strncmp("CFE1CFE1", buf, 8); ++ return ret; + } + + static int bcm63xx_read_nvram(struct mtd_info *master, +@@ -138,7 +130,7 @@ static int bcm63xx_parse_cfe_partitions( + struct bcm963xx_nvram *nvram = NULL; + int ret; + +- if (bcm63xx_detect_cfe(master)) ++ if (!bcm63xx_detect_cfe()) + return -EINVAL; + + nvram = vzalloc(sizeof(*nvram)); diff --git a/target/linux/bcm63xx/patches-5.4/310-cfe_simplify_detection.patch b/target/linux/bcm63xx/patches-5.4/310-cfe_simplify_detection.patch deleted file mode 100644 index 0e4e759ab9..0000000000 --- a/target/linux/bcm63xx/patches-5.4/310-cfe_simplify_detection.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_board.h -+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_board.h -@@ -2,6 +2,8 @@ - #ifndef BCM63XX_BOARD_H_ - #define BCM63XX_BOARD_H_ - -+#include -+ - const char *board_get_name(void); - - void board_prom_init(void); -@@ -10,4 +12,8 @@ void board_setup(void); - - int board_register_devices(void); - -+static inline bool bcm63xx_is_cfe_present(void) { -+ return fw_arg3 == 0x43464531; -+} -+ - #endif /* ! BCM63XX_BOARD_H_ */ diff --git a/target/linux/bcm63xx/patches-5.4/311-bcm63xxpart_use_cfedetection.patch b/target/linux/bcm63xx/patches-5.4/311-bcm63xxpart_use_cfedetection.patch deleted file mode 100644 index 19ed994b85..0000000000 --- a/target/linux/bcm63xx/patches-5.4/311-bcm63xxpart_use_cfedetection.patch +++ /dev/null @@ -1,51 +0,0 @@ ---- a/drivers/mtd/parsers/bcm63xxpart.c -+++ b/drivers/mtd/parsers/bcm63xxpart.c -@@ -21,6 +21,8 @@ - #include - #include - #include -+ -+#include - - #define BCM963XX_CFE_BLOCK_SIZE SZ_64K /* always at least 64KiB */ - -@@ -32,30 +34,6 @@ - #define STR_NULL_TERMINATE(x) \ - do { char *_str = (x); _str[sizeof(x) - 1] = 0; } while (0) - --static int bcm63xx_detect_cfe(struct mtd_info *master) --{ -- char buf[9]; -- int ret; -- size_t retlen; -- -- ret = mtd_read(master, BCM963XX_CFE_VERSION_OFFSET, 5, &retlen, -- (void *)buf); -- buf[retlen] = 0; -- -- if (ret) -- return ret; -- -- if (strncmp("cfe-v", buf, 5) == 0) -- return 0; -- -- /* very old CFE's do not have the cfe-v string, so check for magic */ -- ret = mtd_read(master, BCM963XX_CFE_MAGIC_OFFSET, 8, &retlen, -- (void *)buf); -- buf[retlen] = 0; -- -- return strncmp("CFE1CFE1", buf, 8); --} -- - static int bcm63xx_read_nvram(struct mtd_info *master, - struct bcm963xx_nvram *nvram) - { -@@ -138,7 +116,7 @@ static int bcm63xx_parse_cfe_partitions( - struct bcm963xx_nvram *nvram = NULL; - int ret; - -- if (bcm63xx_detect_cfe(master)) -+ if (!bcm63xx_is_cfe_present()) - return -EINVAL; - - nvram = vzalloc(sizeof(*nvram));