[PATCH] mtd: parsers: add MTD_OF_PARTS_BCM4908 config option

Rafał Miłecki zajec5 at gmail.com
Mon Feb 15 04:37:40 EST 2021


From: Rafał Miłecki <rafal at milecki.pl>

Right now ofpart parser gets always compiled with the BCM4908 support.
It's not a big issue at this point as BCM4908 partitioning support comes
at close-to-zero cost. It may differ for possible further ofpart quirks
though.

Make BCM4908 support selectable to set a clean pattern for adding further
quirks.

Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
This is NOT urgent and is NOT intended for the 5.12. Please review this
change in a free moment, probably after merge window closes.
---
 drivers/mtd/parsers/Kconfig                              | 9 +++++++++
 drivers/mtd/parsers/Makefile                             | 3 ++-
 .../parsers/{bcm4908-partitions.c => ofpart_bcm4908.c}   | 2 +-
 .../parsers/{bcm4908-partitions.h => ofpart_bcm4908.h}   | 8 ++++++++
 drivers/mtd/parsers/{ofpart.c => ofpart_core.c}          | 2 +-
 5 files changed, 21 insertions(+), 3 deletions(-)
 rename drivers/mtd/parsers/{bcm4908-partitions.c => ofpart_bcm4908.c} (97%)
 rename drivers/mtd/parsers/{bcm4908-partitions.h => ofpart_bcm4908.h} (52%)
 rename drivers/mtd/parsers/{ofpart.c => ofpart_core.c} (99%)

diff --git a/drivers/mtd/parsers/Kconfig b/drivers/mtd/parsers/Kconfig
index d90c30229052..05b6a24cedd8 100644
--- a/drivers/mtd/parsers/Kconfig
+++ b/drivers/mtd/parsers/Kconfig
@@ -67,6 +67,15 @@ config MTD_OF_PARTS
 	  flash memory node, as described in
 	  Documentation/devicetree/bindings/mtd/partition.txt.
 
+config MTD_OF_PARTS_BCM4908
+	bool "BCM4908 partitioning support"
+	depends on MTD_OF_PARTS && (ARCH_BCM4908 || COMPILE_TEST)
+	default ARCH_BCM4908
+	help
+	  This provides partitions parser for BCM4908 family devices
+	  that can have multiple "firmware" partitions. It takes care of
+	  finding currently used one and backup ones.
+
 config MTD_PARSER_IMAGETAG
 	tristate "Parser for BCM963XX Image Tag format partitions"
 	depends on BCM63XX || BMIPS_GENERIC || COMPILE_TEST
diff --git a/drivers/mtd/parsers/Makefile b/drivers/mtd/parsers/Makefile
index bf58a5221730..2dfe9fb602de 100644
--- a/drivers/mtd/parsers/Makefile
+++ b/drivers/mtd/parsers/Makefile
@@ -4,7 +4,8 @@ obj-$(CONFIG_MTD_BCM47XX_PARTS)		+= bcm47xxpart.o
 obj-$(CONFIG_MTD_BCM63XX_PARTS)		+= bcm63xxpart.o
 obj-$(CONFIG_MTD_CMDLINE_PARTS)		+= cmdlinepart.o
 obj-$(CONFIG_MTD_OF_PARTS)		+= ofpart.o
-ofpart-objs				:= bcm4908-partitions.o
+ofpart-y				+= ofpart_core.o
+ofpart-$(CONFIG_MTD_OF_PARTS_BCM4908)	+= ofpart_bcm4908.o
 obj-$(CONFIG_MTD_PARSER_IMAGETAG)	+= parser_imagetag.o
 obj-$(CONFIG_MTD_AFS_PARTS)		+= afs.o
 obj-$(CONFIG_MTD_PARSER_TRX)		+= parser_trx.o
diff --git a/drivers/mtd/parsers/bcm4908-partitions.c b/drivers/mtd/parsers/ofpart_bcm4908.c
similarity index 97%
rename from drivers/mtd/parsers/bcm4908-partitions.c
rename to drivers/mtd/parsers/ofpart_bcm4908.c
index ac69a2169763..3cfa4f4ec562 100644
--- a/drivers/mtd/parsers/bcm4908-partitions.c
+++ b/drivers/mtd/parsers/ofpart_bcm4908.c
@@ -10,7 +10,7 @@
 #include <linux/slab.h>
 #include <linux/mtd/partitions.h>
 
-#include "bcm4908-partitions.h"
+#include "ofpart_bcm4908.h"
 
 #define BLPARAMS_FW_OFFSET		"NAND_RFS_OFS"
 
diff --git a/drivers/mtd/parsers/bcm4908-partitions.h b/drivers/mtd/parsers/ofpart_bcm4908.h
similarity index 52%
rename from drivers/mtd/parsers/bcm4908-partitions.h
rename to drivers/mtd/parsers/ofpart_bcm4908.h
index df25f0487d0a..80f8c086641f 100644
--- a/drivers/mtd/parsers/bcm4908-partitions.h
+++ b/drivers/mtd/parsers/ofpart_bcm4908.h
@@ -2,6 +2,14 @@
 #ifndef __BCM4908_PARTITIONS_H
 #define __BCM4908_PARTITIONS_H
 
+#ifdef CONFIG_MTD_OF_PARTS_BCM4908
 int bcm4908_partitions_post_parse(struct mtd_info *mtd, struct mtd_partition *parts, int nr_parts);
+#else
+static inline int bcm4908_partitions_post_parse(struct mtd_info *mtd, struct mtd_partition *parts,
+						int nr_parts)
+{
+	return -EOPNOTSUPP;
+}
+#endif
 
 #endif
diff --git a/drivers/mtd/parsers/ofpart.c b/drivers/mtd/parsers/ofpart_core.c
similarity index 99%
rename from drivers/mtd/parsers/ofpart.c
rename to drivers/mtd/parsers/ofpart_core.c
index 6b221df8401c..258c06a42283 100644
--- a/drivers/mtd/parsers/ofpart.c
+++ b/drivers/mtd/parsers/ofpart_core.c
@@ -16,7 +16,7 @@
 #include <linux/slab.h>
 #include <linux/mtd/partitions.h>
 
-#include "bcm4908-partitions.h"
+#include "ofpart_bcm4908.h"
 
 struct fixed_partitions_quirks {
 	int (*post_parse)(struct mtd_info *mtd, struct mtd_partition *parts, int nr_parts);
-- 
2.26.2




More information about the linux-mtd mailing list