Commit 91e81150 authored by Álvaro Fernández Rojas's avatar Álvaro Fernández Rojas Committed by Miquel Raynal

mtd: parsers: bcm63xx: simplify CFE detection

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: default avatarÁlvaro Fernández Rojas <noltari@gmail.com>
Signed-off-by: default avatarJonas Gorski <jonas.gorski@gmail.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200615091740.2958303-1-noltari@gmail.com
parent 4551e78a
...@@ -22,6 +22,11 @@ ...@@ -22,6 +22,11 @@
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/of.h> #include <linux/of.h>
#ifdef CONFIG_MIPS
#include <asm/bootinfo.h>
#include <asm/fw/cfe/cfe_api.h>
#endif /* CONFIG_MIPS */
#define BCM963XX_CFE_BLOCK_SIZE SZ_64K /* always at least 64KiB */ #define BCM963XX_CFE_BLOCK_SIZE SZ_64K /* always at least 64KiB */
#define BCM963XX_CFE_MAGIC_OFFSET 0x4e0 #define BCM963XX_CFE_MAGIC_OFFSET 0x4e0
...@@ -32,28 +37,15 @@ ...@@ -32,28 +37,15 @@
#define STR_NULL_TERMINATE(x) \ #define STR_NULL_TERMINATE(x) \
do { char *_str = (x); _str[sizeof(x) - 1] = 0; } while (0) 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 = 0;
int ret;
size_t retlen;
ret = mtd_read(master, BCM963XX_CFE_VERSION_OFFSET, 5, &retlen, #ifdef CONFIG_MIPS
(void *)buf); ret = (fw_arg3 == CFE_EPTSEAL);
buf[retlen] = 0; #endif /* CONFIG_MIPS */
if (ret) return 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, static int bcm63xx_read_nvram(struct mtd_info *master,
...@@ -138,7 +130,7 @@ static int bcm63xx_parse_cfe_partitions(struct mtd_info *master, ...@@ -138,7 +130,7 @@ static int bcm63xx_parse_cfe_partitions(struct mtd_info *master,
struct bcm963xx_nvram *nvram = NULL; struct bcm963xx_nvram *nvram = NULL;
int ret; int ret;
if (bcm63xx_detect_cfe(master)) if (!bcm63xx_detect_cfe())
return -EINVAL; return -EINVAL;
nvram = vzalloc(sizeof(*nvram)); nvram = vzalloc(sizeof(*nvram));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment