Skip to content

Commit 91e8115

Browse files
Noltarimiquelraynal
authored andcommitted
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: Álvaro Fernández Rojas <[email protected]> Signed-off-by: Jonas Gorski <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent 4551e78 commit 91e8115

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

drivers/mtd/parsers/bcm63xxpart.c

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
#include <linux/mtd/partitions.h>
2323
#include <linux/of.h>
2424

25+
#ifdef CONFIG_MIPS
26+
#include <asm/bootinfo.h>
27+
#include <asm/fw/cfe/cfe_api.h>
28+
#endif /* CONFIG_MIPS */
29+
2530
#define BCM963XX_CFE_BLOCK_SIZE SZ_64K /* always at least 64KiB */
2631

2732
#define BCM963XX_CFE_MAGIC_OFFSET 0x4e0
@@ -32,28 +37,15 @@
3237
#define STR_NULL_TERMINATE(x) \
3338
do { char *_str = (x); _str[sizeof(x) - 1] = 0; } while (0)
3439

35-
static int bcm63xx_detect_cfe(struct mtd_info *master)
40+
static inline int bcm63xx_detect_cfe(void)
3641
{
37-
char buf[9];
38-
int ret;
39-
size_t retlen;
42+
int ret = 0;
4043

41-
ret = mtd_read(master, BCM963XX_CFE_VERSION_OFFSET, 5, &retlen,
42-
(void *)buf);
43-
buf[retlen] = 0;
44+
#ifdef CONFIG_MIPS
45+
ret = (fw_arg3 == CFE_EPTSEAL);
46+
#endif /* CONFIG_MIPS */
4447

45-
if (ret)
46-
return ret;
47-
48-
if (strncmp("cfe-v", buf, 5) == 0)
49-
return 0;
50-
51-
/* very old CFE's do not have the cfe-v string, so check for magic */
52-
ret = mtd_read(master, BCM963XX_CFE_MAGIC_OFFSET, 8, &retlen,
53-
(void *)buf);
54-
buf[retlen] = 0;
55-
56-
return strncmp("CFE1CFE1", buf, 8);
48+
return ret;
5749
}
5850

5951
static int bcm63xx_read_nvram(struct mtd_info *master,
@@ -138,7 +130,7 @@ static int bcm63xx_parse_cfe_partitions(struct mtd_info *master,
138130
struct bcm963xx_nvram *nvram = NULL;
139131
int ret;
140132

141-
if (bcm63xx_detect_cfe(master))
133+
if (!bcm63xx_detect_cfe())
142134
return -EINVAL;
143135

144136
nvram = vzalloc(sizeof(*nvram));

0 commit comments

Comments
 (0)