mtd: last pile of MTD partition cleanup patches
Subsystems (2)
cover mtd: last pile of MTD partition cleanup patches
Here goes last serie of my current work on cleaning up the MTD partition handling. Now my goal is to clean up OF partition handling.
The following changes since commit 3e1643b282542cf524d30cfab4cfe38f6b2afa99:
mtd: edb7312: correctly pass MTD name to parsers (2011-06-09 15:30:44 +0300)
are available in the git repository at:
git://git.infradead.org/users/dbaryshkov/mtd-cleanup.git mtd-big-cleanup
Dmitry Eremin-Solenikov (17):
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()
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/devices/m25p80.c | 36 ++------------ drivers/mtd/maps/physmap_of.c | 79 ++---------------------------- drivers/mtd/mtdcore.c | 19 +++++++ drivers/mtd/mtdpart.c | 8 ++- drivers/mtd/nand/fsl_elbc_nand.c | 16 +----- drivers/mtd/nand/fsl_upm.c | 12 +---- drivers/mtd/nand/mpc5121_nfc.c | 16 +----- drivers/mtd/nand/ndfc.c | 15 +----- drivers/mtd/nand/socrates_nand.c | 22 +-------- drivers/mtd/ofpart.c | 98 ++++++++++++++++++++++++++++++++++++-- include/linux/mtd/mtd.h | 5 ++ include/linux/mtd/partitions.h | 16 ------ 12 files changed, 144 insertions(+), 198 deletions(-)
PATCH 1/17 mtd: prepare to convert of_mtd_parse_partitions to partition parser
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_info struct
4) Move of_mtd_parse_partitions from __devinit to common text section
5) add ofpart to the default list of partition parsers
--- drivers/mtd/mtdcore.c | 19 +++++++++++++++++++ drivers/mtd/mtdpart.c | 8 ++++++-- drivers/mtd/ofpart.c | 30 ++++++++++++++++++++++++++++-- include/linux/mtd/mtd.h | 5 +++++ include/linux/mtd/partitions.h | 2 +- 5 files changed, 59 insertions(+), 5 deletions(-)
drivers/mtd/mtdcore.c +19 -0
@@ -36,6 +36,7 @@#include <linux/idr.h> #include <linux/backing-dev.h> #include <linux/gfp.h> +#include <linux/of.h> #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h>
@@ -446,6 +447,10 @@ int mtd_device_register(struct mtd_info *master, const struct mtd_partition *parts, int nr_parts) { +#ifdef CONFIG_OF +if (master->node) +of_node_get (master->node); +#endif return parts ?add_mtd_partitions (master, parts, nr_parts) :add_mtd_device (master); }
@@ -487,6 +492,11 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char **types,int err;struct mtd_partition *real_parts; +#ifdef CONFIG_OF +if (mtd->node) +of_node_get (mtd->node); +#endif + err =parse_mtd_partitions (mtd, types, &real_parts, origin);if (err <=0 && nr_parts) { real_parts = kmemdup(parts, sizeof(*parts) * nr_parts,
@@ -505,6 +515,11 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char **types, err = -ENODEV ; } +#ifdef CONFIG_OF +if (err <0 && mtd->node) +of_node_put (mtd->node); +#endif +return err; }EXPORT_SYMBOL_GPL (mtd_device_parse_register);
@@ -519,6 +534,10 @@ int mtd_device_unregister(struct mtd_info *master) {int err; +#ifdef CONFIG_OF +if (master->node) +of_node_put (master->node); +#endif err =del_mtd_partitions (master);if (err)return err;
drivers/mtd/mtdpart.c +6 -2
@@ -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 *const 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
drivers/mtd/ofpart.c +28 -2
@@ -20,7 +20,20 @@#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, +unsigned long origin) +{ +struct device_node *node; + + node = master->node; +if (!node) +return 0 ; + +return of_mtd_parse_partitions (NULL , node, pparts); +} + +int of_mtd_parse_partitions (struct device *dev,struct device_node *node,struct mtd_partition **pparts) {
@@ -69,7 +82,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 +92,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" );
include/linux/mtd/mtd.h +5 -0
@@ -171,6 +171,11 @@ struct mtd_info {// Kernel-only stuff starts here. const char *name;int index; +#ifdef CONFIG_OF +/* Set by driver, reference counting handled by MTD registration/ +* unregistration functions. */ +struct device_node *node; +#endif /* ecc layout structure pointer - read only ! */ struct nand_ecclayout *ecclayout;
include/linux/mtd/partitions.h +1 -1
@@ -74,7 +74,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
Signature · 1 line
1.7.5.3
Re: [PATCH 01/17] mtd: prepare to convert of_mtd_parse_partitions to partition parser
Quoted 29 lines · Dmitry Eremin-Solenikov
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) Adddevice_nodetomtd_infostruct
4) Moveof_mtd_parse_partitionsfrom__devinitto common text section
5) add ofpart to the default list of partition parsersSigned-off-by Dmitry Eremin-Solenikov <[email protected]>--- drivers/mtd/mtdcore.c | 19 +++++++++++++++++++ drivers/mtd/mtdpart.c | 8 ++++++-- drivers/mtd/ofpart.c | 30 ++++++++++++++++++++++++++++-- include/linux/mtd/mtd.h | 5 +++++ include/linux/mtd/partitions.h | 2 +- 5 files changed, 59 insertions(+), 5 deletions(-)drivers/mtd/mtdcore.c +1
-0@@ -36,6 +36,7 @@#include <linux/idr.h> #include <linux/backing-dev.h> #include <linux/gfp.h> +#include <linux/of.h> #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h>
drivers/mtd/mtdcore.c int mtd_device_register(struct mtd_info *master, · line 453
Quoted 7 lines
drivers/mtd/mtdcore.c +4
-0@@ -446,6 +447,10 @@ int mtd_device_register(struct mtd_info *master, const struct mtd_partition *parts, int nr_parts) { +#ifdef CONFIG_OF +if (master->node) +of_node_get (master->node); +#endif
These ifdefs are not very nice, do you have ideas how to avoid them? Ideally, mtdcore should not know or bother about OF things. All OF-specific things should be done in ofpart.c...
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
Re: [PATCH 01/17] mtd: prepare to convert of_mtd_parse_partitions to partition parser
Quoted 27 lines · Artem Bityutskiy
Quoted 26 lines · Dmitry Eremin-Solenikov
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) Adddevice_nodetomtd_infostruct
4) Moveof_mtd_parse_partitionsfrom__devinitto common text section
5) add ofpart to the default list of partition parsersSigned-off-by Dmitry Eremin-Solenikov<[email protected]>--- drivers/mtd/mtdcore.c | 19 +++++++++++++++++++ drivers/mtd/mtdpart.c | 8 ++++++-- drivers/mtd/ofpart.c | 30 ++++++++++++++++++++++++++++-- include/linux/mtd/mtd.h | 5 +++++ include/linux/mtd/partitions.h | 2 +- 5 files changed, 59 insertions(+), 5 deletions(-)drivers/mtd/mtdcore.c +1
-0@@ -36,6 +36,7 @@#include <linux/idr.h> #include <linux/backing-dev.h> #include <linux/gfp.h> +#include <linux/of.h>
Quoted 14 lines
drivers/mtd/mtdcore.c int mtd_device_register(struct mtd_info *master, · line 453
Quoted 10 lines
drivers/mtd/mtdcore.c +4
-0#include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> @@ -446,6 +447,10 @@ int mtd_device_register(struct mtd_info *master, const struct mtd_partition *parts, int nr_parts) { +#ifdef CONFIG_OF +if (master->node) +of_node_get (master->node); +#endif These ifdefs are not very nice, do you have ideas how to avoid them? Ideally, mtdcore should not know or bother about OF things. All OF-specific things should be done in
ofpart.c...
I know they aren't nice. OTOH ofpart.c also seems a bit non-logical: one can have of node in the MTD, but doesn't (strangely) want to compile in ofpart.c. Of course I can add separate small of-handling functions (to do OF handling) to mtdcore.c to be replaced by empty functions in the absence of CONFIG_OF, but this also look like overhead for me.
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH 01/17] mtd: prepare to convert of_mtd_parse_partitions to partition parser
Quoted 43 lines · Dmitry Eremin-Solenikov
Quoted 27 lines · Artem Bityutskiy
Quoted 26 lines · Dmitry Eremin-Solenikov
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) Adddevice_nodetomtd_infostruct
4) Moveof_mtd_parse_partitionsfrom__devinitto common text section
5) add ofpart to the default list of partition parsersSigned-off-by Dmitry Eremin-Solenikov<[email protected]>--- drivers/mtd/mtdcore.c | 19 +++++++++++++++++++ drivers/mtd/mtdpart.c | 8 ++++++-- drivers/mtd/ofpart.c | 30 ++++++++++++++++++++++++++++-- include/linux/mtd/mtd.h | 5 +++++ include/linux/mtd/partitions.h | 2 +- 5 files changed, 59 insertions(+), 5 deletions(-)drivers/mtd/mtdcore.c +1
-0@@ -36,6 +36,7 @@#include <linux/idr.h> #include <linux/backing-dev.h> #include <linux/gfp.h> +#include <linux/of.h> Quoted 14 lines
drivers/mtd/mtdcore.c int mtd_device_register(struct mtd_info *master, · line 453
Quoted 10 lines
drivers/mtd/mtdcore.c +4
-0#include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> @@ -446,6 +447,10 @@ int mtd_device_register(struct mtd_info *master, const struct mtd_partition *parts, int nr_parts) { +#ifdef CONFIG_OF +if (master->node) +of_node_get (master->node); +#endif These ifdefs are not very nice, do you have ideas how to avoid them? Ideally, mtdcore should not know or bother about OF things. All OF-specific things should be done in
ofpart.c...
Quoted 5 lines
I know they aren't nice. OTOH
ofpart.calso seems a bit non-logical: one can have of node in the MTD, but doesn't (strangely) want to compile inofpart.c. Of course I can add separate small of-handling functions (to do OF handling) tomtdcore.cto be replaced by empty functions in the absence ofCONFIG_OF, but this also look like overhead for me.
How about turning the "origin" argument into "void *private" and declaring that this is "parser-specific info". It then can become "origin" for the RedBoot parser and the OF node pointer for the ofpart parser?
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
Re: [PATCH 01/17] mtd: prepare to convert of_mtd_parse_partitions to partition parser
Quoted 50 lines · Artem Bityutskiy
Quoted 43 lines · Dmitry Eremin-Solenikov
Quoted 27 lines · Artem Bityutskiy
Quoted 26 lines · Dmitry Eremin-Solenikov
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) Adddevice_nodetomtd_infostruct
4) Moveof_mtd_parse_partitionsfrom__devinitto common text section
5) add ofpart to the default list of partition parsersSigned-off-by Dmitry Eremin-Solenikov<[email protected]>--- drivers/mtd/mtdcore.c | 19 +++++++++++++++++++ drivers/mtd/mtdpart.c | 8 ++++++-- drivers/mtd/ofpart.c | 30 ++++++++++++++++++++++++++++-- include/linux/mtd/mtd.h | 5 +++++ include/linux/mtd/partitions.h | 2 +- 5 files changed, 59 insertions(+), 5 deletions(-)drivers/mtd/mtdcore.c +1
-0@@ -36,6 +36,7 @@#include <linux/idr.h> #include <linux/backing-dev.h> #include <linux/gfp.h> +#include <linux/of.h> Quoted 14 lines
drivers/mtd/mtdcore.c int mtd_device_register(struct mtd_info *master, · line 453
Quoted 10 lines
drivers/mtd/mtdcore.c +4
-0#include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> @@ -446,6 +447,10 @@ int mtd_device_register(struct mtd_info *master, const struct mtd_partition *parts, int nr_parts) { +#ifdef CONFIG_OF +if (master->node) +of_node_get (master->node); +#endif These ifdefs are not very nice, do you have ideas how to avoid them? Ideally, mtdcore should not know or bother about OF things. All OF-specific things should be done in
ofpart.c...Quoted 5 lines
I know they aren't nice. OTOH
ofpart.calso seems a bit non-logical: one can have of node in the MTD, but doesn't (strangely) want to compile inofpart.c. Of course I can add separate small of-handling functions (to do OF handling) tomtdcore.cto be replaced by empty functions in the absence ofCONFIG_OF, but this also look like overhead for me.
Quoted 4 lines
How about turning the "origin" argument into "void *private" and declaring that this is "parser-specific info". It then can become "origin" for the RedBoot parser and the OF node pointer for the ofpart parser?
And what will happen when ixp4xx (the only user of redboot "exception") will get OF support?
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH 01/17] mtd: prepare to convert of_mtd_parse_partitions to partition parser
Quoted 15 lines · Dmitry Eremin-Solenikov
Quoted 15 lines
Quoted 14 lines
Quoted 8 lines
drivers/mtd/mtdcore.c int mtd_device_register(struct mtd_info *master, · line 453
Quoted 4 lines
drivers/mtd/mtdcore.c +4
-0+#ifdef CONFIG_OF +if (master->node) +of_node_get (master->node); +#endif These ifdefs are not very nice, do you have ideas how to avoid them? Ideally, mtdcore should not know or bother about OF things. All OF-specific things should be done in
ofpart.c...I know they aren't nice. OTOH
ofpart.calso seems a bit non-logical: one can have of node in the MTD, but doesn't (strangely) want to compile inofpart.c. Of course I can add separate small of-handling functions (to do OF handling) tomtdcore.cto be replaced by empty functions in the absence ofCONFIG_OF, but this also look like overhead for me.
Quoted 7 lines
Quoted 4 lines
How about turning the "origin" argument into "void *private" and declaring that this is "parser-specific info". It then can become "origin" for the RedBoot parser and the OF node pointer for the ofpart parser?
And what will happen when ixp4xx (the only user of redboot "exception") will get OF support?
Hmm, may be introducing something like:
/**
* struct mtd_part_parser_data - used to pass data to MTD partition parsers.
* @origin: blah blah, RedBoot-specific
* @of_node: points to the OF node describing the partitions, ofpart-specific */
struct mtd_part_parser_data {
unsigned long origin;
struct device_node *of_node;
};And change the current "origin" argument with a
"struct mtd_part_parser_data *data" pointer?
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
Re: [PATCH 01/17] mtd: prepare to convert of_mtd_parse_partitions to partition parser
Quoted 2 lines · Artem Bityutskiy
And change the current "origin" argument with a
"structmtd_part_parser_data*data" pointer?
Which of course can be NULL if there is nothing to say, as well as of_node may be NULL, in which case the parsers which needs those things can just return "no partitions" or something like that?
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
Re: [PATCH 01/17] mtd: prepare to convert of_mtd_parse_partitions to partition parser
In reply to Dmitry Eremin-SolenikovQuoted 5 lines · Dmitry Eremin-Solenikov
I know they aren't nice. OTOH
ofpart.calso seems a bit non-logical: one can have of node in the MTD, but doesn't (strangely) want to compile inofpart.c. Of course I can add separate small of-handling functions (to do OF handling) tomtdcore.cto be replaced by empty functions in the absence ofCONFIG_OF, but this also look like overhead for me.
Anyway, if I understand correctly (correct me if I don't!) - this is basically about passing parser-specific information to parsers. And if this is right, your way of adding this parser-specific information to 'struct mtd_info *' is bad, and we need to invent something better.
Right?
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
PATCH 2/17 mtd: physmap_of: use ofpart through generic parsing
In reply to Dmitry Eremin-SolenikovConvert the driver to use ofpart partitions parsing through the generic parse_mtd_partitions().
--- drivers/mtd/maps/physmap_of.c | 10 +++------- 1 files changed, 3 insertions(+), 7 deletions(-)
drivers/mtd/maps/physmap_of.c +3 -7
@@ -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;
@@ -331,6 +332,7 @@ static int __devinit of_flash_probe(struct platform_device *dev)if (err) goto err_out; + info->cmtd->node = dp; part_probe_types =of_get_probes (dp); err =parse_mtd_partitions (info->cmtd, part_probe_types, &info->parts,0 );
@@ -341,12 +343,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;
Signature · 1 line
1.7.5.3
PATCH 3/17 mtd: m25p80: use ofpart through generic parsing
In reply to Dmitry Eremin-SolenikovConvert the driver to use ofpart partitions parsing through the generic parse_mtd_partitions().
--- drivers/mtd/devices/m25p80.c | 8 +------- 1 files changed, 1 insertions(+), 7 deletions(-)
drivers/mtd/devices/m25p80.c +1 -7
@@ -928,6 +928,7 @@ static int __devinit m25p_probe(struct spi_device *spi)if (info->flags &M25P_NO_ERASE ) flash->mtd.flags |=MTD_NO_ERASE ; + flash->mtd.node = spi->dev.of_node; flash->mtd.dev.parent = &spi->dev; flash->page_size = info->page_size;
@@ -975,13 +976,6 @@ static int __devinit m25p_probe(struct spi_device *spi) 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] = "
Signature · 1 line
1.7.5.3
PATCH 4/17 mtd: fsl_elbc_nand: use ofpart through generic parsing
In reply to Dmitry Eremin-SolenikovConvert the driver to use ofpart partitions parsing through the generic parse_mtd_partitions().
--- drivers/mtd/nand/fsl_elbc_nand.c | 9 ++------- 1 files changed, 2 insertions(+), 7 deletions(-)
drivers/mtd/nand/fsl_elbc_nand.c +2 -7
@@ -842,7 +842,7 @@ 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;
@@ -910,6 +910,7 @@ static int __devinit fsl_elbc_nand_probe(struct platform_device *pdev) goto err; } + priv->mtd.node = pdev->dev.of_node; priv->mtd.name =kasprintf (GFP_KERNEL ,"%x.flash" , (unsigned )res.start);if (!priv->mtd.name) { ret = -ENOMEM ;
@@ -938,12 +939,6 @@ static int __devinit fsl_elbc_nand_probe(struct platform_device *pdev)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",
Signature · 1 line
1.7.5.3
PATCH 5/17 mtd: fsl_upm: use ofpart through generic parsing
In reply to Dmitry Eremin-SolenikovConvert the driver to use ofpart partitions parsing through the generic parse_mtd_partitions().
--- drivers/mtd/nand/fsl_upm.c | 8 +------- 1 files changed, 1 insertions(+), 7 deletions(-)
drivers/mtd/nand/fsl_upm.c +1 -7
@@ -175,6 +175,7 @@ static int __devinit fun_chip_init(struct fsl_upm_nand *fun, fun->mtd.priv = &fun->chip; fun->mtd.owner =THIS_MODULE ; + fun->mtd.node = flash_np; flash_np =of_get_next_child (upm_np,NULL );if (!flash_np)
@@ -193,13 +194,6 @@ static int __devinit fun_chip_init(struct fsl_upm_nand *fun, ret =parse_mtd_partitions (&fun->mtd,NULL , &fun->parts,0 ); -#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);
Signature · 1 line
1.7.5.3
PATCH 6/17 mtd: mpc5121_nfc: use ofpart through generic parsing
In reply to Dmitry Eremin-SolenikovConvert the driver to use ofpart partitions parsing through the generic parse_mtd_partitions().
--- drivers/mtd/nand/mpc5121_nfc.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
drivers/mtd/nand/mpc5121_nfc.c +1 -4
@@ -725,6 +725,7 @@ static int __devinit mpc5121_nfc_probe(struct platform_device *op) } mtd->name ="MPC5121 NAND" ; + mtd->node = dn; chip->dev_ready = mpc5121_nfc_dev_ready; chip->cmdfunc = mpc5121_nfc_command; chip->read_byte = mpc5121_nfc_read_byte;
@@ -837,10 +838,6 @@ static int __devinit mpc5121_nfc_probe(struct platform_device *op)/* 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 if (retval <0 ) {dev_err (dev,"Error parsing MTD partitions!\n" );devm_free_irq (dev, prv->irq, mtd);
Signature · 1 line
1.7.5.3
PATCH 7/17 mtd: ndfc: use ofpart through generic parsing
In reply to Dmitry Eremin-SolenikovConvert the driver to use ofpart partitions parsing through the generic parse_mtd_partitions().
--- drivers/mtd/nand/ndfc.c | 8 +------- 1 files changed, 1 insertions(+), 7 deletions(-)
drivers/mtd/nand/ndfc.c +1 -7
@@ -188,6 +188,7 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,if (!flash_np)return -ENODEV ; + ndfc->mtd.node = flash_np; ndfc->mtd.name =kasprintf (GFP_KERNEL ,"%s.%s" ,dev_name (&ndfc->ofdev->dev), flash_np->name);if (!ndfc->mtd.name) {
@@ -203,13 +204,6 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,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:
Signature · 1 line
1.7.5.3
PATCH 8/17 mtd: socrates_nand: use ofpart through generic parsing
In reply to Dmitry Eremin-SolenikovConvert the driver to use ofpart partitions parsing through the generic parse_mtd_partitions().
--- drivers/mtd/nand/socrates_nand.c | 11 +---------- 1 files changed, 1 insertions(+), 10 deletions(-)
drivers/mtd/nand/socrates_nand.c +1 -10
@@ -191,6 +191,7 @@ static int __devinit socrates_nand_probe(struct platform_device *ofdev) mtd->name ="socrates_nand" ; mtd->owner =THIS_MODULE ; mtd->dev.parent = &ofdev->dev; + mtd->node = ofdev->dev.of_node;/*should never be accessed directly */ nand_chip->IO_ADDR_R = (void *)0xdeadbeef ;
@@ -229,16 +230,6 @@ static int __devinit socrates_nand_probe(struct platform_device *ofdev) 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;
Signature · 1 line
1.7.5.3
PATCH 9/17 mtd: drop of_mtd_parse_partitions()
In reply to Dmitry Eremin-SolenikovAll users have been converted to call of_mtd_parse_partitions through parse_mtd_partitions() multiplexer. Drop obsolete API.
--- drivers/mtd/ofpart.c | 16 ++++------------ include/linux/mtd/partitions.h | 16 ---------------- 2 files changed, 4 insertions(+), 28 deletions(-)
drivers/mtd/ofpart.c +4 -12
@@ -25,22 +25,15 @@ static int parse_ofpart_partitions(struct mtd_info *master, unsigned long origin) {struct device_node *node; +const char *partname; +struct device_node *pp; +int nr_parts, i; + node = master->node;if (!node)return 0 ; -return of_mtd_parse_partitions (NULL , node, pparts); -} - -int of_mtd_parse_partitions (struct device *dev, -struct device_node *node, -struct mtd_partition **pparts) -{ -const char *partname; -struct device_node *pp; -int nr_parts, i; -/* First count the subnodes */ pp =NULL ; nr_parts =0 ;
@@ -90,7 +83,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 ,
include/linux/mtd/partitions.h +0 -16
@@ -70,22 +70,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);
Signature · 1 line
1.7.5.3
PATCH 10/17 physmap_of: move parse_obsolete_partitions to become separate parser
In reply to Dmitry Eremin-SolenikovMove parse_obsolete_partitions() to ofpart.c and register it as an ofoldpart partitions parser.
--- drivers/mtd/maps/physmap_of.c | 53 +----------------------------- drivers/mtd/ofpart.c | 72 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 72 insertions(+), 53 deletions(-)
drivers/mtd/maps/physmap_of.c +1 -52
@@ -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;
@@ -342,12 +297,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);
drivers/mtd/ofpart.c +71 -1
80 lines not on this page · raw message
Signature · 1 line
1.7.5.3
PATCH 11/17 mtd: m25p80.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/devices/m25p80.c | 28 +++------------------------- 1 files changed, 3 insertions(+), 25 deletions(-)
drivers/mtd/devices/m25p80.c +3 -25
@@ -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 ;/* Platform data helps sort out which chip type we have, as * well as how this board partitions it. If we don't have
@@ -969,28 +966,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,0 ); - -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 ,0 , + data ? data->parts :NULL , + data ? data->nr_parts :0 ); }
Signature · 1 line
1.7.5.3
PATCH 11/17 mtd: physmap_of.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/maps/physmap_of.c | 18 +++--------------- 1 files changed, 3 insertions(+), 15 deletions(-)
drivers/mtd/maps/physmap_of.c +3 -15
@@ -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)
@@ -289,16 +283,10 @@ static int __devinit of_flash_probe(struct platform_device *dev) info->cmtd->node = dp; part_probe_types =of_get_probes (dp); - err =parse_mtd_partitions (info->cmtd, part_probe_types, - &info->parts,0 ); -if (err <0 ) { -of_free_probes (part_probe_types); - goto err_out; - } +mtd_device_parse_register (info->cmtd, part_probe_types,0 , +NULL ,0 );of_free_probes (part_probe_types); -mtd_device_register (info->cmtd, info->parts, err); -kfree (mtd_list);return 0 ;
Signature · 1 line
1.7.5.3
PATCH 12/17 mtd: m25p80.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/devices/m25p80.c | 28 +++------------------------- 1 files changed, 3 insertions(+), 25 deletions(-)
drivers/mtd/devices/m25p80.c +3 -25
@@ -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 ;/* Platform data helps sort out which chip type we have, as * well as how this board partitions it. If we don't have
@@ -969,28 +966,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,0 ); - -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 ,0 , + data ? data->parts :NULL , + data ? data->nr_parts :0 ); }
Signature · 1 line
1.7.5.3
PATCH 12/17 mtd: physmap_of.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/maps/physmap_of.c | 18 +++--------------- 1 files changed, 3 insertions(+), 15 deletions(-)
drivers/mtd/maps/physmap_of.c +3 -15
@@ -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)
@@ -289,16 +283,10 @@ static int __devinit of_flash_probe(struct platform_device *dev) info->cmtd->node = dp; part_probe_types =of_get_probes (dp); - err =parse_mtd_partitions (info->cmtd, part_probe_types, - &info->parts,0 ); -if (err <0 ) { -of_free_probes (part_probe_types); - goto err_out; - } +mtd_device_parse_register (info->cmtd, part_probe_types,0 , +NULL ,0 );of_free_probes (part_probe_types); -mtd_device_register (info->cmtd, info->parts, err); -kfree (mtd_list);return 0 ;
Signature · 1 line
1.7.5.3
PATCH 13/17 mtd: fsl_elbc_nand.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/fsl_elbc_nand.c | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-)
drivers/mtd/nand/fsl_elbc_nand.c +1 -6
@@ -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;
@@ -935,11 +934,7 @@ 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 ); -if (ret <0 ) - goto err; - -mtd_device_register (&priv->mtd, parts, ret); +mtd_device_parse_register (&priv->mtd, part_probe_types,0 ,NULL ,0 );printk (KERN_INFO "eLBC NAND device at 0x%llx, bank %d\n" , (unsigned long long )res.start, priv->bank);
Signature · 1 line
1.7.5.3
PATCH 14/17 mtd: fsl_upm.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/fsl_upm.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/mtd/nand/fsl_upm.c +1 -3
@@ -192,9 +192,7 @@ 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 ); - - ret =mtd_device_register (&fun->mtd, fun->parts, ret); + ret =mtd_device_parse_register (&fun->mtd,NULL ,0 ,NULL ,0 ); err:of_node_put (flash_np);return ret;
Signature · 1 line
1.7.5.3
PATCH 15/17 mtd: mpc5121_nfc.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/mpc5121_nfc.c | 11 +---------- 1 files changed, 1 insertions(+), 10 deletions(-)
drivers/mtd/nand/mpc5121_nfc.c +1 -10
@@ -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;
@@ -837,15 +836,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 ); -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 ,0 ,NULL ,0 );if (retval) {dev_err (dev,"Error adding MTD device!\n" );devm_free_irq (dev, prv->irq, mtd);
Signature · 1 line
1.7.5.3
PATCH 16/17 mtd: ndfc.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/ndfc.c | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-)
drivers/mtd/nand/ndfc.c +1 -6
@@ -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 ];
@@ -200,11 +199,7 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,if (ret) goto err; - ret =parse_mtd_partitions (&ndfc->mtd,NULL , &ndfc->parts,0 ); -if (ret <0 ) - goto err; - - ret =mtd_device_register (&ndfc->mtd, ndfc->parts, ret); + ret =mtd_device_parse_register (&ndfc->mtd,NULL ,0 ,NULL ,0 ); err:of_node_put (flash_np);
Signature · 1 line
1.7.5.3
PATCH 17/17 mtd: socrates_nand.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/socrates_nand.c | 11 +---------- 1 files changed, 1 insertions(+), 10 deletions(-)
drivers/mtd/nand/socrates_nand.c +1 -10
@@ -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 ;/* Allocate memory for the device structure (and zero it) */ host =kzalloc (sizeof (struct socrates_nand_host ),GFP_KERNEL );
@@ -224,17 +222,10 @@ static int __devinit socrates_nand_probe(struct platform_device *ofdev) goto out; } - num_partitions =parse_mtd_partitions (mtd,NULL , &partitions,0 ); -if (num_partitions <0 ) { - res = num_partitions; - goto release; - } - - res =mtd_device_register (mtd, partitions, num_partitions); + res =mtd_device_parse_register (mtd,NULL ,0 ,NULL ,0 );if (!res)return res; -release:nand_release (mtd); out:
Signature · 1 line
1.7.5.3