mtd: cleanup partition handling in OF-enabled drivers
Subsystems (2)
v2 cover mtd: cleanup partition handling in OF-enabled drivers
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(-)
PATCH v2 1/18 mtd: abstract last MTD partition parser argument
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.
--- 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(-)
drivers/mtd/afs.c +2 -2
@@ -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;
drivers/mtd/ar7part.c +1 -1
@@ -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;
drivers/mtd/cmdlinepart.c +2 -2
@@ -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;
drivers/mtd/mtdcore.c +3 -3
@@ -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 );
drivers/mtd/mtdpart.c +4 -3
@@ -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);
drivers/mtd/redboot.c +6 -7
@@ -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_
include/linux/mtd/mtd.h +2 -1
@@ -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);
include/linux/mtd/partitions.h +14 -2
@@ -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)
Signature · 1 line
1.7.5.3
PATCH v2 2/18 mtd: prepare to convert of_mtd_parse_partitions to partition parser
In reply to Dmitry Eremin-SolenikovPrepare 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
--- drivers/mtd/mtdpart.c | 8 ++++++-- drivers/mtd/ofpart.c | 27 +++++++++++++++++++++++++-- include/linux/mtd/partitions.h | 6 +++++- 3 files changed, 36 insertions(+), 5 deletions(-)
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 *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 +25 -2
@@ -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" );
include/linux/mtd/partitions.h +5 -1
@@ -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
Signature · 1 line
1.7.5.3
PATCH v2 3/18 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 | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-)
drivers/mtd/maps/physmap_of.c +5 -8
@@ -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;
Signature · 1 line
1.7.5.3
PATCH v2 4/18 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 | 11 +++-------- 1 files changed, 3 insertions(+), 8 deletions(-)
drivers/mtd/devices/m25p80.c +3 -8
@@ -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] = "
Signature · 1 line
1.7.5.3
PATCH v2 5/18 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 | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-)
drivers/mtd/nand/fsl_elbc_nand.c +4 -8
@@ -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",
Signature · 1 line
1.7.5.3
PATCH v2 6/18 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 | 11 +++-------- 1 files changed, 3 insertions(+), 8 deletions(-)
drivers/mtd/nand/fsl_upm.c +3 -8
@@ -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);
Signature · 1 line
1.7.5.3
PATCH v2 7/18 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 | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)
drivers/mtd/nand/mpc5121_nfc.c +3 -5
@@ -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);
Signature · 1 line
1.7.5.3
PATCH v2 8/18 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 | 11 +++-------- 1 files changed, 3 insertions(+), 8 deletions(-)
drivers/mtd/nand/ndfc.c +3 -8
@@ -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:
Signature · 1 line
1.7.5.3
PATCH v2 9/18 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 | 14 +++----------- 1 files changed, 3 insertions(+), 11 deletions(-)
drivers/mtd/nand/socrates_nand.c +3 -11
@@ -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;
Signature · 1 line
1.7.5.3
PATCH v2 10/18 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 | 20 +++++++++----------- include/linux/mtd/partitions.h | 16 ---------------- 2 files changed, 9 insertions(+), 27 deletions(-)
drivers/mtd/ofpart.c +9 -11
@@ -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 ,
include/linux/mtd/partitions.h +0 -16
@@ -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);
Signature · 1 line
1.7.5.3
PATCH v2 11/18 mtd: 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 | 75 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 75 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;
@@ -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);
drivers/mtd/ofpart.c +74 -1
83 lines not on this page · raw message
Signature · 1 line
1.7.5.3
PATCH v2 12/18 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)
@@ -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 ;
Signature · 1 line
1.7.5.3
PATCH v2 13/18 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 ;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 ); }
Signature · 1 line
1.7.5.3
PATCH v2 14/18 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 | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-)
drivers/mtd/nand/fsl_elbc_nand.c +2 -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;
@@ -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);
Signature · 1 line
1.7.5.3
PATCH v2 15/18 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
@@ -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;
Signature · 1 line
1.7.5.3
PATCH v2 16/18 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;
@@ -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);
Signature · 1 line
1.7.5.3
PATCH v2 17/18 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 ];
@@ -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);
Signature · 1 line
1.7.5.3
PATCH v2 18/18 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 ;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:
Signature · 1 line
1.7.5.3
Artem Bityutskiy
AppliedQuoted 5 lines · Dmitry Eremin-Solenikov
Changes since V1:
* Tab-vs-space cleanup
* 80-column cleanup
* documentedof_nodeparser data field
* changed documentation forparser_dataarguments
Pushed to l2-mtd-2.6.git, thanks for good cleanups.
Signature · 2 lines
Best Regards, Artem Bityutskiy