linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 02/18] mtd: prepare to convert of_mtd_parse_partitions to partition parser
  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
  2011-06-22  4:22   ` Artem Bityutskiy
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-11 23:11 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Woodhouse, dedekind1

Prepare to convert of_mtd_parse_partitions() to usual partitions parser:
1) Register ofpart parser
2) Internally don't use passed device for error printing
3) Add device_node to mtd_part_parser_data struct
4) Move of_mtd_parse_partitions from __devinit to common text section
5) add ofpart to the default list of partition parsers

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/mtdpart.c          |    8 ++++++--
 drivers/mtd/ofpart.c           |   27 +++++++++++++++++++++++++--
 include/linux/mtd/partitions.h |    4 +++-
 3 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 09ebe69..54160c0 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -729,7 +729,11 @@ EXPORT_SYMBOL_GPL(deregister_mtd_parser);
  * Do not forget to update 'parse_mtd_partitions()' kerneldoc comment if you
  * are changing this array!
  */
-static const char *default_mtd_part_types[] = {"cmdlinepart", NULL};
+static const char *default_mtd_part_types[] = {
+	"cmdlinepart",
+	"ofpart",
+	NULL
+};
 
 /**
  * parse_mtd_partitions - parse MTD partitions
@@ -741,7 +745,7 @@ static const char *default_mtd_part_types[] = {"cmdlinepart", NULL};
  * This function tries to find partition on MTD device @master. It uses MTD
  * partition parsers, specified in @types. However, if @types is %NULL, then
  * the default list of parsers is used. The default list contains only the
- * "cmdlinepart" parser ATM.
+ * "cmdlinepart" and "ofpart" parsers ATM.
  *
  * This function may return:
  * o a negative error code in case of failure
diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c
index a996718..7c2c926 100644
--- a/drivers/mtd/ofpart.c
+++ b/drivers/mtd/ofpart.c
@@ -20,7 +20,17 @@
 #include <linux/slab.h>
 #include <linux/mtd/partitions.h>
 
-int __devinit of_mtd_parse_partitions(struct device *dev,
+static int parse_ofpart_partitions(struct mtd_info *master,
+				   struct mtd_partition **pparts,
+				   struct mtd_part_parser_data *data)
+{
+	if (!data || !data->of_node)
+		return 0;
+
+	return of_mtd_parse_partitions(NULL, data->of_node, pparts);
+}
+
+int of_mtd_parse_partitions(struct device *dev,
                                       struct device_node *node,
                                       struct mtd_partition **pparts)
 {
@@ -69,7 +79,7 @@ int __devinit of_mtd_parse_partitions(struct device *dev,
 
 	if (!i) {
 		of_node_put(pp);
-		dev_err(dev, "No valid partition found on %s\n", node->full_name);
+		pr_err("No valid partition found on %s\n", node->full_name);
 		kfree(*pparts);
 		*pparts = NULL;
 		return -EINVAL;
@@ -79,4 +89,17 @@ int __devinit of_mtd_parse_partitions(struct device *dev,
 }
 EXPORT_SYMBOL(of_mtd_parse_partitions);
 
+static struct mtd_part_parser ofpart_parser = {
+	.owner = THIS_MODULE,
+	.parse_fn = parse_ofpart_partitions,
+	.name = "ofpart",
+};
+
+static int __init ofpart_parser_init(void)
+{
+	return register_mtd_parser(&ofpart_parser);
+}
+
+module_init(ofpart_parser_init);
+
 MODULE_LICENSE("GPL");
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index 4e91abf..dad4edf 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -51,6 +51,7 @@ struct mtd_partition {
 
 
 struct mtd_info;
+struct device_node;
 
 /**
  * struct mtd_part_parser_data - used to pass data to MTD partition parsers.
@@ -58,6 +59,7 @@ struct mtd_info;
  */
 struct mtd_part_parser_data {
 	unsigned long origin;
+	struct device_node *of_node;
 };
 
 
@@ -84,7 +86,7 @@ struct device;
 struct device_node;
 
 #ifdef CONFIG_MTD_OF_PARTS
-int __devinit of_mtd_parse_partitions(struct device *dev,
+int of_mtd_parse_partitions(struct device *dev,
                                       struct device_node *node,
                                       struct mtd_partition **pparts);
 #else
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH 02/18] mtd: prepare to convert of_mtd_parse_partitions to partition parser
  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
  0 siblings, 0 replies; 22+ messages in thread
From: Artem Bityutskiy @ 2011-06-22  4:22 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: David Woodhouse, linux-mtd

On Sun, 2011-06-12 at 03:11 +0400, Dmitry Eremin-Solenikov wrote:
>  struct mtd_part_parser_data {
>  	unsigned long origin;
> +	struct device_node *of_node;
>  };

You forgot to add a comment for the of_node field.
I could fixup this myself, but I really have no time now, sorry.

-- 
Best Regards,
Artem Bityutskiy

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers
@ 2011-06-22  9:37 Dmitry Eremin-Solenikov
  2011-06-22  9:37 ` [PATCH 01/18] mtd: abstract last MTD partition parser argument Dmitry Eremin-Solenikov
                   ` (18 more replies)
  0 siblings, 19 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-22  9:37 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Woodhouse, Artem Bityutskiy

Changes since V1:
 * Tab-vs-space cleanup
 * 80-column cleanup
 * documented of_node parser data field
 * changed documentation for parser_data arguments

The following changes since commit 6a146696fdcf383d90753145dfb367e499790940:

  mtd: nand_base: always initialise oob_poi before writing OOB data (2011-06-22 08:50:28 +0300)

are available in the git repository at:
  git://git.infradead.org/users/dbaryshkov/mtd-cleanup.git mtd-big-cleanup

Dmitry Eremin-Solenikov (18):
      mtd: abstract last MTD partition parser argument
      mtd: prepare to convert of_mtd_parse_partitions to partition parser
      mtd: physmap_of: use ofpart through generic parsing
      mtd: m25p80: use ofpart through generic parsing
      mtd: fsl_elbc_nand: use ofpart through generic parsing
      mtd: fsl_upm: use ofpart through generic parsing
      mtd: mpc5121_nfc: use ofpart through generic parsing
      mtd: ndfc: use ofpart through generic parsing
      mtd: socrates_nand: use ofpart through generic parsing
      mtd: drop of_mtd_parse_partitions()
      mtd: physmap_of: move parse_obsolete_partitions to become separate parser
      mtd: physmap_of.c: use mtd_device_parse_register
      mtd: m25p80.c: use mtd_device_parse_register
      mtd: fsl_elbc_nand.c: use mtd_device_parse_register
      mtd: fsl_upm.c: use mtd_device_parse_register
      mtd: mpc5121_nfc.c: use mtd_device_parse_register
      mtd: ndfc.c: use mtd_device_parse_register
      mtd: socrates_nand.c: use mtd_device_parse_register

 drivers/mtd/afs.c                |    4 +-
 drivers/mtd/ar7part.c            |    2 +-
 drivers/mtd/cmdlinepart.c        |    4 +-
 drivers/mtd/devices/m25p80.c     |   37 ++------------
 drivers/mtd/maps/physmap_of.c    |   80 +++--------------------------
 drivers/mtd/mtdcore.c            |    6 +-
 drivers/mtd/mtdpart.c            |   15 ++++--
 drivers/mtd/nand/fsl_elbc_nand.c |   18 ++-----
 drivers/mtd/nand/fsl_upm.c       |   13 +----
 drivers/mtd/nand/mpc5121_nfc.c   |   17 +-----
 drivers/mtd/nand/ndfc.c          |   16 +-----
 drivers/mtd/nand/socrates_nand.c |   23 +-------
 drivers/mtd/ofpart.c             |  104 ++++++++++++++++++++++++++++++++++++--
 drivers/mtd/redboot.c            |   13 ++---
 include/linux/mtd/mtd.h          |    3 +-
 include/linux/mtd/partitions.h   |   36 +++++++-------
 16 files changed, 172 insertions(+), 219 deletions(-)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 01/18] mtd: abstract last MTD partition parser argument
  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 ` Dmitry Eremin-Solenikov
  2011-06-22  9:37 ` [PATCH 02/18] mtd: prepare to convert of_mtd_parse_partitions to partition parser Dmitry Eremin-Solenikov
                   ` (17 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-22  9:37 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Woodhouse, Artem Bityutskiy

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/afs.c              |    4 ++--
 drivers/mtd/ar7part.c          |    2 +-
 drivers/mtd/cmdlinepart.c      |    4 ++--
 drivers/mtd/mtdcore.c          |    6 +++---
 drivers/mtd/mtdpart.c          |    7 ++++---
 drivers/mtd/redboot.c          |   13 ++++++-------
 include/linux/mtd/mtd.h        |    3 ++-
 include/linux/mtd/partitions.h |   16 ++++++++++++++--
 8 files changed, 34 insertions(+), 21 deletions(-)

diff --git a/drivers/mtd/afs.c b/drivers/mtd/afs.c
index 302372c..89a02f6 100644
--- a/drivers/mtd/afs.c
+++ b/drivers/mtd/afs.c
@@ -162,8 +162,8 @@ afs_read_iis(struct mtd_info *mtd, struct image_info_struct *iis, u_int ptr)
 }
 
 static int parse_afs_partitions(struct mtd_info *mtd,
-                         struct mtd_partition **pparts,
-                         unsigned long origin)
+				struct mtd_partition **pparts,
+				struct mtd_part_parser_data *data)
 {
 	struct mtd_partition *parts;
 	u_int mask, off, idx, sz;
diff --git a/drivers/mtd/ar7part.c b/drivers/mtd/ar7part.c
index 6697a1e..71bfa2e 100644
--- a/drivers/mtd/ar7part.c
+++ b/drivers/mtd/ar7part.c
@@ -46,7 +46,7 @@ struct ar7_bin_rec {
 
 static int create_mtd_partitions(struct mtd_info *master,
 				 struct mtd_partition **pparts,
-				 unsigned long origin)
+				 struct mtd_part_parser_data *data)
 {
 	struct ar7_bin_rec header;
 	unsigned int offset;
diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
index be0c121..1b11f94 100644
--- a/drivers/mtd/cmdlinepart.c
+++ b/drivers/mtd/cmdlinepart.c
@@ -313,8 +313,8 @@ static int mtdpart_setup_real(char *s)
  * the first one in the chain if a NULL mtd_id is passed in.
  */
 static int parse_cmdline_partitions(struct mtd_info *master,
-                             struct mtd_partition **pparts,
-                             unsigned long origin)
+				    struct mtd_partition **pparts,
+				    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..e186399 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: MTD partition parser-specific data
  * @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..34d582c 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: MTD partition parser-specific data
  *
  * 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..56e48ea 100644
--- a/drivers/mtd/redboot.c
+++ b/drivers/mtd/redboot.c
@@ -56,8 +56,8 @@ 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_partition **pparts,
+				    struct mtd_part_parser_data *data)
 {
 	int nrparts = 0;
 	struct fis_image_desc *buf;
@@ -197,11 +197,10 @@ 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;
-                } else {
-                        buf[i].flash_base &= master->size-1;
-                }
+		if (data && data->origin)
+			buf[i].flash_base -= data->origin;
+		else
+			buf[i].flash_base &= master->size-1;
 
 		/* I'm sure the JFFS2 code has done me permanent damage.
 		 * I now think the following is _normal_
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..df125fa 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -52,6 +52,16 @@ 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 +70,15 @@ 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

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 02/18] mtd: prepare to convert of_mtd_parse_partitions to partition parser
  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
@ 2011-06-22  9:37 ` Dmitry Eremin-Solenikov
  2011-06-22  9:37 ` [PATCH 03/18] mtd: physmap_of: use ofpart through generic parsing Dmitry Eremin-Solenikov
                   ` (16 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-22  9:37 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Woodhouse, Artem Bityutskiy

Prepare to convert of_mtd_parse_partitions() to usual partitions parser:
1) Register ofpart parser
2) Internally don't use passed device for error printing
3) Add device_node to mtd_part_parser_data struct
4) Move of_mtd_parse_partitions from __devinit to common text section
5) add ofpart to the default list of partition parsers

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/mtdpart.c          |    8 ++++++--
 drivers/mtd/ofpart.c           |   27 +++++++++++++++++++++++++--
 include/linux/mtd/partitions.h |    6 +++++-
 3 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 34d582c..9e8ee05 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -729,7 +729,11 @@ EXPORT_SYMBOL_GPL(deregister_mtd_parser);
  * Do not forget to update 'parse_mtd_partitions()' kerneldoc comment if you
  * are changing this array!
  */
-static const char *default_mtd_part_types[] = {"cmdlinepart", NULL};
+static const char *default_mtd_part_types[] = {
+	"cmdlinepart",
+	"ofpart",
+	NULL
+};
 
 /**
  * parse_mtd_partitions - parse MTD partitions
@@ -741,7 +745,7 @@ static const char *default_mtd_part_types[] = {"cmdlinepart", NULL};
  * This function tries to find partition on MTD device @master. It uses MTD
  * partition parsers, specified in @types. However, if @types is %NULL, then
  * the default list of parsers is used. The default list contains only the
- * "cmdlinepart" parser ATM.
+ * "cmdlinepart" and "ofpart" parsers ATM.
  *
  * This function may return:
  * o a negative error code in case of failure
diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c
index a996718..7c2c926 100644
--- a/drivers/mtd/ofpart.c
+++ b/drivers/mtd/ofpart.c
@@ -20,7 +20,17 @@
 #include <linux/slab.h>
 #include <linux/mtd/partitions.h>
 
-int __devinit of_mtd_parse_partitions(struct device *dev,
+static int parse_ofpart_partitions(struct mtd_info *master,
+				   struct mtd_partition **pparts,
+				   struct mtd_part_parser_data *data)
+{
+	if (!data || !data->of_node)
+		return 0;
+
+	return of_mtd_parse_partitions(NULL, data->of_node, pparts);
+}
+
+int of_mtd_parse_partitions(struct device *dev,
                                       struct device_node *node,
                                       struct mtd_partition **pparts)
 {
@@ -69,7 +79,7 @@ int __devinit of_mtd_parse_partitions(struct device *dev,
 
 	if (!i) {
 		of_node_put(pp);
-		dev_err(dev, "No valid partition found on %s\n", node->full_name);
+		pr_err("No valid partition found on %s\n", node->full_name);
 		kfree(*pparts);
 		*pparts = NULL;
 		return -EINVAL;
@@ -79,4 +89,17 @@ int __devinit of_mtd_parse_partitions(struct device *dev,
 }
 EXPORT_SYMBOL(of_mtd_parse_partitions);
 
+static struct mtd_part_parser ofpart_parser = {
+	.owner = THIS_MODULE,
+	.parse_fn = parse_ofpart_partitions,
+	.name = "ofpart",
+};
+
+static int __init ofpart_parser_init(void)
+{
+	return register_mtd_parser(&ofpart_parser);
+}
+
+module_init(ofpart_parser_init);
+
 MODULE_LICENSE("GPL");
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index df125fa..6e724af 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -51,14 +51,18 @@ struct mtd_partition {
 
 
 struct mtd_info;
+struct device_node;
 
 /**
  * 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.
+ * @of_node: for OpenFirmware based parsers, pass device node containing
+ *					partitioning information
  */
 struct mtd_part_parser_data {
 	unsigned long origin;
+	struct device_node *of_node;
 };
 
 
@@ -86,7 +90,7 @@ struct device;
 struct device_node;
 
 #ifdef CONFIG_MTD_OF_PARTS
-int __devinit of_mtd_parse_partitions(struct device *dev,
+int of_mtd_parse_partitions(struct device *dev,
                                       struct device_node *node,
                                       struct mtd_partition **pparts);
 #else
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 03/18] mtd: physmap_of: use ofpart through generic parsing
  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
  2011-06-22  9:37 ` [PATCH 02/18] mtd: prepare to convert of_mtd_parse_partitions to partition parser Dmitry Eremin-Solenikov
@ 2011-06-22  9:37 ` Dmitry Eremin-Solenikov
  2011-06-22  9:37 ` [PATCH 04/18] mtd: m25p80: " Dmitry Eremin-Solenikov
                   ` (15 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-22  9:37 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Woodhouse, Artem Bityutskiy

Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/maps/physmap_of.c |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
index d251d1d..6a75743 100644
--- a/drivers/mtd/maps/physmap_of.c
+++ b/drivers/mtd/maps/physmap_of.c
@@ -165,7 +165,8 @@ static struct mtd_info * __devinit obsolete_probe(struct platform_device *dev,
    specifies the list of partition probers to use. If none is given then the
    default is use. These take precedence over other device tree
    information. */
-static const char *part_probe_types_def[] = { "cmdlinepart", "RedBoot", NULL };
+static const char *part_probe_types_def[] = { "cmdlinepart", "RedBoot",
+					"ofpart", NULL };
 static const char ** __devinit of_get_probes(struct device_node *dp)
 {
 	const char *cp;
@@ -218,6 +219,7 @@ static int __devinit of_flash_probe(struct platform_device *dev)
 	int reg_tuple_size;
 	struct mtd_info **mtd_list = NULL;
 	resource_size_t res_size;
+	struct mtd_part_parser_data ppdata;
 
 	match = of_match_device(of_flash_match, &dev->dev);
 	if (!match)
@@ -331,9 +333,10 @@ static int __devinit of_flash_probe(struct platform_device *dev)
 	if (err)
 		goto err_out;
 
+	ppdata.of_node = dp;
 	part_probe_types = of_get_probes(dp);
 	err = parse_mtd_partitions(info->cmtd, part_probe_types,
-				   &info->parts, 0);
+				   &info->parts, &ppdata);
 	if (err < 0) {
 		of_free_probes(part_probe_types);
 		goto err_out;
@@ -341,12 +344,6 @@ static int __devinit of_flash_probe(struct platform_device *dev)
 	of_free_probes(part_probe_types);
 
 	if (err == 0) {
-		err = of_mtd_parse_partitions(&dev->dev, dp, &info->parts);
-		if (err < 0)
-			goto err_out;
-	}
-
-	if (err == 0) {
 		err = parse_obsolete_partitions(dev, info, dp);
 		if (err < 0)
 			goto err_out;
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 04/18] mtd: m25p80: use ofpart through generic parsing
  2011-06-22  9:37 [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers Dmitry Eremin-Solenikov
                   ` (2 preceding siblings ...)
  2011-06-22  9:37 ` [PATCH 03/18] mtd: physmap_of: use ofpart through generic parsing Dmitry Eremin-Solenikov
@ 2011-06-22  9:37 ` Dmitry Eremin-Solenikov
  2011-06-22  9:37 ` [PATCH 05/18] mtd: fsl_elbc_nand: " Dmitry Eremin-Solenikov
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-22  9:37 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Woodhouse, Artem Bityutskiy

Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/devices/m25p80.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 70d5fca..399c234 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -827,6 +827,7 @@ static int __devinit m25p_probe(struct spi_device *spi)
 	unsigned			i;
 	struct mtd_partition		*parts = NULL;
 	int				nr_parts = 0;
+	struct mtd_part_parser_data	ppdata;
 
 	/* Platform data helps sort out which chip type we have, as
 	 * well as how this board partitions it.  If we don't have
@@ -928,6 +929,7 @@ static int __devinit m25p_probe(struct spi_device *spi)
 	if (info->flags & M25P_NO_ERASE)
 		flash->mtd.flags |= MTD_NO_ERASE;
 
+	ppdata.of_node = spi->dev.of_node;
 	flash->mtd.dev.parent = &spi->dev;
 	flash->page_size = info->page_size;
 
@@ -968,20 +970,13 @@ static int __devinit m25p_probe(struct spi_device *spi)
 	/* partitions should match sector boundaries; and it may be good to
 	 * use readonly partitions for writeprotected sectors (BP2..BP0).
 	 */
-	nr_parts = parse_mtd_partitions(&flash->mtd, NULL, &parts, 0);
+	nr_parts = parse_mtd_partitions(&flash->mtd, NULL, &parts, &ppdata);
 
 	if (nr_parts <= 0 && data && data->parts) {
 		parts = data->parts;
 		nr_parts = data->nr_parts;
 	}
 
-#ifdef CONFIG_MTD_OF_PARTS
-	if (nr_parts <= 0 && spi->dev.of_node) {
-		nr_parts = of_mtd_parse_partitions(&spi->dev,
-						   spi->dev.of_node, &parts);
-	}
-#endif
-
 	if (nr_parts > 0) {
 		for (i = 0; i < nr_parts; i++) {
 			DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = "
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 05/18] mtd: fsl_elbc_nand: use ofpart through generic parsing
  2011-06-22  9:37 [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers Dmitry Eremin-Solenikov
                   ` (3 preceding siblings ...)
  2011-06-22  9:37 ` [PATCH 04/18] mtd: m25p80: " Dmitry Eremin-Solenikov
@ 2011-06-22  9:37 ` Dmitry Eremin-Solenikov
  2011-06-22  9:37 ` [PATCH 06/18] mtd: fsl_upm: " Dmitry Eremin-Solenikov
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-22  9:37 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Woodhouse, Artem Bityutskiy

Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/nand/fsl_elbc_nand.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index d4ea5fe..4d225ba 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -842,13 +842,15 @@ static int __devinit fsl_elbc_nand_probe(struct platform_device *pdev)
 	struct resource res;
 	struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl;
 	static const char *part_probe_types[]
-		= { "cmdlinepart", "RedBoot", NULL };
+		= { "cmdlinepart", "RedBoot", "ofpart", NULL };
 	struct mtd_partition *parts;
 	int ret;
 	int bank;
 	struct device *dev;
 	struct device_node *node = pdev->dev.of_node;
+	struct mtd_part_parser_data ppdata;
 
+	ppdata.of_node = pdev->dev.of_node;
 	if (!fsl_lbc_ctrl_dev || !fsl_lbc_ctrl_dev->regs)
 		return -ENODEV;
 	lbc = fsl_lbc_ctrl_dev->regs;
@@ -934,16 +936,10 @@ static int __devinit fsl_elbc_nand_probe(struct platform_device *pdev)
 
 	/* First look for RedBoot table or partitions on the command
 	 * line, these take precedence over device tree information */
-	ret = parse_mtd_partitions(&priv->mtd, part_probe_types, &parts, 0);
+	ret = parse_mtd_partitions(&priv->mtd, part_probe_types, &parts, &ppdata);
 	if (ret < 0)
 		goto err;
 
-	if (ret == 0) {
-		ret = of_mtd_parse_partitions(priv->dev, node, &parts);
-		if (ret < 0)
-			goto err;
-	}
-
 	mtd_device_register(&priv->mtd, parts, ret);
 
 	printk(KERN_INFO "eLBC NAND device at 0x%llx, bank %d\n",
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 06/18] mtd: fsl_upm: use ofpart through generic parsing
  2011-06-22  9:37 [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers Dmitry Eremin-Solenikov
                   ` (4 preceding siblings ...)
  2011-06-22  9:37 ` [PATCH 05/18] mtd: fsl_elbc_nand: " Dmitry Eremin-Solenikov
@ 2011-06-22  9:37 ` Dmitry Eremin-Solenikov
  2011-06-22  9:37 ` [PATCH 07/18] mtd: mpc5121_nfc: " Dmitry Eremin-Solenikov
                   ` (12 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-22  9:37 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Woodhouse, Artem Bityutskiy

Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/nand/fsl_upm.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/fsl_upm.c b/drivers/mtd/nand/fsl_upm.c
index 7c782eb..714d831 100644
--- a/drivers/mtd/nand/fsl_upm.c
+++ b/drivers/mtd/nand/fsl_upm.c
@@ -158,6 +158,7 @@ static int __devinit fun_chip_init(struct fsl_upm_nand *fun,
 {
 	int ret;
 	struct device_node *flash_np;
+	struct mtd_part_parser_data ppdata;
 
 	fun->chip.IO_ADDR_R = fun->io_base;
 	fun->chip.IO_ADDR_W = fun->io_base;
@@ -191,15 +192,9 @@ static int __devinit fun_chip_init(struct fsl_upm_nand *fun,
 	if (ret)
 		goto err;
 
-	ret = parse_mtd_partitions(&fun->mtd, NULL, &fun->parts, 0);
+	ppdata.of_node = flash_np;
+	ret = parse_mtd_partitions(&fun->mtd, NULL, &fun->parts, &ppdata);
 
-#ifdef CONFIG_MTD_OF_PARTS
-	if (ret == 0) {
-		ret = of_mtd_parse_partitions(fun->dev, flash_np, &fun->parts);
-		if (ret < 0)
-			goto err;
-	}
-#endif
 	ret = mtd_device_register(&fun->mtd, fun->parts, ret);
 err:
 	of_node_put(flash_np);
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 07/18] mtd: mpc5121_nfc: use ofpart through generic parsing
  2011-06-22  9:37 [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers Dmitry Eremin-Solenikov
                   ` (5 preceding siblings ...)
  2011-06-22  9:37 ` [PATCH 06/18] mtd: fsl_upm: " Dmitry Eremin-Solenikov
@ 2011-06-22  9:37 ` Dmitry Eremin-Solenikov
  2011-06-22  9:37 ` [PATCH 08/18] mtd: ndfc: " Dmitry Eremin-Solenikov
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-22  9:37 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Woodhouse, Artem Bityutskiy

Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/nand/mpc5121_nfc.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/nand/mpc5121_nfc.c b/drivers/mtd/nand/mpc5121_nfc.c
index 0b61367..996ee29 100644
--- a/drivers/mtd/nand/mpc5121_nfc.c
+++ b/drivers/mtd/nand/mpc5121_nfc.c
@@ -661,6 +661,7 @@ static int __devinit mpc5121_nfc_probe(struct platform_device *op)
 	int resettime = 0;
 	int retval = 0;
 	int rev, len;
+	struct mtd_part_parser_data ppdata;
 
 	/*
 	 * Check SoC revision. This driver supports only NFC
@@ -725,6 +726,7 @@ static int __devinit mpc5121_nfc_probe(struct platform_device *op)
 	}
 
 	mtd->name = "MPC5121 NAND";
+	ppdata.of_node = dn;
 	chip->dev_ready = mpc5121_nfc_dev_ready;
 	chip->cmdfunc = mpc5121_nfc_command;
 	chip->read_byte = mpc5121_nfc_read_byte;
@@ -836,11 +838,7 @@ static int __devinit mpc5121_nfc_probe(struct platform_device *op)
 	dev_set_drvdata(dev, mtd);
 
 	/* Register device in MTD */
-	retval = parse_mtd_partitions(mtd, NULL, &parts, 0);
-#ifdef CONFIG_MTD_OF_PARTS
-	if (retval == 0)
-		retval = of_mtd_parse_partitions(dev, dn, &parts);
-#endif
+	retval = parse_mtd_partitions(mtd, NULL, &parts, &ppdata);
 	if (retval < 0) {
 		dev_err(dev, "Error parsing MTD partitions!\n");
 		devm_free_irq(dev, prv->irq, mtd);
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 08/18] mtd: ndfc: use ofpart through generic parsing
  2011-06-22  9:37 [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers Dmitry Eremin-Solenikov
                   ` (6 preceding siblings ...)
  2011-06-22  9:37 ` [PATCH 07/18] mtd: mpc5121_nfc: " Dmitry Eremin-Solenikov
@ 2011-06-22  9:37 ` Dmitry Eremin-Solenikov
  2011-06-22  9:37 ` [PATCH 09/18] mtd: socrates_nand: " Dmitry Eremin-Solenikov
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-22  9:37 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Woodhouse, Artem Bityutskiy

Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/nand/ndfc.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c
index 70c04ff..1528734 100644
--- a/drivers/mtd/nand/ndfc.c
+++ b/drivers/mtd/nand/ndfc.c
@@ -161,6 +161,7 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,
 {
 	struct device_node *flash_np;
 	struct nand_chip *chip = &ndfc->chip;
+	struct mtd_part_parser_data ppdata;
 	int ret;
 
 	chip->IO_ADDR_R = ndfc->ndfcbase + NDFC_DATA;
@@ -188,6 +189,7 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,
 	if (!flash_np)
 		return -ENODEV;
 
+	ppdata->of_node = flash_np;
 	ndfc->mtd.name = kasprintf(GFP_KERNEL, "%s.%s",
 			dev_name(&ndfc->ofdev->dev), flash_np->name);
 	if (!ndfc->mtd.name) {
@@ -199,17 +201,10 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,
 	if (ret)
 		goto err;
 
-	ret = parse_mtd_partitions(&ndfc->mtd, NULL, &ndfc->parts, 0);
+	ret = parse_mtd_partitions(&ndfc->mtd, NULL, &ndfc->parts, &ppdata);
 	if (ret < 0)
 		goto err;
 
-	if (ret == 0) {
-		ret = of_mtd_parse_partitions(&ndfc->ofdev->dev, flash_np,
-					      &ndfc->parts);
-		if (ret < 0)
-			goto err;
-	}
-
 	ret = mtd_device_register(&ndfc->mtd, ndfc->parts, ret);
 
 err:
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 09/18] mtd: socrates_nand: use ofpart through generic parsing
  2011-06-22  9:37 [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers Dmitry Eremin-Solenikov
                   ` (7 preceding siblings ...)
  2011-06-22  9:37 ` [PATCH 08/18] mtd: ndfc: " Dmitry Eremin-Solenikov
@ 2011-06-22  9:37 ` Dmitry Eremin-Solenikov
  2011-06-22  9:37 ` [PATCH 10/18] mtd: drop of_mtd_parse_partitions() Dmitry Eremin-Solenikov
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-22  9:37 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Woodhouse, Artem Bityutskiy

Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/nand/socrates_nand.c |   14 +++-----------
 1 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/nand/socrates_nand.c b/drivers/mtd/nand/socrates_nand.c
index 9023ac8..f4f79ec 100644
--- a/drivers/mtd/nand/socrates_nand.c
+++ b/drivers/mtd/nand/socrates_nand.c
@@ -166,6 +166,7 @@ static int __devinit socrates_nand_probe(struct platform_device *ofdev)
 	int res;
 	struct mtd_partition *partitions = NULL;
 	int num_partitions = 0;
+	struct mtd_part_parser_data ppdata;
 
 	/* Allocate memory for the device structure (and zero it) */
 	host = kzalloc(sizeof(struct socrates_nand_host), GFP_KERNEL);
@@ -191,6 +192,7 @@ static int __devinit socrates_nand_probe(struct platform_device *ofdev)
 	mtd->name = "socrates_nand";
 	mtd->owner = THIS_MODULE;
 	mtd->dev.parent = &ofdev->dev;
+	ppdata.of_node = ofdev->dev.of_node;
 
 	/*should never be accessed directly */
 	nand_chip->IO_ADDR_R = (void *)0xdeadbeef;
@@ -223,22 +225,12 @@ static int __devinit socrates_nand_probe(struct platform_device *ofdev)
 		goto out;
 	}
 
-	num_partitions = parse_mtd_partitions(mtd, NULL, &partitions, 0);
+	num_partitions = parse_mtd_partitions(mtd, NULL, &partitions, &ppdata);
 	if (num_partitions < 0) {
 		res = num_partitions;
 		goto release;
 	}
 
-	if (num_partitions == 0) {
-		num_partitions = of_mtd_parse_partitions(&ofdev->dev,
-							 ofdev->dev.of_node,
-							 &partitions);
-		if (num_partitions < 0) {
-			res = num_partitions;
-			goto release;
-		}
-	}
-
 	res = mtd_device_register(mtd, partitions, num_partitions);
 	if (!res)
 		return res;
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 10/18] mtd: drop of_mtd_parse_partitions()
  2011-06-22  9:37 [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers Dmitry Eremin-Solenikov
                   ` (8 preceding siblings ...)
  2011-06-22  9:37 ` [PATCH 09/18] mtd: socrates_nand: " Dmitry Eremin-Solenikov
@ 2011-06-22  9:37 ` Dmitry Eremin-Solenikov
  2011-06-22  9:37 ` [PATCH 11/18] mtd: physmap_of: move parse_obsolete_partitions to become separate parser Dmitry Eremin-Solenikov
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-22  9:37 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Woodhouse, Artem Bityutskiy

All users have been converted to call of_mtd_parse_partitions through
parse_mtd_partitions() multiplexer. Drop obsolete API.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/ofpart.c           |   20 +++++++++-----------
 include/linux/mtd/partitions.h |   16 ----------------
 2 files changed, 9 insertions(+), 27 deletions(-)

diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c
index 7c2c926..24007f3 100644
--- a/drivers/mtd/ofpart.c
+++ b/drivers/mtd/ofpart.c
@@ -24,20 +24,19 @@ static int parse_ofpart_partitions(struct mtd_info *master,
 				   struct mtd_partition **pparts,
 				   struct mtd_part_parser_data *data)
 {
-	if (!data || !data->of_node)
-		return 0;
-
-	return of_mtd_parse_partitions(NULL, data->of_node, pparts);
-}
-
-int of_mtd_parse_partitions(struct device *dev,
-                                      struct device_node *node,
-                                      struct mtd_partition **pparts)
-{
+	struct device_node *node;
 	const char *partname;
 	struct device_node *pp;
 	int nr_parts, i;
 
+
+	if (!data)
+		return 0;
+
+	node = data->of_node;
+	if (!node)
+		return 0;
+
 	/* First count the subnodes */
 	pp = NULL;
 	nr_parts = 0;
@@ -87,7 +86,6 @@ int of_mtd_parse_partitions(struct device *dev,
 
 	return nr_parts;
 }
-EXPORT_SYMBOL(of_mtd_parse_partitions);
 
 static struct mtd_part_parser ofpart_parser = {
 	.owner = THIS_MODULE,
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index 6e724af..c3dcf35 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -86,22 +86,6 @@ extern int parse_mtd_partitions(struct mtd_info *master, const char **types,
 
 #define put_partition_parser(p) do { module_put((p)->owner); } while(0)
 
-struct device;
-struct device_node;
-
-#ifdef CONFIG_MTD_OF_PARTS
-int of_mtd_parse_partitions(struct device *dev,
-                                      struct device_node *node,
-                                      struct mtd_partition **pparts);
-#else
-static inline int of_mtd_parse_partitions(struct device *dev,
-					  struct device_node *node,
-					  struct mtd_partition **pparts)
-{
-	return 0;
-}
-#endif
-
 int mtd_is_partition(struct mtd_info *mtd);
 int mtd_add_partition(struct mtd_info *master, char *name,
 		      long long offset, long long length);
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 11/18] mtd: physmap_of: move parse_obsolete_partitions to become separate parser
  2011-06-22  9:37 [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers Dmitry Eremin-Solenikov
                   ` (9 preceding siblings ...)
  2011-06-22  9:37 ` [PATCH 10/18] mtd: drop of_mtd_parse_partitions() Dmitry Eremin-Solenikov
@ 2011-06-22  9:37 ` Dmitry Eremin-Solenikov
  2011-06-22  9:37 ` [PATCH 12/18] mtd: physmap_of.c: use mtd_device_parse_register Dmitry Eremin-Solenikov
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-22  9:37 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Woodhouse, Artem Bityutskiy

Move parse_obsolete_partitions() to ofpart.c and register it as an
ofoldpart partitions parser.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/maps/physmap_of.c |   53 +----------------------------
 drivers/mtd/ofpart.c          |   75 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 75 insertions(+), 53 deletions(-)

diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
index 6a75743..55c4e2e 100644
--- a/drivers/mtd/maps/physmap_of.c
+++ b/drivers/mtd/maps/physmap_of.c
@@ -40,51 +40,6 @@ struct of_flash {
 };
 
 #define OF_FLASH_PARTS(info)	((info)->parts)
-static int parse_obsolete_partitions(struct platform_device *dev,
-				     struct of_flash *info,
-				     struct device_node *dp)
-{
-	int i, plen, nr_parts;
-	const struct {
-		__be32 offset, len;
-	} *part;
-	const char *names;
-
-	part = of_get_property(dp, "partitions", &plen);
-	if (!part)
-		return 0; /* No partitions found */
-
-	dev_warn(&dev->dev, "Device tree uses obsolete partition map binding\n");
-
-	nr_parts = plen / sizeof(part[0]);
-
-	info->parts = kzalloc(nr_parts * sizeof(*info->parts), GFP_KERNEL);
-	if (!info->parts)
-		return -ENOMEM;
-
-	names = of_get_property(dp, "partition-names", &plen);
-
-	for (i = 0; i < nr_parts; i++) {
-		info->parts[i].offset = be32_to_cpu(part->offset);
-		info->parts[i].size   = be32_to_cpu(part->len) & ~1;
-		if (be32_to_cpu(part->len) & 1) /* bit 0 set signifies read only partition */
-			info->parts[i].mask_flags = MTD_WRITEABLE;
-
-		if (names && (plen > 0)) {
-			int len = strlen(names) + 1;
-
-			info->parts[i].name = (char *)names;
-			plen -= len;
-			names += len;
-		} else {
-			info->parts[i].name = "unnamed";
-		}
-
-		part++;
-	}
-
-	return nr_parts;
-}
 
 static int of_flash_remove(struct platform_device *dev)
 {
@@ -166,7 +121,7 @@ static struct mtd_info * __devinit obsolete_probe(struct platform_device *dev,
    default is use. These take precedence over other device tree
    information. */
 static const char *part_probe_types_def[] = { "cmdlinepart", "RedBoot",
-					"ofpart", NULL };
+					"ofpart", "ofoldpart", NULL };
 static const char ** __devinit of_get_probes(struct device_node *dp)
 {
 	const char *cp;
@@ -343,12 +298,6 @@ static int __devinit of_flash_probe(struct platform_device *dev)
 	}
 	of_free_probes(part_probe_types);
 
-	if (err == 0) {
-		err = parse_obsolete_partitions(dev, info, dp);
-		if (err < 0)
-			goto err_out;
-	}
-
 	mtd_device_register(info->cmtd, info->parts, err);
 
 	kfree(mtd_list);
diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c
index 24007f3..41c4518 100644
--- a/drivers/mtd/ofpart.c
+++ b/drivers/mtd/ofpart.c
@@ -93,9 +93,82 @@ static struct mtd_part_parser ofpart_parser = {
 	.name = "ofpart",
 };
 
+static int parse_ofoldpart_partitions(struct mtd_info *master,
+				      struct mtd_partition **pparts,
+				      struct mtd_part_parser_data *data)
+{
+	struct device_node *dp;
+	int i, plen, nr_parts;
+	const struct {
+		__be32 offset, len;
+	} *part;
+	const char *names;
+
+	if (!data)
+		return 0;
+
+	dp = data->of_node;
+	if (!dp)
+		return 0;
+
+	part = of_get_property(dp, "partitions", &plen);
+	if (!part)
+		return 0; /* No partitions found */
+
+	pr_warning("Device tree uses obsolete partition map binding: %s\n",
+			dp->full_name);
+
+	nr_parts = plen / sizeof(part[0]);
+
+	*pparts = kzalloc(nr_parts * sizeof(*(*pparts)), GFP_KERNEL);
+	if (!pparts)
+		return -ENOMEM;
+
+	names = of_get_property(dp, "partition-names", &plen);
+
+	for (i = 0; i < nr_parts; i++) {
+		(*pparts)[i].offset = be32_to_cpu(part->offset);
+		(*pparts)[i].size   = be32_to_cpu(part->len) & ~1;
+		/* bit 0 set signifies read only partition */
+		if (be32_to_cpu(part->len) & 1)
+			(*pparts)[i].mask_flags = MTD_WRITEABLE;
+
+		if (names && (plen > 0)) {
+			int len = strlen(names) + 1;
+
+			(*pparts)[i].name = (char *)names;
+			plen -= len;
+			names += len;
+		} else {
+			(*pparts)[i].name = "unnamed";
+		}
+
+		part++;
+	}
+
+	return nr_parts;
+}
+
+static struct mtd_part_parser ofoldpart_parser = {
+	.owner = THIS_MODULE,
+	.parse_fn = parse_ofoldpart_partitions,
+	.name = "ofoldpart",
+};
+
 static int __init ofpart_parser_init(void)
 {
-	return register_mtd_parser(&ofpart_parser);
+	int rc;
+	rc = register_mtd_parser(&ofpart_parser);
+	if (rc)
+		goto out;
+
+	rc = register_mtd_parser(&ofoldpart_parser);
+	if (!rc)
+		return 0;
+
+	deregister_mtd_parser(&ofoldpart_parser);
+out:
+	return rc;
 }
 
 module_init(ofpart_parser_init);
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 12/18] mtd: physmap_of.c: use mtd_device_parse_register
  2011-06-22  9:37 [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers Dmitry Eremin-Solenikov
                   ` (10 preceding siblings ...)
  2011-06-22  9:37 ` [PATCH 11/18] mtd: physmap_of: move parse_obsolete_partitions to become separate parser Dmitry Eremin-Solenikov
@ 2011-06-22  9:37 ` Dmitry Eremin-Solenikov
  2011-06-22  9:37 ` [PATCH 13/18] mtd: m25p80.c: " Dmitry Eremin-Solenikov
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-22  9:37 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Woodhouse, Artem Bityutskiy

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/maps/physmap_of.c |   18 +++---------------
 1 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
index 55c4e2e..7d65f9d 100644
--- a/drivers/mtd/maps/physmap_of.c
+++ b/drivers/mtd/maps/physmap_of.c
@@ -34,13 +34,10 @@ struct of_flash_list {
 
 struct of_flash {
 	struct mtd_info		*cmtd;
-	struct mtd_partition	*parts;
 	int list_size; /* number of elements in of_flash_list */
 	struct of_flash_list	list[0];
 };
 
-#define OF_FLASH_PARTS(info)	((info)->parts)
-
 static int of_flash_remove(struct platform_device *dev)
 {
 	struct of_flash *info;
@@ -56,11 +53,8 @@ static int of_flash_remove(struct platform_device *dev)
 		mtd_concat_destroy(info->cmtd);
 	}
 
-	if (info->cmtd) {
-		if (OF_FLASH_PARTS(info))
-			kfree(OF_FLASH_PARTS(info));
+	if (info->cmtd)
 		mtd_device_unregister(info->cmtd);
-	}
 
 	for (i = 0; i < info->list_size; i++) {
 		if (info->list[i].mtd)
@@ -290,16 +284,10 @@ static int __devinit of_flash_probe(struct platform_device *dev)
 
 	ppdata.of_node = dp;
 	part_probe_types = of_get_probes(dp);
-	err = parse_mtd_partitions(info->cmtd, part_probe_types,
-				   &info->parts, &ppdata);
-	if (err < 0) {
-		of_free_probes(part_probe_types);
-		goto err_out;
-	}
+	mtd_device_parse_register(info->cmtd, part_probe_types, &ppdata,
+			NULL, 0);
 	of_free_probes(part_probe_types);
 
-	mtd_device_register(info->cmtd, info->parts, err);
-
 	kfree(mtd_list);
 
 	return 0;
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 13/18] mtd: m25p80.c: use mtd_device_parse_register
  2011-06-22  9:37 [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers Dmitry Eremin-Solenikov
                   ` (11 preceding siblings ...)
  2011-06-22  9:37 ` [PATCH 12/18] mtd: physmap_of.c: use mtd_device_parse_register Dmitry Eremin-Solenikov
@ 2011-06-22  9:37 ` Dmitry Eremin-Solenikov
  2011-06-22  9:37 ` [PATCH 14/18] mtd: fsl_elbc_nand.c: " Dmitry Eremin-Solenikov
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-22  9:37 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Woodhouse, Artem Bityutskiy

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/devices/m25p80.c |   28 +++-------------------------
 1 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 399c234..66a3555 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -88,7 +88,6 @@ struct m25p {
 	struct spi_device	*spi;
 	struct mutex		lock;
 	struct mtd_info		mtd;
-	unsigned		partitioned:1;
 	u16			page_size;
 	u16			addr_width;
 	u8			erase_opcode;
@@ -825,8 +824,6 @@ static int __devinit m25p_probe(struct spi_device *spi)
 	struct m25p			*flash;
 	struct flash_info		*info;
 	unsigned			i;
-	struct mtd_partition		*parts = NULL;
-	int				nr_parts = 0;
 	struct mtd_part_parser_data	ppdata;
 
 	/* Platform data helps sort out which chip type we have, as
@@ -970,28 +967,9 @@ static int __devinit m25p_probe(struct spi_device *spi)
 	/* partitions should match sector boundaries; and it may be good to
 	 * use readonly partitions for writeprotected sectors (BP2..BP0).
 	 */
-	nr_parts = parse_mtd_partitions(&flash->mtd, NULL, &parts, &ppdata);
-
-	if (nr_parts <= 0 && data && data->parts) {
-		parts = data->parts;
-		nr_parts = data->nr_parts;
-	}
-
-	if (nr_parts > 0) {
-		for (i = 0; i < nr_parts; i++) {
-			DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = "
-			      "{.name = %s, .offset = 0x%llx, "
-			      ".size = 0x%llx (%lldKiB) }\n",
-			      i, parts[i].name,
-			      (long long)parts[i].offset,
-			      (long long)parts[i].size,
-			      (long long)(parts[i].size >> 10));
-		}
-		flash->partitioned = 1;
-	}
-
-	return mtd_device_register(&flash->mtd, parts, nr_parts) == 1 ?
-		-ENODEV : 0;
+	return mtd_device_parse_register(&flash->mtd, NULL, &ppdata,
+			data ? data->parts : NULL,
+			data ? data->nr_parts : 0);
 }
 
 
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 14/18] mtd: fsl_elbc_nand.c: use mtd_device_parse_register
  2011-06-22  9:37 [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers Dmitry Eremin-Solenikov
                   ` (12 preceding siblings ...)
  2011-06-22  9:37 ` [PATCH 13/18] mtd: m25p80.c: " Dmitry Eremin-Solenikov
@ 2011-06-22  9:37 ` Dmitry Eremin-Solenikov
  2011-06-22  9:37 ` [PATCH 15/18] mtd: fsl_upm.c: " Dmitry Eremin-Solenikov
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-22  9:37 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Woodhouse, Artem Bityutskiy

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/nand/fsl_elbc_nand.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index 4d225ba..915b4a4 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -843,7 +843,6 @@ static int __devinit fsl_elbc_nand_probe(struct platform_device *pdev)
 	struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl;
 	static const char *part_probe_types[]
 		= { "cmdlinepart", "RedBoot", "ofpart", NULL };
-	struct mtd_partition *parts;
 	int ret;
 	int bank;
 	struct device *dev;
@@ -936,11 +935,8 @@ static int __devinit fsl_elbc_nand_probe(struct platform_device *pdev)
 
 	/* First look for RedBoot table or partitions on the command
 	 * line, these take precedence over device tree information */
-	ret = parse_mtd_partitions(&priv->mtd, part_probe_types, &parts, &ppdata);
-	if (ret < 0)
-		goto err;
-
-	mtd_device_register(&priv->mtd, parts, ret);
+	mtd_device_parse_register(&priv->mtd, part_probe_types, &ppdata,
+				  NULL, 0);
 
 	printk(KERN_INFO "eLBC NAND device at 0x%llx, bank %d\n",
 	       (unsigned long long)res.start, priv->bank);
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 15/18] mtd: fsl_upm.c: use mtd_device_parse_register
  2011-06-22  9:37 [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers Dmitry Eremin-Solenikov
                   ` (13 preceding siblings ...)
  2011-06-22  9:37 ` [PATCH 14/18] mtd: fsl_elbc_nand.c: " Dmitry Eremin-Solenikov
@ 2011-06-22  9:37 ` Dmitry Eremin-Solenikov
  2011-06-22  9:37 ` [PATCH 16/18] mtd: mpc5121_nfc.c: " Dmitry Eremin-Solenikov
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-22  9:37 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Woodhouse, Artem Bityutskiy

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/nand/fsl_upm.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/fsl_upm.c b/drivers/mtd/nand/fsl_upm.c
index 714d831..da92fed 100644
--- a/drivers/mtd/nand/fsl_upm.c
+++ b/drivers/mtd/nand/fsl_upm.c
@@ -193,9 +193,7 @@ static int __devinit fun_chip_init(struct fsl_upm_nand *fun,
 		goto err;
 
 	ppdata.of_node = flash_np;
-	ret = parse_mtd_partitions(&fun->mtd, NULL, &fun->parts, &ppdata);
-
-	ret = mtd_device_register(&fun->mtd, fun->parts, ret);
+	ret = mtd_device_parse_register(&fun->mtd, NULL, &ppdata, NULL, 0);
 err:
 	of_node_put(flash_np);
 	return ret;
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 16/18] mtd: mpc5121_nfc.c: use mtd_device_parse_register
  2011-06-22  9:37 [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers Dmitry Eremin-Solenikov
                   ` (14 preceding siblings ...)
  2011-06-22  9:37 ` [PATCH 15/18] mtd: fsl_upm.c: " Dmitry Eremin-Solenikov
@ 2011-06-22  9:37 ` Dmitry Eremin-Solenikov
  2011-06-22  9:37 ` [PATCH 17/18] mtd: ndfc.c: " Dmitry Eremin-Solenikov
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-22  9:37 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Woodhouse, Artem Bityutskiy

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/nand/mpc5121_nfc.c |   11 +----------
 1 files changed, 1 insertions(+), 10 deletions(-)

diff --git a/drivers/mtd/nand/mpc5121_nfc.c b/drivers/mtd/nand/mpc5121_nfc.c
index 996ee29..871095f 100644
--- a/drivers/mtd/nand/mpc5121_nfc.c
+++ b/drivers/mtd/nand/mpc5121_nfc.c
@@ -654,7 +654,6 @@ static int __devinit mpc5121_nfc_probe(struct platform_device *op)
 	struct mpc5121_nfc_prv *prv;
 	struct resource res;
 	struct mtd_info *mtd;
-	struct mtd_partition *parts;
 	struct nand_chip *chip;
 	unsigned long regs_paddr, regs_size;
 	const __be32 *chips_no;
@@ -838,15 +837,7 @@ static int __devinit mpc5121_nfc_probe(struct platform_device *op)
 	dev_set_drvdata(dev, mtd);
 
 	/* Register device in MTD */
-	retval = parse_mtd_partitions(mtd, NULL, &parts, &ppdata);
-	if (retval < 0) {
-		dev_err(dev, "Error parsing MTD partitions!\n");
-		devm_free_irq(dev, prv->irq, mtd);
-		retval = -EINVAL;
-		goto error;
-	}
-
-	retval = mtd_device_register(mtd, parts, retval);
+	retval = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0);
 	if (retval) {
 		dev_err(dev, "Error adding MTD device!\n");
 		devm_free_irq(dev, prv->irq, mtd);
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 17/18] mtd: ndfc.c: use mtd_device_parse_register
  2011-06-22  9:37 [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers Dmitry Eremin-Solenikov
                   ` (15 preceding siblings ...)
  2011-06-22  9:37 ` [PATCH 16/18] mtd: mpc5121_nfc.c: " Dmitry Eremin-Solenikov
@ 2011-06-22  9:37 ` Dmitry Eremin-Solenikov
  2011-06-22  9:37 ` [PATCH 18/18] mtd: socrates_nand.c: " Dmitry Eremin-Solenikov
  2011-06-23  7:56 ` [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers Artem Bityutskiy
  18 siblings, 0 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-22  9:37 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Woodhouse, Artem Bityutskiy

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/nand/ndfc.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c
index 1528734..ee17139 100644
--- a/drivers/mtd/nand/ndfc.c
+++ b/drivers/mtd/nand/ndfc.c
@@ -42,7 +42,6 @@ struct ndfc_controller {
 	struct nand_chip chip;
 	int chip_select;
 	struct nand_hw_control ndfc_control;
-	struct mtd_partition *parts;
 };
 
 static struct ndfc_controller ndfc_ctrl[NDFC_MAX_CS];
@@ -201,11 +200,7 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,
 	if (ret)
 		goto err;
 
-	ret = parse_mtd_partitions(&ndfc->mtd, NULL, &ndfc->parts, &ppdata);
-	if (ret < 0)
-		goto err;
-
-	ret = mtd_device_register(&ndfc->mtd, ndfc->parts, ret);
+	ret = mtd_device_parse_register(&ndfc->mtd, NULL, &ppdata, NULL, 0);
 
 err:
 	of_node_put(flash_np);
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 18/18] mtd: socrates_nand.c: use mtd_device_parse_register
  2011-06-22  9:37 [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers Dmitry Eremin-Solenikov
                   ` (16 preceding siblings ...)
  2011-06-22  9:37 ` [PATCH 17/18] mtd: ndfc.c: " Dmitry Eremin-Solenikov
@ 2011-06-22  9:37 ` Dmitry Eremin-Solenikov
  2011-06-23  7:56 ` [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers Artem Bityutskiy
  18 siblings, 0 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-22  9:37 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Woodhouse, Artem Bityutskiy

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/nand/socrates_nand.c |   11 +----------
 1 files changed, 1 insertions(+), 10 deletions(-)

diff --git a/drivers/mtd/nand/socrates_nand.c b/drivers/mtd/nand/socrates_nand.c
index f4f79ec..0fb24f9 100644
--- a/drivers/mtd/nand/socrates_nand.c
+++ b/drivers/mtd/nand/socrates_nand.c
@@ -164,8 +164,6 @@ static int __devinit socrates_nand_probe(struct platform_device *ofdev)
 	struct mtd_info *mtd;
 	struct nand_chip *nand_chip;
 	int res;
-	struct mtd_partition *partitions = NULL;
-	int num_partitions = 0;
 	struct mtd_part_parser_data ppdata;
 
 	/* Allocate memory for the device structure (and zero it) */
@@ -225,17 +223,10 @@ static int __devinit socrates_nand_probe(struct platform_device *ofdev)
 		goto out;
 	}
 
-	num_partitions = parse_mtd_partitions(mtd, NULL, &partitions, &ppdata);
-	if (num_partitions < 0) {
-		res = num_partitions;
-		goto release;
-	}
-
-	res = mtd_device_register(mtd, partitions, num_partitions);
+	res = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0);
 	if (!res)
 		return res;
 
-release:
 	nand_release(mtd);
 
 out:
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers
  2011-06-22  9:37 [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers Dmitry Eremin-Solenikov
                   ` (17 preceding siblings ...)
  2011-06-22  9:37 ` [PATCH 18/18] mtd: socrates_nand.c: " Dmitry Eremin-Solenikov
@ 2011-06-23  7:56 ` Artem Bityutskiy
  18 siblings, 0 replies; 22+ messages in thread
From: Artem Bityutskiy @ 2011-06-23  7:56 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: David Woodhouse, linux-mtd

On Wed, 2011-06-22 at 13:37 +0400, Dmitry Eremin-Solenikov wrote:
> Changes since V1:
>  * Tab-vs-space cleanup
>  * 80-column cleanup
>  * documented of_node parser data field
>  * changed documentation for parser_data arguments

Pushed to l2-mtd-2.6.git, thanks for good cleanups.

-- 
Best Regards,
Artem Bityutskiy

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2011-06-23  7:55 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2011-06-22  9:37 ` [PATCH 02/18] mtd: prepare to convert of_mtd_parse_partitions to partition parser Dmitry Eremin-Solenikov
2011-06-22  9:37 ` [PATCH 03/18] mtd: physmap_of: use ofpart through generic parsing Dmitry Eremin-Solenikov
2011-06-22  9:37 ` [PATCH 04/18] mtd: m25p80: " Dmitry Eremin-Solenikov
2011-06-22  9:37 ` [PATCH 05/18] mtd: fsl_elbc_nand: " Dmitry Eremin-Solenikov
2011-06-22  9:37 ` [PATCH 06/18] mtd: fsl_upm: " Dmitry Eremin-Solenikov
2011-06-22  9:37 ` [PATCH 07/18] mtd: mpc5121_nfc: " Dmitry Eremin-Solenikov
2011-06-22  9:37 ` [PATCH 08/18] mtd: ndfc: " Dmitry Eremin-Solenikov
2011-06-22  9:37 ` [PATCH 09/18] mtd: socrates_nand: " Dmitry Eremin-Solenikov
2011-06-22  9:37 ` [PATCH 10/18] mtd: drop of_mtd_parse_partitions() Dmitry Eremin-Solenikov
2011-06-22  9:37 ` [PATCH 11/18] mtd: physmap_of: move parse_obsolete_partitions to become separate parser Dmitry Eremin-Solenikov
2011-06-22  9:37 ` [PATCH 12/18] mtd: physmap_of.c: use mtd_device_parse_register Dmitry Eremin-Solenikov
2011-06-22  9:37 ` [PATCH 13/18] mtd: m25p80.c: " Dmitry Eremin-Solenikov
2011-06-22  9:37 ` [PATCH 14/18] mtd: fsl_elbc_nand.c: " Dmitry Eremin-Solenikov
2011-06-22  9:37 ` [PATCH 15/18] mtd: fsl_upm.c: " Dmitry Eremin-Solenikov
2011-06-22  9:37 ` [PATCH 16/18] mtd: mpc5121_nfc.c: " Dmitry Eremin-Solenikov
2011-06-22  9:37 ` [PATCH 17/18] mtd: ndfc.c: " Dmitry Eremin-Solenikov
2011-06-22  9:37 ` [PATCH 18/18] mtd: socrates_nand.c: " Dmitry Eremin-Solenikov
2011-06-23  7:56 ` [PATCH V2 00/18] mtd: cleanup partition handling in OF-enabled drivers Artem Bityutskiy
  -- strict thread matches above, loose matches on Subject: below --
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 ` [PATCH 02/18] mtd: prepare to convert of_mtd_parse_partitions to partition parser Dmitry Eremin-Solenikov
2011-06-22  4:22   ` Artem Bityutskiy

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).