public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: "Rafał Miłecki" <zajec5@gmail.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Rob Herring <robh+dt@kernel.org>
Cc: "Rafał Miłecki" <rafal@milecki.pl>,
	devicetree@vger.kernel.org, linux-mtd@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	"Boris Brezillon" <bbrezillon@kernel.org>
Subject: [PATCH] mtd: parsers: add MTD_OF_PARTS_BCM4908 config option
Date: Mon, 15 Feb 2021 10:37:40 +0100	[thread overview]
Message-ID: <20210215093740.20080-1-zajec5@gmail.com> (raw)

From: Rafał Miłecki <rafal@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@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


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

             reply	other threads:[~2021-02-15  9:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-15  9:37 Rafał Miłecki [this message]
2021-02-15 13:48 ` [PATCH] mtd: parsers: add MTD_OF_PARTS_BCM4908 config option Rafał Miłecki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210215093740.20080-1-zajec5@gmail.com \
    --to=zajec5@gmail.com \
    --cc=bbrezillon@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=rafal@milecki.pl \
    --cc=richard@nod.at \
    --cc=robh+dt@kernel.org \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox