linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
To: linux-mtd@lists.infradead.org
Cc: David Woodhouse <dwmw2@infradead.org>, dedekind1@gmail.com
Subject: [PATCH 01/18] mtd: abstract last MTD partition parser argument
Date: Sun, 12 Jun 2011 03:11:45 +0400	[thread overview]
Message-ID: <1307833922-21602-2-git-send-email-dbaryshkov@gmail.com> (raw)
In-Reply-To: <1307833922-21602-1-git-send-email-dbaryshkov@gmail.com>

Encapsulate last MTD partition parser argument into a separate
structure. Currently it holds only 'origin' field for RedBoot parser,
but will be extended in future to contain at least device_node for OF
devices.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/cmdlinepart.c      |    2 +-
 drivers/mtd/mtdcore.c          |    6 +++---
 drivers/mtd/mtdpart.c          |    7 ++++---
 drivers/mtd/redboot.c          |    6 +++---
 include/linux/mtd/mtd.h        |    3 ++-
 include/linux/mtd/partitions.h |   14 ++++++++++++--
 6 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
index be0c121..80851c6 100644
--- a/drivers/mtd/cmdlinepart.c
+++ b/drivers/mtd/cmdlinepart.c
@@ -314,7 +314,7 @@ static int mtdpart_setup_real(char *s)
  */
 static int parse_cmdline_partitions(struct mtd_info *master,
                              struct mtd_partition **pparts,
-                             unsigned long origin)
+                             struct mtd_part_parser_data *data)
 {
 	unsigned long offset;
 	int i;
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 1326747..a4067e7 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -457,7 +457,7 @@ EXPORT_SYMBOL_GPL(mtd_device_register);
  * @mtd: the MTD device to register
  * @types: the list of MTD partition probes to try, see
  *         'parse_mtd_partitions()' for more information
- * @origin: start address of MTD device, %0 unless you are sure you need this.
+ * @parser_data: data passed to mtd parsers
  * @parts: fallback partition information to register, if parsing fails;
  *         only valid if %nr_parts > %0
  * @nr_parts: the number of partitions in parts, if zero then the full
@@ -480,14 +480,14 @@ EXPORT_SYMBOL_GPL(mtd_device_register);
  * Returns zero in case of success and a negative error code in case of failure.
  */
 int mtd_device_parse_register(struct mtd_info *mtd, const char **types,
-			      unsigned long origin,
+			      struct mtd_part_parser_data *parser_data,
 			      const struct mtd_partition *parts,
 			      int nr_parts)
 {
 	int err;
 	struct mtd_partition *real_parts;
 
-	err = parse_mtd_partitions(mtd, types, &real_parts, origin);
+	err = parse_mtd_partitions(mtd, types, &real_parts, parser_data);
 	if (err <= 0 && nr_parts) {
 		real_parts = kmemdup(parts, sizeof(*parts) * nr_parts,
 				     GFP_KERNEL);
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 2b71ccb..09ebe69 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -736,7 +736,7 @@ static const char *default_mtd_part_types[] = {"cmdlinepart", NULL};
  * @master: the master partition (describes whole MTD device)
  * @types: names of partition parsers to try or %NULL
  * @pparts: array of partitions found is returned here
- * @origin: MTD device start address (use %0 if unsure)
+ * @data: data passed to MTD partition parsers
  *
  * This function tries to find partition on MTD device @master. It uses MTD
  * partition parsers, specified in @types. However, if @types is %NULL, then
@@ -750,7 +750,8 @@ static const char *default_mtd_part_types[] = {"cmdlinepart", NULL};
  *   point to an array containing this number of &struct mtd_info objects.
  */
 int parse_mtd_partitions(struct mtd_info *master, const char **types,
-			 struct mtd_partition **pparts, unsigned long origin)
+			 struct mtd_partition **pparts,
+			 struct mtd_part_parser_data *data)
 {
 	struct mtd_part_parser *parser;
 	int ret = 0;
@@ -764,7 +765,7 @@ int parse_mtd_partitions(struct mtd_info *master, const char **types,
 				parser = get_partition_parser(*types);
 		if (!parser)
 			continue;
-		ret = (*parser->parse_fn)(master, pparts, origin);
+		ret = (*parser->parse_fn)(master, pparts, data);
 		if (ret > 0) {
 			printk(KERN_NOTICE "%d %s partitions found on MTD device %s\n",
 			       ret, parser->name, master->name);
diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c
index 7a87d07..2b65558 100644
--- a/drivers/mtd/redboot.c
+++ b/drivers/mtd/redboot.c
@@ -57,7 +57,7 @@ static inline int redboot_checksum(struct fis_image_desc *img)
 
 static int parse_redboot_partitions(struct mtd_info *master,
                              struct mtd_partition **pparts,
-                             unsigned long fis_origin)
+                             struct mtd_part_parser_data *data)
 {
 	int nrparts = 0;
 	struct fis_image_desc *buf;
@@ -197,8 +197,8 @@ static int parse_redboot_partitions(struct mtd_info *master,
 			goto out;
 		}
 		new_fl->img = &buf[i];
-                if (fis_origin) {
-                        buf[i].flash_base -= fis_origin;
+                if (data && data->origin) {
+                        buf[i].flash_base -= data->origin;
                 } else {
                         buf[i].flash_base &= master->size-1;
                 }
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index d28a241..b2b454b 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -323,13 +323,14 @@ static inline uint32_t mtd_mod_by_ws(uint64_t sz, struct mtd_info *mtd)
 	/* Kernel-side ioctl definitions */
 
 struct mtd_partition;
+struct mtd_part_parser_data;
 
 extern int mtd_device_register(struct mtd_info *master,
 			       const struct mtd_partition *parts,
 			       int nr_parts);
 extern int mtd_device_parse_register(struct mtd_info *mtd,
 			      const char **part_probe_types,
-			      unsigned long origin,
+			      struct mtd_part_parser_data *parser_data,
 			      const struct mtd_partition *defparts,
 			      int defnr_parts);
 extern int mtd_device_unregister(struct mtd_info *master);
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index 1431cf2..4e91abf 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -52,6 +52,15 @@ struct mtd_partition {
 
 struct mtd_info;
 
+/**
+ * struct mtd_part_parser_data - used to pass data to MTD partition parsers.
+ * @origin: for RedBoot, start address of MTD device, %0 unless you are sure you need this.
+ */
+struct mtd_part_parser_data {
+	unsigned long origin;
+};
+
+
 /*
  * Functions dealing with the various ways of partitioning the space
  */
@@ -60,13 +69,14 @@ struct mtd_part_parser {
 	struct list_head list;
 	struct module *owner;
 	const char *name;
-	int (*parse_fn)(struct mtd_info *, struct mtd_partition **, unsigned long);
+	int (*parse_fn)(struct mtd_info *, struct mtd_partition **, struct mtd_part_parser_data *);
 };
 
 extern int register_mtd_parser(struct mtd_part_parser *parser);
 extern int deregister_mtd_parser(struct mtd_part_parser *parser);
 extern int parse_mtd_partitions(struct mtd_info *master, const char **types,
-				struct mtd_partition **pparts, unsigned long origin);
+				struct mtd_partition **pparts,
+				struct mtd_part_parser_data *data);
 
 #define put_partition_parser(p) do { module_put((p)->owner); } while(0)
 
-- 
1.7.5.3

  reply	other threads:[~2011-06-11 23:12 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-11 23:11 [PATCH V2 00/18] last part of big cleanup of partition handling Dmitry Eremin-Solenikov
2011-06-11 23:11 ` Dmitry Eremin-Solenikov [this message]
2011-06-22  4:21   ` [PATCH 01/18] mtd: abstract last MTD partition parser argument Artem Bityutskiy
2011-06-22  4:59     ` Artem Bityutskiy
2011-06-22  8:21     ` Dmitry Eremin-Solenikov
2011-06-22  8:55       ` Artem Bityutskiy
2011-06-22  9:05         ` Dmitry Eremin-Solenikov
2011-06-22  9:16           ` Artem Bityutskiy
2011-06-11 23:11 ` [PATCH 02/18] mtd: prepare to convert of_mtd_parse_partitions to partition parser Dmitry Eremin-Solenikov
2011-06-22  4:22   ` Artem Bityutskiy
2011-06-11 23:11 ` [PATCH 03/18] mtd: physmap_of: use ofpart through generic parsing Dmitry Eremin-Solenikov
2011-06-11 23:11 ` [PATCH 04/18] mtd: m25p80: " Dmitry Eremin-Solenikov
2011-06-11 23:11 ` [PATCH 05/18] mtd: fsl_elbc_nand: " Dmitry Eremin-Solenikov
2011-06-11 23:11 ` [PATCH 06/18] mtd: fsl_upm: " Dmitry Eremin-Solenikov
2011-06-11 23:11 ` [PATCH 07/18] mtd: mpc5121_nfc: " Dmitry Eremin-Solenikov
2011-06-11 23:11 ` [PATCH 08/18] mtd: ndfc: " Dmitry Eremin-Solenikov
2011-06-11 23:11 ` [PATCH 09/18] mtd: socrates_nand: " Dmitry Eremin-Solenikov
2011-06-11 23:11 ` [PATCH 10/18] mtd: drop of_mtd_parse_partitions() Dmitry Eremin-Solenikov
2011-06-11 23:11 ` [PATCH 11/18] mtd: physmap_of: move parse_obsolete_partitions to become separate parser Dmitry Eremin-Solenikov
2011-06-11 23:11 ` [PATCH 12/18] mtd: physmap_of.c: use mtd_device_parse_register Dmitry Eremin-Solenikov
2011-06-11 23:11 ` [PATCH 13/18] mtd: m25p80.c: " Dmitry Eremin-Solenikov
2011-06-11 23:11 ` [PATCH 14/18] mtd: fsl_elbc_nand.c: " Dmitry Eremin-Solenikov
2011-06-11 23:11 ` [PATCH 15/18] mtd: fsl_upm.c: " Dmitry Eremin-Solenikov
2011-06-11 23:12 ` [PATCH 16/18] mtd: mpc5121_nfc.c: " Dmitry Eremin-Solenikov
2011-06-11 23:12 ` [PATCH 17/18] mtd: ndfc.c: " Dmitry Eremin-Solenikov
2011-06-11 23:12 ` [PATCH 18/18] mtd: socrates_nand.c: " Dmitry Eremin-Solenikov
2011-06-16  8:56 ` [PATCH V2 00/18] last part of big cleanup of partition handling Dmitry Eremin-Solenikov
  -- strict thread matches above, loose matches on Subject: below --
2011-06-22  9:37 [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers Dmitry Eremin-Solenikov
2011-06-22  9:37 ` [PATCH 01/18] mtd: abstract last MTD partition parser argument Dmitry Eremin-Solenikov

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=1307833922-21602-2-git-send-email-dbaryshkov@gmail.com \
    --to=dbaryshkov@gmail.com \
    --cc=dedekind1@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).